diff --git a/src/jobflow_remote/cli/flow.py b/src/jobflow_remote/cli/flow.py index 43f000da..eedaf300 100644 --- a/src/jobflow_remote/cli/flow.py +++ b/src/jobflow_remote/cli/flow.py @@ -13,6 +13,7 @@ db_ids_opt, end_date_opt, flow_ids_opt, + flow_state_opt, force_opt, job_ids_opt, job_state_opt, @@ -42,7 +43,7 @@ def flows_list( job_id: job_ids_opt = None, db_id: db_ids_opt = None, flow_id: flow_ids_opt = None, - state: job_state_opt = None, + state: flow_state_opt = None, start_date: start_date_opt = None, end_date: end_date_opt = None, days: days_opt = None, @@ -93,7 +94,7 @@ def delete( job_id: job_ids_opt = None, db_id: db_ids_opt = None, flow_id: flow_ids_opt = None, - state: job_state_opt = None, + state: flow_state_opt = None, start_date: start_date_opt = None, end_date: end_date_opt = None, days: days_opt = None, diff --git a/src/jobflow_remote/cli/types.py b/src/jobflow_remote/cli/types.py index 291121cd..5dc6ec19 100644 --- a/src/jobflow_remote/cli/types.py +++ b/src/jobflow_remote/cli/types.py @@ -8,7 +8,7 @@ from jobflow_remote.cli.utils import SerializeFileFormat, SortOption from jobflow_remote.config.base import LogLevel -from jobflow_remote.jobs.state import JobState, RemoteState +from jobflow_remote.jobs.state import FlowState, JobState, RemoteState job_ids_indexes_opt = Annotated[ Optional[List[str]], @@ -63,6 +63,16 @@ ] +flow_state_opt = Annotated[ + Optional[FlowState], + typer.Option( + "--state", + "-s", + help="One of the Flow states", + ), +] + + remote_state_opt = Annotated[ Optional[RemoteState], typer.Option( diff --git a/src/jobflow_remote/jobs/jobcontroller.py b/src/jobflow_remote/jobs/jobcontroller.py index a36a1cff..1fca2c36 100644 --- a/src/jobflow_remote/jobs/jobcontroller.py +++ b/src/jobflow_remote/jobs/jobcontroller.py @@ -147,7 +147,7 @@ def _build_query_wf( not_in_states = list(Firework.STATE_RANKS.keys()) not_in_states.remove("WAITING") query["fws.state"] = {"$nin": not_in_states} - if state == FlowState.PAUSED: + elif state == FlowState.PAUSED: not_in_states = list(Firework.STATE_RANKS.keys()) not_in_states.remove("PAUSED") query["fws.state"] = {"$nin": not_in_states} @@ -170,6 +170,8 @@ def _build_query_wf( } }, ] + else: + raise RuntimeError("Unknown flow state.") # at variance with Firework doc, the dates in the Workflow are Date objects if start_date: