-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:WinVector/wvpy
- Loading branch information
Showing
20 changed files
with
32,327 additions
and
1,152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Example driver sheet.\n", | ||
"\n", | ||
"This can be used to run many jobs in parallel." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pprint import pprint\n", | ||
"from wvpy.jtools import JTask, run_pool\n", | ||
"import imgkit\n", | ||
"import os" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# define tasks, rendering the same Jupyter notebook\n", | ||
"# with different sheet_vars values and ouput suffices.\n", | ||
"tasks = [\n", | ||
" JTask(\n", | ||
" \"task_sheet.ipynb\",\n", | ||
" output_suffix=\"_g1\",\n", | ||
" sheet_vars = {\n", | ||
" \"file_names\": [\n", | ||
" \"fname_1.txt\",\n", | ||
" \"fname_2.txt\",\n", | ||
" ],\n", | ||
" \"sheet_group\": \"g1\",\n", | ||
" },\n", | ||
" exclude_input=False,\n", | ||
" ),\n", | ||
" JTask(\n", | ||
" \"task_sheet.ipynb\",\n", | ||
" output_suffix=\"_g2\",\n", | ||
" sheet_vars = {\n", | ||
" \"file_names\": [\n", | ||
" \"fname_3.txt\",\n", | ||
" \"fname_4.txt\",\n", | ||
" ],\n", | ||
" \"sheet_group\": \"g2\",\n", | ||
" },\n", | ||
" exclude_input=True,\n", | ||
" ),\n", | ||
"]\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[JTask(\n", | ||
" sheet_name='task_sheet.ipynb',\n", | ||
" output_suffix='_g1',\n", | ||
" exclude_input=False,\n", | ||
" init_code=None,\n", | ||
" path_prefix=None,\n", | ||
" sheet_vars={'file_names': ['fname_1.txt', 'fname_2.txt'], 'sheet_group': 'g1'},\n", | ||
"),\n", | ||
" JTask(\n", | ||
" sheet_name='task_sheet.ipynb',\n", | ||
" output_suffix='_g2',\n", | ||
" exclude_input=True,\n", | ||
" init_code=None,\n", | ||
" path_prefix=None,\n", | ||
" sheet_vars={'file_names': ['fname_3.txt', 'fname_4.txt'], 'sheet_group': 'g2'},\n", | ||
")]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# print our tasks\n", | ||
"pprint(tasks)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"start render_as_html \"task_sheet.ipynb\" \"_g2\" 2023-07-02 12:08:33.054926\n", | ||
"start render_as_html \"task_sheet.ipynb\" \"_g1\" 2023-07-02 12:08:33.056136\n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"This version of python seems to be incorrectly compiled\n", | ||
"(internal generated filenames are not absolute).\n", | ||
"This may make the debugger miss breakpoints.\n", | ||
"Related bug: http://bugs.python.org/issue1666807\n", | ||
"This version of python seems to be incorrectly compiled\n", | ||
"(internal generated filenames are not absolute).\n", | ||
"This may make the debugger miss breakpoints.\n", | ||
"Related bug: http://bugs.python.org/issue1666807\n", | ||
"This version of python seems to be incorrectly compiled\n", | ||
"(internal generated filenames are not absolute).\n", | ||
"This may make the debugger miss breakpoints.\n", | ||
"Related bug: http://bugs.python.org/issue1666807\n", | ||
"This version of python seems to be incorrectly compiled\n", | ||
"(internal generated filenames are not absolute).\n", | ||
"This may make the debugger miss breakpoints.\n", | ||
"Related bug: http://bugs.python.org/issue1666807\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\tdone render_as_html \"task_sheet_g2.html\" 2023-07-02 12:08:35.352744\n", | ||
"\tdone render_as_html \"task_sheet_g1.html\" 2023-07-02 12:08:35.438916\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[None, None]" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# run the tasks, in parallel\n", | ||
"# ignore warning msgs\n", | ||
"# \"This version of python seems to be incorrectly compiled\"\n", | ||
"# Just MacOS problems\n", | ||
"run_pool(\n", | ||
" tasks,\n", | ||
" njobs=2,\n", | ||
" verbose=False,\n", | ||
" stop_on_error=False,\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Loading page (1/2)\n", | ||
"Rendering (2/2) \n", | ||
"Done \n", | ||
"Loading page (1/2)\n", | ||
"Rendering (2/2) \n", | ||
"Done \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# convert HTMLs from renders to PNGs to show\n", | ||
"for fname in os.listdir():\n", | ||
" if fname.startswith('task_sheet_') and fname.endswith('.html'):\n", | ||
" imgkit.from_file(fname, fname.removesuffix('.html') + \".png\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "wvpy_dev_env", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.3" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Example task sheet.\n", | ||
"\n", | ||
"Example of a single job to run. Values come in through `sheet_vars` and even optional `init_code`." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pprint import pprint\n", | ||
"from IPython.display import display, HTML, Markdown" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"display(HTML(f'File names assigned: {sheet_vars[\"file_names\"]}.'))" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The sheet variables are the following." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pprint(sheet_vars)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.