diff --git a/beeflow/client/bee_client.py b/beeflow/client/bee_client.py index ed61ec27..7b435d58 100644 --- a/beeflow/client/bee_client.py +++ b/beeflow/client/bee_client.py @@ -631,10 +631,6 @@ def dag(wf_id: str = typer.Argument(..., callback=match_short_id), 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.""" - # Check if the workflow is archived - wf_status = get_wf_status(wf_id) - if wf_status == 'Archived': - error_exit('Workflow has been archived. Check the workflow archive for the final DAG.') output_dir = output_dir.resolve() # Make sure output_dir is an absolute path and exists output_dir = os.path.expanduser(output_dir) @@ -644,9 +640,19 @@ def dag(wf_id: str = typer.Argument(..., callback=match_short_id), # output_dir must be a string output_dir = str(output_dir) - wf_dir = wf_utils.get_workflow_dir(wf_id) - graphmls_dir = wf_dir + "/graphmls" - wf_utils.export_dag(wf_id, output_dir, wf_dir, no_dag_dir) + # Check if the workflow is archived + wf_status = get_wf_status(wf_id) + if wf_status == 'Archived': + bee_workdir = wf_utils.get_bee_workdir() + mount_dir = os.path.join(bee_workdir, 'gdb_mount') + graphmls_dir = mount_dir + '/graphmls' + typer.secho(f"Workflow has been archived. All new DAGs will look the same as the one in the archive directory.", + fg=typer.colors.MAGENTA) + else: + wf_dir = wf_utils.get_workflow_dir(wf_id) + graphmls_dir = wf_dir + '/graphmls' + os.makedirs(graphmls_dir, exist_ok=True) + wf_utils.export_dag(wf_id, output_dir, graphmls_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/wf_manager/resources/wf_update.py b/beeflow/wf_manager/resources/wf_update.py index 90f34962..47dbea2d 100644 --- a/beeflow/wf_manager/resources/wf_update.py +++ b/beeflow/wf_manager/resources/wf_update.py @@ -27,7 +27,9 @@ def archive_workflow(db, wf_id, final_state=None): shutil.copyfile(os.path.expanduser("~") + '/.config/beeflow/bee.conf', workflow_dir + '/' + 'bee.conf') # Archive Completed DAG - wf_utils.export_dag(wf_id, workflow_dir, workflow_dir, no_dag_dir=True) + graphmls_dir = workflow_dir + "/graphmls" + os.makedirs(graphmls_dir, exist_ok=True) + wf_utils.export_dag(wf_id, workflow_dir, graphmls_dir, no_dag_dir=True) wf_state = f'Archived/{final_state}' if final_state is not None else 'Archived' db.workflows.update_workflow_state(wf_id, wf_state) diff --git a/beeflow/wf_manager/resources/wf_utils.py b/beeflow/wf_manager/resources/wf_utils.py index 46411b56..4dde69b8 100644 --- a/beeflow/wf_manager/resources/wf_utils.py +++ b/beeflow/wf_manager/resources/wf_utils.py @@ -294,12 +294,10 @@ 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, wf_dir, no_dag_dir): +def export_dag(wf_id, output_dir, graphmls_dir, no_dag_dir): """Export the DAG of the workflow.""" wfi = get_workflow_interface(wf_id) wfi.export_graphml() - graphmls_dir = wf_dir + "/graphmls" - os.makedirs(graphmls_dir, exist_ok=True) update_graphml(wf_id, graphmls_dir) generate_viz(wf_id, output_dir, graphmls_dir, no_dag_dir)