From 3d92527cf74b0b61ce6a0ee13cbbceaadaea8875 Mon Sep 17 00:00:00 2001 From: tmaeno Date: Thu, 16 May 2024 14:50:16 +0200 Subject: [PATCH 1/2] added a util function to get resource type for a job w/o hitting the database --- pandaserver/taskbuffer/JobUtils.py | 14 ++++++++++++++ pandaserver/taskbuffer/OraDBProxy.py | 11 +++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pandaserver/taskbuffer/JobUtils.py b/pandaserver/taskbuffer/JobUtils.py index 9d8080f42..e18e9ca31 100644 --- a/pandaserver/taskbuffer/JobUtils.py +++ b/pandaserver/taskbuffer/JobUtils.py @@ -198,3 +198,17 @@ def load_jobs_json(state): job_spec.load_from_json_serializable(job_state) jobs.append(job_spec) return jobs + + +# get resource type for a job +def get_resource_type_job(resource_map: list, job_spec: JobSpec) -> str: + """ + Get the resource type for a job based on the job's resource type and the list of resource types. + :param resource_map: The list of resource types. + :param job_spec: The job. + :return: The resource type. + """ + for resource_spec in resource_map: + if resource_spec.match_job(job_spec): + return resource_spec.resource_name + return "Undefined" diff --git a/pandaserver/taskbuffer/OraDBProxy.py b/pandaserver/taskbuffer/OraDBProxy.py index 454a293a7..d9f68a2d0 100644 --- a/pandaserver/taskbuffer/OraDBProxy.py +++ b/pandaserver/taskbuffer/OraDBProxy.py @@ -22829,14 +22829,9 @@ def get_resource_type_job(self, job_spec): type(job_spec.coreCount), ) ) - - for resource_spec in resource_map: - if resource_spec.match_job(job_spec): - tmp_log.debug(f"done. resource_type is {resource_spec.resource_name}") - return resource_spec.resource_name - - tmp_log.debug("done. resource_type is Undefined") - return "Undefined" + resource_type = JobUtils.get_resource_type_job(resource_map, job_spec) + tmp_log.debug(f"done. resource_type is {resource_type}") + return resource_type # update stat of workers def reportWorkerStats(self, harvesterID, siteName, paramsList): From 7b8f1adef83893a00be9ef12e812a559d260f371 Mon Sep 17 00:00:00 2001 From: tmaeno Date: Tue, 21 May 2024 09:17:09 +0200 Subject: [PATCH 2/2] added a util function to get resource type for a job w/o hitting the database --- PandaPkgInfo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PandaPkgInfo.py b/PandaPkgInfo.py index b5531e600..ed30d8edb 100644 --- a/PandaPkgInfo.py +++ b/PandaPkgInfo.py @@ -1 +1 @@ -release_version = "0.3.5" +release_version = "0.3.6"