diff --git a/beeflow/client/bee_client.py b/beeflow/client/bee_client.py index 7cfd7d08..258491c7 100644 --- a/beeflow/client/bee_client.py +++ b/beeflow/client/bee_client.py @@ -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() @@ -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) diff --git a/beeflow/common/gdb/generate_graph.py b/beeflow/common/gdb/generate_graph.py index 2b421aa3..75e87a4a 100644 --- a/beeflow/common/gdb/generate_graph.py +++ b/beeflow/common/gdb/generate_graph.py @@ -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): diff --git a/beeflow/wf_manager/resources/wf_update.py b/beeflow/wf_manager/resources/wf_update.py index 335057cf..4772655e 100644 --- a/beeflow/wf_manager/resources/wf_update.py +++ b/beeflow/wf_manager/resources/wf_update.py @@ -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: diff --git a/beeflow/wf_manager/resources/wf_utils.py b/beeflow/wf_manager/resources/wf_utils.py index a654789b..e75211c5 100644 --- a/beeflow/wf_manager/resources/wf_utils.py +++ b/beeflow/wf_manager/resources/wf_utils.py @@ -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):