Skip to content

Commit

Permalink
edited bee_client and wf_update and wf_utils so now multiple versions…
Browse files Browse the repository at this point in the history
… of the completed dags can be made
  • Loading branch information
leahh committed Sep 30, 2024
1 parent 68fb161 commit 56181c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
20 changes: 13 additions & 7 deletions beeflow/client/bee_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion beeflow/wf_manager/resources/wf_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions beeflow/wf_manager/resources/wf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 56181c8

Please sign in to comment.