diff --git a/CLI/cli.py b/CLI/cli.py index 2e6bd98..48f663e 100644 --- a/CLI/cli.py +++ b/CLI/cli.py @@ -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() @@ -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: diff --git a/pyworkflow/pyworkflow/workflow.py b/pyworkflow/pyworkflow/workflow.py index 6d29a07..c8ce491 100644 --- a/pyworkflow/pyworkflow/workflow.py +++ b/pyworkflow/pyworkflow/workflow.py @@ -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) @@ -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. """ @@ -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)