Skip to content

Commit 75454c4

Browse files
authored
Merge pull request #1848 from danforthcenter/exclude-plot-image
Exclude plot image
2 parents d0f4fee + 0a424ee commit 75454c4

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

docs/parallel_jupyterconfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The `jupyterconfig` class is very similar to the [`WorkflowConfig` class](parall
44

55
### Quick Start
66

7-
Initializing a `jupyterconfig` object in a Jupyter notebook will immediately use `nbconvert` to create a python script version of the workflow. When the python script is generated notebook cells marked with `@ignore` as the start of a comment (`# @ignore`) are excluded, which may be useful to avoid making diagnostic plots in parallel or otherwise in keeping your notebook reproducible. Similar to `WorkflowConfig` objects you can overwrite default attributes to meet your particular needs. Once your edits are done the `run` method will run the workflow in parallel. Note that you will need to specify arguments with [`workflow_inputs`](parallel_workflow_inputs.md) how you would when using `WorkflowConfig` to run a script in parallel.
7+
Initializing a `jupyterconfig` object in a Jupyter notebook will immediately use `nbconvert` to create a python script version of the workflow. When the python script is generated notebook cells marked with `@ignore` as the start of a comment (`# @ignore`) are excluded, which may be useful to avoid making diagnostic plots in parallel or otherwise in keeping your notebook reproducible. Any calls to `plot_image` will also be removed. Similar to `WorkflowConfig` objects you can overwrite default attributes to meet your particular needs. Once your edits are done the `run` method will run the workflow in parallel. Note that you will need to specify arguments with [`workflow_inputs`](parallel_workflow_inputs.md) how you would when using `WorkflowConfig` to run a script in parallel.
88

99
```python
1010
from plantcv import parallel as pcvpar

plantcv/parallel/jupyterconfig.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ def notebook2script(self):
143143
source, _ = exporter.from_notebook_node(nb)
144144
# Write the output to a Python file
145145
with open(self.workflow, 'w') as fh:
146-
fh.writelines(source)
146+
pattern = pattern = r".*?(.*?[.])?plot_image\(.*?\).*\n?|.*get_ipython\(\).*\n?"
147+
fh.writelines(re.sub(pattern, "", source))
147148
# return boolean for if self.script exists
148149
return os.path.exists(self.workflow)
149150

0 commit comments

Comments
 (0)