Skip to content

Commit fc58222

Browse files
committed
work on sheet vars exmaple
1 parent a66a4d6 commit fc58222

File tree

6 files changed

+30785
-0
lines changed

6 files changed

+30785
-0
lines changed
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"metadata": {},
7+
"source": [
8+
"Example driver sheet."
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": 1,
14+
"metadata": {},
15+
"outputs": [],
16+
"source": [
17+
"from pprint import pprint\n",
18+
"from wvpy.jtools import JTask, run_pool\n",
19+
"import imgkit\n",
20+
"import os"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": null,
26+
"metadata": {},
27+
"outputs": [],
28+
"source": []
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": 2,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"tasks = [\n",
37+
" JTask(\n",
38+
" \"task_sheet.ipynb\",\n",
39+
" output_suffix=\"_g1\",\n",
40+
" sheet_vars = {\n",
41+
" \"file_names\": [\n",
42+
" \"fname_1.txt\",\n",
43+
" \"fname_2.txt\",\n",
44+
" ]},\n",
45+
" ),\n",
46+
" JTask(\n",
47+
" \"task_sheet.ipynb\",\n",
48+
" output_suffix=\"_g2\",\n",
49+
" sheet_vars = {\n",
50+
" \"file_names\": [\n",
51+
" \"fname_3.txt\",\n",
52+
" \"fname_4.txt\",\n",
53+
" ]},\n",
54+
" ),\n",
55+
"]\n"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": 3,
61+
"metadata": {},
62+
"outputs": [
63+
{
64+
"name": "stdout",
65+
"output_type": "stream",
66+
"text": [
67+
"[JTask(\n",
68+
" sheet_name='task_sheet.ipynb',\n",
69+
" output_suffix='_g1',\n",
70+
" exclude_input=True,\n",
71+
" init_code=None,\n",
72+
" path_prefix=None,\n",
73+
" sheet_vars={'file_names': ['fname_1.txt', 'fname_2.txt']},\n",
74+
"),\n",
75+
" JTask(\n",
76+
" sheet_name='task_sheet.ipynb',\n",
77+
" output_suffix='_g2',\n",
78+
" exclude_input=True,\n",
79+
" init_code=None,\n",
80+
" path_prefix=None,\n",
81+
" sheet_vars={'file_names': ['fname_3.txt', 'fname_4.txt']},\n",
82+
")]\n"
83+
]
84+
}
85+
],
86+
"source": [
87+
"pprint(tasks)"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": 4,
93+
"metadata": {},
94+
"outputs": [
95+
{
96+
"name": "stdout",
97+
"output_type": "stream",
98+
"text": [
99+
"start render_as_html \"task_sheet.ipynb\" \"_g1\" 2023-07-02 11:52:33.286698\n",
100+
"start render_as_html \"task_sheet.ipynb\" \"_g2\" 2023-07-02 11:52:33.286955\n"
101+
]
102+
},
103+
{
104+
"name": "stderr",
105+
"output_type": "stream",
106+
"text": [
107+
"This version of python seems to be incorrectly compiled\n",
108+
"(internal generated filenames are not absolute).\n",
109+
"This may make the debugger miss breakpoints.\n",
110+
"Related bug: http://bugs.python.org/issue1666807\n",
111+
"This version of python seems to be incorrectly compiled\n",
112+
"(internal generated filenames are not absolute).\n",
113+
"This may make the debugger miss breakpoints.\n",
114+
"Related bug: http://bugs.python.org/issue1666807\n",
115+
"This version of python seems to be incorrectly compiled\n",
116+
"(internal generated filenames are not absolute).\n",
117+
"This may make the debugger miss breakpoints.\n",
118+
"Related bug: http://bugs.python.org/issue1666807\n",
119+
"This version of python seems to be incorrectly compiled\n",
120+
"(internal generated filenames are not absolute).\n",
121+
"This may make the debugger miss breakpoints.\n",
122+
"Related bug: http://bugs.python.org/issue1666807\n"
123+
]
124+
},
125+
{
126+
"name": "stdout",
127+
"output_type": "stream",
128+
"text": [
129+
"\tdone render_as_html \"task_sheet_g2.html\" 2023-07-02 11:52:35.467671\n",
130+
"\tdone render_as_html \"task_sheet_g1.html\" 2023-07-02 11:52:35.467699\n"
131+
]
132+
},
133+
{
134+
"data": {
135+
"text/plain": [
136+
"[None, None]"
137+
]
138+
},
139+
"execution_count": 4,
140+
"metadata": {},
141+
"output_type": "execute_result"
142+
}
143+
],
144+
"source": [
145+
"# ignore \n",
146+
"# \"This version of python seems to be incorrectly compiled\"\n",
147+
"# Just MacOS problems\n",
148+
"run_pool(\n",
149+
" tasks,\n",
150+
" njobs=2,\n",
151+
" verbose=False,\n",
152+
" stop_on_error=False,\n",
153+
")"
154+
]
155+
},
156+
{
157+
"cell_type": "code",
158+
"execution_count": 5,
159+
"metadata": {},
160+
"outputs": [
161+
{
162+
"name": "stdout",
163+
"output_type": "stream",
164+
"text": [
165+
"Loading page (1/2)\n",
166+
"Rendering (2/2) \n",
167+
"Done \n",
168+
"Loading page (1/2)\n",
169+
"Rendering (2/2) \n",
170+
"Done \n"
171+
]
172+
}
173+
],
174+
"source": [
175+
"for fname in os.listdir():\n",
176+
" if fname.startswith('task_sheet_') and fname.endswith('.html'):\n",
177+
" imgkit.from_file(fname, fname.removesuffix('.html') + \".png\")"
178+
]
179+
},
180+
{
181+
"cell_type": "code",
182+
"execution_count": null,
183+
"metadata": {},
184+
"outputs": [],
185+
"source": []
186+
}
187+
],
188+
"metadata": {
189+
"kernelspec": {
190+
"display_name": "wvpy_dev_env",
191+
"language": "python",
192+
"name": "python3"
193+
},
194+
"language_info": {
195+
"codemirror_mode": {
196+
"name": "ipython",
197+
"version": 3
198+
},
199+
"file_extension": ".py",
200+
"mimetype": "text/x-python",
201+
"name": "python",
202+
"nbconvert_exporter": "python",
203+
"pygments_lexer": "ipython3",
204+
"version": "3.11.3"
205+
},
206+
"orig_nbformat": 4
207+
},
208+
"nbformat": 4,
209+
"nbformat_minor": 2
210+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": []
9+
},
10+
{
11+
"attachments": {},
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"Example task sheet"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": null,
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"from pprint import pprint"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": null,
30+
"metadata": {},
31+
"outputs": [],
32+
"source": [
33+
"pprint(sheet_vars[\"file_names\"])"
34+
]
35+
}
36+
],
37+
"metadata": {
38+
"language_info": {
39+
"name": "python"
40+
},
41+
"orig_nbformat": 4
42+
},
43+
"nbformat": 4,
44+
"nbformat_minor": 2
45+
}

0 commit comments

Comments
 (0)