-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_examples.py
39 lines (35 loc) · 1.09 KB
/
run_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import datetime
from multiprocessing import Pool
from wvpy.jtools import JTask, job_fn
import imgkit
import pdfkit
import pprint
if __name__ == "__main__":
# define the tasks
tasks = [
JTask(
sheet_name="ParamExample",
output_suffix=f"_{value_map['n']}_{value_map['run_date']}",
exclude_input=True,
init_code=f"""
import datetime
worksheet_params = {repr(value_map)}
""",
)
for value_map in [
{"n": 5, "run_date": datetime.date(2022, 8, 18)},
{"n": 10, "run_date": datetime.date(2022, 8, 19)},
{"n": 15, "run_date": datetime.date(2022, 8, 20)},
]
]
print("starting tasks:")
pprint.pprint(tasks)
# do the work
with Pool(4) as p:
p.map(job_fn, tasks)
# convert to different formats
for fname in os.listdir():
if fname.startswith('ParamExample_') and fname.endswith('.html'):
imgkit.from_file(fname, fname.removesuffix('.html') + ".png")
# pdfkit.from_file(fname, fname.removesuffix('.html') + ".pdf")