Skip to content

Commit

Permalink
Add a command to list the dependencies of a task
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Oct 13, 2023
1 parent 4c93ee7 commit d42470c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bioluigi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,39 @@ def show(task_id):
click.echo('No such task %s.' % task_id, err=True)
sys.exit(1)

@main.command()
@click.argument('task_id')
@click.option('--status', multiple=True)
@click.option('--summary', is_flag=True)
@click.option('--detailed', is_flag=True)
@click.option('--extract-id', is_flag=True)
@click.option('--extract-parameter')
def list_dependencies(task_id, status, summary, detailed, extract_id, extract_parameter):
"""
List all the dependencies of the given task ID.
"""
deps = rpc('dep_graph', task_id=task_id)
fix_tasks_dict(deps)
if status:
deps = {dep_id: deps[dep_id] for dep_id in deps if deps[dep_id]['status'] in status}
if summary:
formatter = TasksSummaryFormatter()
elif detailed:
# deps are missing a display name so we have to reconstruct it from the
# name and parameters
for dep_id in deps:
params = deps[dep_id]['params']
deps[dep_id]['display_name'] = deps[dep_id]['name'] + '(' + ', '.join(p + '=' + params[p] for p in sorted(params.keys())) + ')'
formatter = DetailedTaskFormatter()
elif extract_id:
formatter = ExtractingIdTaskFormatter()
elif extract_parameter is not None:
formatter = ExtractingParameterTaskFormatter(field=extract_parameter)
else:
dep_id_width = max(len(dep_id) for dep_id in deps)
formatter = InlineTaskFormatter(task_id_width=dep_id_width)
click.echo_via_pager(formatter.format_multiple(deps.values()))

@main.command()
@click.argument('task_id')
@click.option('--recursive', is_flag=True, help='Reenable all the dependencies of a task.')
Expand Down

0 comments on commit d42470c

Please sign in to comment.