Skip to content

Commit

Permalink
Stop resetting _input, step_input etc vatlab/jupyterlab-sos#36
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Jul 3, 2019
1 parent 8b7256f commit 1d03ef6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 12 additions & 1 deletion src/sos_notebook/step_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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
Expand Down
9 changes: 0 additions & 9 deletions src/sos_notebook/workflow_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__,
Expand Down

0 comments on commit 1d03ef6

Please sign in to comment.