Skip to content

Commit

Permalink
added an option to not make the dags dir, set to false for archive
Browse files Browse the repository at this point in the history
  • Loading branch information
leahh committed Sep 23, 2024
1 parent 605234e commit e72e1be
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions beeflow/client/bee_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,9 @@ def reexecute(wf_name: str = typer.Argument(..., help='The workflow name'),
@app.command()
def dag(wf_id: str = typer.Argument(..., callback=match_short_id),
output_dir: pathlib.Path = typer.Argument(...,
help='Path to the where the dag directory will be')):
help='Path to the where the dag output will be'),
no_dag_dir: bool = typer.Option(False, '--no-dag-dir',
help='do not make a subdirectory within ouput_dir for the dags')):
"""Export a DAG of the workflow to a GraphML file."""
output_dir = output_dir.resolve()

Expand All @@ -639,7 +641,7 @@ def dag(wf_id: str = typer.Argument(..., callback=match_short_id),

# output_dir must be a string
output_dir = str(output_dir)
wf_utils.export_dag(wf_id, output_dir)
wf_utils.export_dag(wf_id, output_dir, no_dag_dir)
typer.secho(f"DAG for workflow {_short_id(wf_id)} has been exported successfully.",
fg=typer.colors.GREEN)

Expand Down
10 changes: 7 additions & 3 deletions beeflow/common/gdb/generate_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
graphmls_dir = os.path.join(bee_workdir, 'graphmls')


def generate_viz(wf_id, output_dir):
def generate_viz(wf_id, output_dir, no_dag_dir):
"""Generate a PNG of a workflow graph from a GraphML file."""
short_id = wf_id[:6]
graphml_path = graphmls_dir + "/" + short_id + ".graphml"
dags_dir = output_dir + "/" + short_id + "_dags"
os.makedirs(dags_dir, exist_ok=True)

if no_dag_dir:
dags_dir = output_dir
else:
dags_dir = output_dir + "/" + short_id + "_dags"
os.makedirs(dags_dir, exist_ok=True)

output_path = dags_dir + "/" + short_id + ".png"
if os.path.exists(output_path):
Expand Down
2 changes: 1 addition & 1 deletion beeflow/wf_manager/resources/wf_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def archive_workflow(db, wf_id, final_state=None):
archive_path = f'../archives/{wf_id}.tgz'
# We use tar directly since tarfile is apparently very slow
workflows_dir = wf_utils.get_workflows_dir()
wf_utils.export_dag(wf_id, workflow_dir)
wf_utils.export_dag(wf_id, workflow_dir, no_dag_dir=True)
subprocess.call(['tar', '-czf', archive_path, wf_id], cwd=workflows_dir)
remove_wf_dir = bc.get('DEFAULT', 'delete_completed_workflow_dirs')
if remove_wf_dir:
Expand Down
4 changes: 2 additions & 2 deletions beeflow/wf_manager/resources/wf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ def setup_workflow(wf_id, wf_name, wf_dir, wf_workdir, no_start, workflow=None,
start_workflow(wf_id)


def export_dag(wf_id, output_dir):
def export_dag(wf_id, output_dir, no_dag_dir):
"""Export the DAG of the workflow."""
wfi = get_workflow_interface(wf_id)
wfi.export_graphml()
update_graphml(wf_id)
generate_viz(wf_id, output_dir)
generate_viz(wf_id, output_dir, no_dag_dir)


def start_workflow(wf_id):
Expand Down

0 comments on commit e72e1be

Please sign in to comment.