From 8088b3ce146213a2d23994df00b5b6000a8bae6e Mon Sep 17 00:00:00 2001 From: Diego Struk Date: Tue, 5 May 2020 11:06:39 -0400 Subject: [PATCH 1/4] Adds changes for executing through cli with flow vars --- pyworkflow/pyworkflow/workflow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyworkflow/pyworkflow/workflow.py b/pyworkflow/pyworkflow/workflow.py index 6d29a07..70ac741 100644 --- a/pyworkflow/pyworkflow/workflow.py +++ b/pyworkflow/pyworkflow/workflow.py @@ -587,11 +587,12 @@ def execute_write_csv(self, node_id): preceding_data = self.load_input_data(node_to_execute.node_id) flow_nodes = self.load_flow_nodes(node_to_execute.option_replace) + print('flow-nodes') + print(flow_nodes) 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) From 41f2ed08e03b6c8d122bfb2decf9b73cf3ce327d Mon Sep 17 00:00:00 2001 From: Diego Struk Date: Tue, 5 May 2020 11:07:15 -0400 Subject: [PATCH 2/4] removes print statements --- pyworkflow/pyworkflow/workflow.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyworkflow/pyworkflow/workflow.py b/pyworkflow/pyworkflow/workflow.py index 70ac741..c223bc8 100644 --- a/pyworkflow/pyworkflow/workflow.py +++ b/pyworkflow/pyworkflow/workflow.py @@ -587,8 +587,6 @@ def execute_write_csv(self, node_id): preceding_data = self.load_input_data(node_to_execute.node_id) flow_nodes = self.load_flow_nodes(node_to_execute.option_replace) - print('flow-nodes') - print(flow_nodes) try: # Validate input data, and replace flow variables node_to_execute.validate_input_data(len(preceding_data)) From 92a708af985a6eb9c84458252eb0b5c79593596f Mon Sep 17 00:00:00 2001 From: Diego Struk Date: Tue, 5 May 2020 11:43:08 -0400 Subject: [PATCH 3/4] Adds verbose mode to get details on which node is being executed at which time --- CLI/cli.py | 11 +++++++---- pyworkflow/pyworkflow/workflow.py | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) 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 c223bc8..c8ce491 100644 --- a/pyworkflow/pyworkflow/workflow.py +++ b/pyworkflow/pyworkflow/workflow.py @@ -608,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. """ @@ -625,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) From bab54461cb428d6ae72b906035cd71c7f436d4f6 Mon Sep 17 00:00:00 2001 From: Diego Struk Date: Tue, 5 May 2020 12:01:39 -0400 Subject: [PATCH 4/4] Adds instruction to run CLI using verbose option to README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 90d589e..0bf9d79 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ data from `localhost:8000` **where the Django app must be running**. 2. Create a workflow using UI and save it. 3. Run it as: pyworkflow execute workflow-file -Also accepts reading input from std (i.e < file.csv) and writing to sdt out (i.e > output.csv) +- Also accepts reading input from std (i.e < file.csv) and writing to sdt out (i.e > output.csv) +- To see node execution details please use the verbose option (i.e pyworkflow execute --verbose workflow-file)