From 496e9b0326860823e3a257893d8719b1bcf32f0c Mon Sep 17 00:00:00 2001 From: Guido Petretto Date: Fri, 13 Sep 2024 14:49:11 +0200 Subject: [PATCH] fix build job query --- doc/source/user/tuning.rst | 7 ++++--- src/jobflow_remote/jobs/jobcontroller.py | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/source/user/tuning.rst b/doc/source/user/tuning.rst index 0e763e7d..f64a572d 100644 --- a/doc/source/user/tuning.rst +++ b/doc/source/user/tuning.rst @@ -173,6 +173,7 @@ to set the values of the resources and execution configurations. .. note:: - In order for this to be meaningful only Jobs that have not been started - can be modified. So this commands can be applied only to Jobs in the - ``READY`` or ``WAITING`` states. + In order for this to be meaningful only a subset of Jobs states are + acceptable. This commands can be applied only to Jobs in the + ``READY``, ``WAITING``, ``COMPLETED``, ``FAILED``, ``PAUSED`` and + ``REMOTE_ERROR`` states. diff --git a/src/jobflow_remote/jobs/jobcontroller.py b/src/jobflow_remote/jobs/jobcontroller.py index e76346d0..31852625 100644 --- a/src/jobflow_remote/jobs/jobcontroller.py +++ b/src/jobflow_remote/jobs/jobcontroller.py @@ -233,7 +233,7 @@ def _build_query_job( if isinstance(workers, str): workers = [workers] - query: dict = {} + query: dict = defaultdict(dict) if db_ids: query["db_id"] = {"$in": db_ids} @@ -255,7 +255,7 @@ def _build_query_job( query["updated_on"] = {"$gte": start_date_str} if end_date: end_date_str = end_date.astimezone(timezone.utc) - query["updated_on"] = {"$lte": end_date_str} + query["updated_on"]["$lte"] = end_date_str if locked: query["lock_id"] = {"$ne": None} @@ -269,7 +269,6 @@ def _build_query_job( if metadata: metadata_dict = {f"job.metadata.{k}": v for k, v in metadata.items()} query.update(metadata_dict) - print(query) if workers: query["worker"] = {"$in": workers}