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