From 808ca4a6ff9dae2c8d7d0840458ac4d2dae6f8c2 Mon Sep 17 00:00:00 2001 From: Guido Petretto Date: Mon, 14 Aug 2023 12:34:23 +0200 Subject: [PATCH] improve CLI, include allow_external_references --- src/jobflow_remote/cli/admin.py | 15 ++++++++++++--- src/jobflow_remote/fireworks/convert.py | 6 +++++- src/jobflow_remote/jobs/submit.py | 11 ++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/jobflow_remote/cli/admin.py b/src/jobflow_remote/cli/admin.py index ac8fc790..0f716c81 100644 --- a/src/jobflow_remote/cli/admin.py +++ b/src/jobflow_remote/cli/admin.py @@ -46,7 +46,7 @@ def reset( "--max-limit", "-max", help=( - "The database will be reset only if the number of Jobs is lower than the specified limit. 0 means no limit" + "The database will be reset only if the number of Flows is lower than the specified limit. 0 means no limit" ), ), ] = 25, @@ -56,6 +56,8 @@ def reset( Reset the jobflow database. WARNING: deletes all the data. These could not be retrieved anymore. """ + from jobflow_remote import SETTINGS + dm = DaemonManager() try: @@ -78,7 +80,8 @@ def reset( cm = ConfigManager() project_name = cm.get_project_data().project.name text = Text.from_markup( - f"[red]This operation will [bold]delete all the Jobs data[/bold] for project [bold]{project_name}[/bold]. Proceed anyway?[/red]" + "[red]This operation will [bold]delete all the Jobs data[/bold] " + f"for project [bold]{project_name}[/bold]. Proceed anyway?[/red]" ) confirmed = Confirm.ask(text, default=False) @@ -88,7 +91,13 @@ def reset( progress.add_task(description="Resetting the DB...", total=None) jc = JobController() done = jc.reset(reset_output=reset_output, max_limit=max_limit) - out_console.print(f"The database was {'' if done else 'NOT '}reset") + not_text = "" if done else "[bold]NOT [/bold]" + out_console.print(f"The database was {not_text}reset") + if not done and SETTINGS.cli_suggestions: + out_console.print( + "Check the amount of Flows and change --max-limit if this is the correct project to reset", + style="yellow", + ) @app_admin.command() diff --git a/src/jobflow_remote/fireworks/convert.py b/src/jobflow_remote/fireworks/convert.py index eccc9474..527d97b4 100644 --- a/src/jobflow_remote/fireworks/convert.py +++ b/src/jobflow_remote/fireworks/convert.py @@ -23,6 +23,7 @@ def flow_to_workflow( exec_config: str | ExecutionConfig = None, resources: dict | QResources | None = None, metadata: dict | None = None, + allow_external_references: bool = False, **kwargs, ) -> Workflow: """ @@ -52,6 +53,9 @@ def flow_to_workflow( metadata: Dict metadata passed to the workflow. The flow uuid will be added with the key "flow_id". + allow_external_references + If False all the references to other outputs should be from other Jobs + of the Flow. **kwargs Keyword arguments passed to Workflow init method. @@ -69,7 +73,7 @@ def flow_to_workflow( if not worker: raise ConfigError("Worker name must be set.") - flow = get_flow(flow) + flow = get_flow(flow, allow_external_references=allow_external_references) for job, parents in flow.iterflow(): fw = job_to_firework( diff --git a/src/jobflow_remote/jobs/submit.py b/src/jobflow_remote/jobs/submit.py index dbfe6d9f..1efc8718 100644 --- a/src/jobflow_remote/jobs/submit.py +++ b/src/jobflow_remote/jobs/submit.py @@ -15,6 +15,7 @@ def submit_flow( project: str | None = None, exec_config: str | ExecutionConfig | None = None, resources: dict | QResources | None = None, + allow_external_references: bool = False, ): """ Submit a flow for calculation to the selected Worker. @@ -43,6 +44,9 @@ def submit_flow( resources: Dict or QResources information passed to qtoolkit to require the resources for the submission to the queue. + allow_external_references + If False all the references to other outputs should be from other Jobs + of the Flow. """ config_manager = ConfigManager() @@ -60,7 +64,12 @@ def submit_flow( ) wf = flow_to_workflow( - flow, worker=worker, store=store, exec_config=exec_config, resources=resources + flow, + worker=worker, + store=store, + exec_config=exec_config, + resources=resources, + allow_external_references=allow_external_references, ) rlpad = proj_obj.get_launchpad()