Skip to content

Commit

Permalink
improve CLI, include allow_external_references
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetretto committed Aug 14, 2023
1 parent 593224a commit 808ca4a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/jobflow_remote/cli/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion src/jobflow_remote/fireworks/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
11 changes: 10 additions & 1 deletion src/jobflow_remote/jobs/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()

Expand All @@ -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()
Expand Down

0 comments on commit 808ca4a

Please sign in to comment.