Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds verbose CLI mode option #85

Merged
merged 5 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions 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 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