diff --git a/marzipan/TODO.md b/marzipan/TODO.md index b64bb76..a70a968 100644 --- a/marzipan/TODO.md +++ b/marzipan/TODO.md @@ -16,14 +16,13 @@ * ~~why is everything red in the pretty output? (see line 96 in __init__.py)~~ * ~~awk RESULT flush in marzipan()~~ * ~~move the whole metaverif function to Python~~ +* ~move the whole analyze function to Python~ + * ~find the files~ + * ~start subprocesses in parallel~ + * ~wait for them to finish~ ## Next Steps - -* move the whole analyze function to Python - * find the files - * start subprocesses in parallel - * wait for them to finish * think about next steps * integrate this upstream, into the CI? * “make it beautiful” steps? more resiliency to working directory? diff --git a/marzipan/src/__init__.py b/marzipan/src/__init__.py index 4ef0c9f..30f4532 100644 --- a/marzipan/src/__init__.py +++ b/marzipan/src/__init__.py @@ -41,7 +41,7 @@ def _run_proverif(file, extra_args=[]): try: null, p = clean_warnings_init() for line in process.stdout: - print(f"received a line: {line.strip()}") + #print(f"received a line: {line.strip()}") # clean warnings line = line.rstrip() if not pkgs.re.match(r"^Warning: identifier \w+ rebound.$", line): @@ -165,14 +165,27 @@ def pretty_output(file_path): @click.command() -@click.argument("command") @click.argument("path") -def analyze(command, path): - exc([ - f"{pkgs.pathlib.Path(__file__).resolve().parent}/analyze.sh", - command, - path - ]) +def analyze(path): + pkgs.os.chdir(path) + + tmpdir = "target/proverif" + pkgs.os.makedirs(tmpdir, exist_ok=True) + + entries = [] + entries.extend(sorted(pkgs.glob.glob('analysis/*.entry.mpv'))) + + with pkgs.concurrent.futures.ProcessPoolExecutor() as executor: + futures = {executor.submit(_metaverif, tmpdir, entry): entry for entry in entries} + for future in pkgs.concurrent.futures.as_completed(futures): + cmd = futures[future] + try: + #res = future.result() + print(f"Metaverif {cmd} finished.", file=pkgs.sys.stderr) + except Exception as e: + print(f"Metaverif {cmd} generated an exception: {e}") + + print("all processes finished.") @click.command() @@ -232,6 +245,10 @@ def clean_warnings(): @click.argument("tmpdir") @click.argument("file") def metaverif(tmpdir, file): + metaverif(tmpdir, file) + +def _metaverif(tmpdir, file): + print(f"Start metaverif on {file}") # Extract the name using regex name_match = pkgs.re.search(r'([^/]*)(?=\.mpv)', file) if name_match: