Skip to content

Commit

Permalink
Merge branch 'dev/diego'
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Struk committed May 7, 2020
2 parents 3903abf + 8106e2e commit b2f2bcc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 7 additions & 4 deletions back-end/CLI/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def cli():

@cli.command()
@click.argument('filename', type=click.Path(exists=True), nargs=-1)
def execute(filename):
@click.option('--verbose', is_flag=True, help='Enables verbose mode.')
def execute(filename, verbose):

write_to_stdout = not click.get_text_stream('stdout').isatty()

Expand All @@ -45,15 +46,17 @@ def execute(filename):

stdin_files.append(file_name)



if workflow_file is None:
click.echo('Please specify a workflow to run')
return
try:
if not write_to_stdout:
click.echo('Loading workflow file from %s' % workflow_file)
Workflow.execute_workflow(workflow_file, stdin_files, write_to_stdout)

Workflow.execute_workflow(workflow_file, stdin_files, write_to_stdout, verbose)

if verbose:
click.echo('Completed workflow execution!')


except NodeException as ne:
Expand Down
9 changes: 6 additions & 3 deletions back-end/pyworkflow/pyworkflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,7 @@ def execute_write_csv(self, node_id):
try:
# Validate input data, and replace flow variables
node_to_execute.validate_input_data(len(preceding_data))
execution_options = node_to_execute.get_execution_options(flow_nodes)

execution_options = node_to_execute.get_execution_options(self, flow_nodes)
# Pass in data to current Node to use in execution
output = node_to_execute.execute(preceding_data, execution_options)

Expand All @@ -609,7 +608,7 @@ def execute_write_csv(self, node_id):
return node_to_execute

@staticmethod
def execute_workflow(workflow_location, stdin_files, write_to_stdout):
def execute_workflow(workflow_location, stdin_files, write_to_stdout, verbose_mode):
"""Execute entire workflow at a certain location.
Current use case: CLI.
"""
Expand All @@ -626,6 +625,10 @@ def execute_workflow(workflow_location, stdin_files, write_to_stdout):
#execute each node in the order returned by execution order method
#TODO exception handling: stop and provide details on which node failed to execute
for node in execution_order:

if verbose_mode:
print('Executing node of type ' + str(type(workflow_instance.get_node(node))))

if type(workflow_instance.get_node(node)) is ReadCsvNode and len(stdin_files) > 0:
csv_location = stdin_files[0]
executed_node = workflow_instance.execute_read_csv(node, csv_location)
Expand Down

0 comments on commit b2f2bcc

Please sign in to comment.