This commit is contained in:
David Doblas Jiménez 2021-08-06 13:46:44 +02:00
parent 7aa931a3fc
commit 3a939b4e9f

View File

@ -1,19 +1,17 @@
def update_table(): import time
""" from glob import glob
Update README.md with the timings of the solved problems from pathlib import Path
""" from subprocess import PIPE, run
text = read()
print(text)
def read(): def read_md():
""" """
Read README.md Read README.md
""" """
with open("../README.md", "r") as f: with open("../README.md", "r") as f:
text = [line.strip() for line in f.readlines() if line.strip() != ""] md = [line.strip() for line in f.readlines() if line.strip() != ""][1:]
return text[-1:] return md
def write(): def write_md():
""" """
Write to README.md Write to README.md
""" """
@ -23,17 +21,39 @@ def execute(num):
""" """
Execute script and return output Execute script and return output
""" """
import sys # import sys
sys.path.insert(0, "./Python/") # sys.path.insert(0, "./Python/")
import Problem001 # 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)
res = eval(f"Problem{num:0>3}.compute()")
print(res)
time = str(res).split(sep=" ")
print(time)
if __name__ == "__main__": if __name__ == "__main__":
# update_table() md = read_md()
execute(1) 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("."),
# )