import time from glob import glob from pathlib import Path from subprocess import PIPE, run def read_md(): """ Read README.md """ with open("../README.md", "r") as f: md = [line.strip() for line in f.readlines() if line.strip() != ""][1:] return md def write_md(): """ Write to README.md """ pass def execute(num): """ Execute script and return output """ # import sys # sys.path.insert(0, "./Python/") # from Python import Problem001 # res = eval(f"Problem{num:0>3}.compute()") # print(res) # time = str(res).split(sep=" ") # print(time) scripts = sorted(Path("Python/").glob("*[0-9].py")) # print(scripts[0].name) for script in scripts: run(["python3", f"{script}"]) time.sleep(5) if __name__ == "__main__": md = read_md() execute(1) # for c in chunks: # res = run( # [ # "sbatch", # "--parsable", # "--dependency=afterok:" + ":".join(str(j) for j in images_nbs), # "run2.sh", # str(f"{c:02}"), # your_path_for_notebooks.as_posix(), # ], # stdout=PIPE, # check=True, # cwd=Path("."), # )