From 1d03ef61ead8d8fcafef67e8b5d823d71ea5cc20 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Wed, 3 Jul 2019 10:04:01 -0500 Subject: [PATCH] Stop resetting _input, step_input etc vatlab/jupyterlab-sos#36 --- src/sos_notebook/step_executor.py | 13 ++++++++++++- src/sos_notebook/workflow_executor.py | 9 --------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/sos_notebook/step_executor.py b/src/sos_notebook/step_executor.py index 93c520e..ed1c801 100755 --- a/src/sos_notebook/step_executor.py +++ b/src/sos_notebook/step_executor.py @@ -9,7 +9,7 @@ from sos.hosts import Host from sos.step_executor import Base_Step_Executor from sos.utils import env, short_repr - +from sos.targets import sos_targets class Interactive_Step_Executor(Base_Step_Executor): @@ -18,6 +18,17 @@ def __init__(self, step, mode='interactive'): self.run_mode = mode self.host = None + def init_input_output_vars(self): + # we keep these variables (which can be result of stepping through previous statements) + # if no input and/or output statement is defined + if any(x[0] == ':' and x[1] == 'input' for x in self.step.statements): + env.sos_dict.set('step_input', sos_targets([])) + env.sos_dict.set('_input', sos_targets([])) + if any(x[0] == ':' and x[1] == 'output' for x in self.step.statements): + env.sos_dict.set('step_output', sos_targets([])) + env.sos_dict.set('_output', sos_targets([])) + env.sos_dict.pop('__default_output__', None) + def submit_tasks(self, tasks): if not tasks: return diff --git a/src/sos_notebook/workflow_executor.py b/src/sos_notebook/workflow_executor.py index 2dba5ce..653832c 100755 --- a/src/sos_notebook/workflow_executor.py +++ b/src/sos_notebook/workflow_executor.py @@ -118,15 +118,6 @@ def execute_scratch_cell(code, raw_args, kernel): else: env.logger.handers[0].setTitle(' '.join(sys.argv)) - # clear __step_input__, __step_output__ etc because there is - # no concept of passing input/outputs across cells. - env.sos_dict.set('__step_output__', sos_targets([])) - for k in [ - '__step_input__', '__default_output__', 'step_input', 'step_output', - 'step_depends', '_input', '_output', '_depends' - ]: - env.sos_dict.pop(k, None) - config = { 'config_file': args.__config__, 'default_queue': '' if args.__queue__ is None else args.__queue__,