Skip to content

Commit 7edd685

Browse files
committed
fix: use MaxRAM instead of RAM for consistency
1 parent d179cbd commit 7edd685

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/DIRAC/WorkloadManagementSystem/Client/Matcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def selectJob(self, resourceDescription, credDict):
7373

7474
# Make a nice print of the resource matching parameters
7575
toPrintDict = dict(resourceDict)
76-
if "RAM" in resourceDict:
77-
toPrintDict["RAM"] = resourceDict["RAM"]
76+
if "MaxRAM" in resourceDict:
77+
toPrintDict["MaxRAM"] = resourceDict["MaxRAM"]
7878
if "NumberOfProcessors" in resourceDescription:
7979
toPrintDict["NumberOfProcessors"] = resourceDescription["NumberOfProcessors"]
8080
toPrintDict["Tag"] = []
@@ -171,7 +171,7 @@ def _processResourceDescription(self, resourceDescription):
171171
"""
172172

173173
resourceDict = {}
174-
for name in singleValueDefFields + multiValueMatchFields + ["RAM"]:
174+
for name in singleValueDefFields + multiValueMatchFields + ["MaxRAM"]:
175175
if name in resourceDescription:
176176
resourceDict[name] = resourceDescription[name]
177177

src/DIRAC/WorkloadManagementSystem/DB/TaskQueueDB.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ def travelAndCheckType(value, validTypes, escapeValues=True):
277277
tqMatchDict[field] = result["Value"]
278278

279279
# Check range value fields (RAM requirements for matching)
280-
if "RAM" in tqMatchDict:
281-
result = travelAndCheckType(tqMatchDict["RAM"], int, escapeValues=False)
280+
if "MaxRAM" in tqMatchDict:
281+
result = travelAndCheckType(tqMatchDict["MaxRAM"], int, escapeValues=False)
282282
if not result["OK"]:
283283
return S_ERROR(f"Match definition field RAM failed : {result['Message']}")
284-
tqMatchDict["RAM"] = result["Value"]
284+
tqMatchDict["MaxRAM"] = result["Value"]
285285

286286
return S_OK(tqMatchDict)
287287

@@ -796,8 +796,8 @@ def __generateTQMatchSQL(self, tqMatchDict, numQueuesToGet=1, negativeCond=None)
796796
sqlCondList.append(self.__generateSQLSubCond("tq.%s <= %%s" % "CPUTime", tqMatchDict["CPUTime"]))
797797

798798
# RAM matching logic
799-
if "RAM" in tqMatchDict:
800-
ram = tqMatchDict["RAM"]
799+
if "MaxRAM" in tqMatchDict:
800+
ram = tqMatchDict["MaxRAM"]
801801
# Join with tq_RAM_requirements table
802802
sqlTables["tq_RAM_requirements"] = "ram_req"
803803
# Match if:
@@ -937,7 +937,7 @@ def __generateTQMatchSQL(self, tqMatchDict, numQueuesToGet=1, negativeCond=None)
937937
if "tq_RAM_requirements" in sqlTables:
938938
fromClause += " LEFT JOIN `tq_RAM_requirements` ram_req ON tq.TQId = ram_req.TQId"
939939

940-
tqSqlCmd = "SELECT tq.TQId, tq.Owner, tq.OwnerGroup FROM %s WHERE %s" % (fromClause, " AND ".join(sqlCondList))
940+
tqSqlCmd = f"SELECT tq.TQId, tq.Owner, tq.OwnerGroup FROM {fromClause} WHERE {' AND '.join(sqlCondList)}"
941941

942942
# Apply priorities
943943
tqSqlCmd = f"{tqSqlCmd} ORDER BY RAND() / tq.Priority ASC"

tests/Integration/WorkloadManagementSystem/Test_TaskQueueDB.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,36 +1167,36 @@ def test_chainWithRAM():
11671167
# Remember: Matching is based on MinRAM only (resource_RAM >= MinRAM)
11681168

11691169
# Resource with 1536 MB RAM (1.5 GB)
1170-
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "RAM": 1536}, numQueuesToGet=5)
1170+
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "MaxRAM": 1536}, numQueuesToGet=5)
11711171
assert result["OK"]
11721172
res = {int(x[0]) for x in result["Value"]}
11731173
# Should match: tq_job3 (no requirement), tq_job4 (MinRAM=1024, 1536 >= 1024)
11741174
assert res == {tq_job3, tq_job4}
11751175

11761176
# Resource with 3072 MB RAM (3 GB)
1177-
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "RAM": 3072}, numQueuesToGet=5)
1177+
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "MaxRAM": 3072}, numQueuesToGet=5)
11781178
assert result["OK"]
11791179
res = {int(x[0]) for x in result["Value"]}
11801180
# Should match: tq_job1 (MinRAM=2048), tq_job3 (no requirement), tq_job4 (MinRAM=1024)
11811181
# tq_job2 has MinRAM=4096, so 3072 is not enough
11821182
assert res == {tq_job1, tq_job3, tq_job4}
11831183

11841184
# Resource with 6144 MB RAM (6 GB)
1185-
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "RAM": 6144}, numQueuesToGet=5)
1185+
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "MaxRAM": 6144}, numQueuesToGet=5)
11861186
assert result["OK"]
11871187
res = {int(x[0]) for x in result["Value"]}
11881188
# Should match: all jobs (6144 >= all MinRAM values: 2048, 4096, 0, 1024)
11891189
assert res == {tq_job1, tq_job2, tq_job3, tq_job4}
11901190

11911191
# Resource with 10240 MB RAM (10 GB)
1192-
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "RAM": 10240}, numQueuesToGet=5)
1192+
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "MaxRAM": 10240}, numQueuesToGet=5)
11931193
assert result["OK"]
11941194
res = {int(x[0]) for x in result["Value"]}
11951195
# Should match: all jobs (10GB is enough for all MinRAM requirements)
11961196
assert res == {tq_job1, tq_job2, tq_job3, tq_job4}
11971197

11981198
# Resource with 512 MB RAM
1199-
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "RAM": 512}, numQueuesToGet=5)
1199+
result = tqDB.matchAndGetTaskQueue({"CPUTime": 50000, "MaxRAM": 512}, numQueuesToGet=5)
12001200
assert result["OK"]
12011201
res = {int(x[0]) for x in result["Value"]}
12021202
# Should only match: tq_job3 (no requirement) - 512MB is below all other MinRAM values

0 commit comments

Comments
 (0)