feat: Output experiment result into folder
This commit is contained in:
parent
02b56c937f
commit
97f22ed67a
|
@ -0,0 +1 @@
|
||||||
|
/result
|
|
@ -213,13 +213,16 @@ def full_proof_search_dsp_lean(
|
||||||
eng: Engine,
|
eng: Engine,
|
||||||
server: Server,
|
server: Server,
|
||||||
data: list[Datum],
|
data: list[Datum],
|
||||||
|
path_output: Path,
|
||||||
):
|
):
|
||||||
print(colored(f"DSP on {len(data)} points", "blue", attrs=["bold", "underline"]))
|
print(colored(f"DSP on {len(data)} points", "blue", attrs=["bold", "underline"]))
|
||||||
# -- Proof search by DSP over all eval data
|
# -- Proof search by DSP over all eval data
|
||||||
for datum in tqdm(data, total=len(data), desc='DSP proof loop per data point in benchmark.'):
|
for i, datum in tqdm(enumerate(data), total=len(data), desc='DSP proof loop per data point in benchmark.'):
|
||||||
print("Problem:", colored(datum.id, "cyan"))
|
print(f"Problem {i}:", colored(str(datum), "cyan"))
|
||||||
result = single_proof_search_dsp_lean(eng, server, datum)
|
result = single_proof_search_dsp_lean(eng, server, datum)
|
||||||
print(result)
|
file_name = path_output / f"{i:03}.json"
|
||||||
|
with open(file_name, 'w') as f:
|
||||||
|
json.dump({ 'name': str(datum), 'success': result.success, 'steps': result.steps }, f)
|
||||||
#server.gc()
|
#server.gc()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -253,9 +256,13 @@ def load_data(args) -> list[Datum]:
|
||||||
# -- Main
|
# -- Main
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
import time
|
import time, datetime
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
|
# Setup paths and data
|
||||||
data_eval = load_data(args)
|
data_eval = load_data(args)
|
||||||
|
path_output = Path(args.output)
|
||||||
|
path_output.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
project_path, lean_path = get_project_and_lean_path()
|
project_path, lean_path = get_project_and_lean_path()
|
||||||
|
@ -302,9 +309,10 @@ def main(args):
|
||||||
)
|
)
|
||||||
|
|
||||||
# - Full proof search with DSP
|
# - Full proof search with DSP
|
||||||
full_proof_search_dsp_lean(eng, server, data_eval)
|
full_proof_search_dsp_lean(eng, server, data_eval, path_output)
|
||||||
msg = f"Time taken: {time.time() - start_time:.2f} seconds, or {(time.time() - start_time) / 60:.2f} minutes, or {(time.time() - start_time) / 3600:.2f} hours.\a"
|
|
||||||
print(colored(msg, "magenta"))
|
dt = datetime.timedelta(seconds=time.time() - start_time)
|
||||||
|
print(colored(f"Time elapsed: {dt}", "magenta"))
|
||||||
|
|
||||||
# - End run
|
# - End run
|
||||||
# wandb.config.update(config)
|
# wandb.config.update(config)
|
||||||
|
@ -329,6 +337,11 @@ if __name__ == "__main__":
|
||||||
help="Evaluation dataset path",
|
help="Evaluation dataset path",
|
||||||
default=experiment_dir / 'debug/toy_example1_dsp/dsp_debug5_sf/dsp_debug5_sf_train.json',
|
default=experiment_dir / 'debug/toy_example1_dsp/dsp_debug5_sf/dsp_debug5_sf_train.json',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output",
|
||||||
|
help="Result directory",
|
||||||
|
default=experiment_dir / 'result',
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model",
|
"--model",
|
||||||
help="Model",
|
help="Model",
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Datum:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.id:
|
if self.id:
|
||||||
return self.id
|
return self.id
|
||||||
return str(self.nl_problem)
|
return self.nl_problem_str
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def nl_problem_str(self) -> Optional[str]:
|
def nl_problem_str(self) -> Optional[str]:
|
||||||
|
|
Loading…
Reference in New Issue