-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from verified_cogen.tools import compare_errors | ||
|
||
|
||
def test_compare_errors1(): | ||
err1: str = "Verification timed out" | ||
err2: str = "Verification timed out" | ||
assert compare_errors(err1, err2) | ||
|
||
def test_compare_errors2(): | ||
err1: str = "Verification timed out" | ||
err2: str = """\ | ||
Translation failed | ||
Not supported: (0 <= d_6_i_ <= len(l)) | ||
(/home/aleksandr/verified-cogen/log_tries/humaneval-nagini/[email protected])""" | ||
assert not compare_errors(err1, err2) | ||
|
||
def test_compare_errors3(): | ||
err1: str = """\ | ||
Translation failed | ||
Type error: invalid syntax (/home/aleksandr/verified-cogen/log_tries/humaneval-nagini/[email protected])""" | ||
err2: str = """\ | ||
Translation failed | ||
Type error: invalid syntax (/home/aleksandr/verified-cogen/log_tries/humaneval-nagini/[email protected])""" | ||
assert compare_errors(err1, err2) | ||
|
||
def test_compare_errors4(): | ||
err1: str = """\ | ||
Translation failed | ||
Type error: invalid syntax (/home/aleksandr/verified-cogen/log_tries/humaneval-nagini/[email protected])""" | ||
err2: str = """\ | ||
Translation failed | ||
Type error: invalid syntax (/home/aleksandr/verified-cogen/log_tries/humaneval-nagini/[email protected])""" | ||
assert not compare_errors(err1, err2) | ||
|
||
def test_compare_errors5(): | ||
err1: str = """\ | ||
Verification failed | ||
Errors: | ||
Loop invariant might not be preserved. Assertion (s == psum(0, d_2_i_, numbers)) might not hold. ([email protected]) | ||
Verification took 9.04 seconds.""" | ||
err2: str = """\ | ||
Verification failed | ||
Errors: | ||
Loop invariant might not be preserved. Assertion (s == psum(0, d_2_i_, numbers)) might not hold. ([email protected]) | ||
Verification took 13.72 seconds.""" | ||
assert compare_errors(err1, err2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from typing import Optional | ||
from verified_cogen.runners import Runner | ||
from verified_cogen.runners.step_by_step import StepByStepRunner, StepByStepConfig | ||
from verified_cogen.tools import compare_errors | ||
|
||
|
||
class StepByStepFlushRunner(StepByStepRunner): | ||
previous_error: str = "" | ||
timeout: str = "Verification timed out" | ||
|
||
def __init__(self, wrapping: Runner, config: Optional[StepByStepConfig] = None): | ||
super().__init__(wrapping, config) | ||
|
||
def flush_and_rewrite(self) -> str: | ||
assert self.starting_prg is not None | ||
self.llm.wipe_all() | ||
self.previous_error = "" | ||
self.logger.info("Encountered same error. Rewrite") | ||
return self.rewrite(self.starting_prg) | ||
|
||
def ask_for_timeout(self) -> str: | ||
if compare_errors(self.previous_error, self.timeout): | ||
return self.flush_and_rewrite() | ||
else: | ||
self.previous_error = self.timeout | ||
return self.wrapped_runner.ask_for_timeout() | ||
|
||
def ask_for_fixed(self, err: str) -> str: | ||
if compare_errors(self.previous_error, err): | ||
return self.flush_and_rewrite() | ||
else: | ||
self.previous_error = err | ||
return self.wrapped_runner.ask_for_fixed(err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters