Skip to content

Commit

Permalink
Merge pull request #358 from tmaeno/master
Browse files Browse the repository at this point in the history
added a util function to get resource type for a job w/o hitting the database
  • Loading branch information
tmaeno committed May 21, 2024
2 parents 79a9ce6 + 7b8f1ad commit 115973a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PandaPkgInfo.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = "0.3.5"
release_version = "0.3.6"
14 changes: 14 additions & 0 deletions pandaserver/taskbuffer/JobUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 3 additions & 8 deletions pandaserver/taskbuffer/OraDBProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 115973a

Please sign in to comment.