From 9c4e66ea093070e51b4326238485091461bd8edf Mon Sep 17 00:00:00 2001 From: aldbr Date: Fri, 19 Jun 2026 17:24:28 +0200 Subject: [PATCH] fix: remove HTCondorResourceUsage module --- .../TimeLeft/HTCondorResourceUsage.py | 54 ------------------- .../test/Test_HTCondorResourceUsage.py | 38 ------------- 2 files changed, 92 deletions(-) delete mode 100644 src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/HTCondorResourceUsage.py delete mode 100644 src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/test/Test_HTCondorResourceUsage.py diff --git a/src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/HTCondorResourceUsage.py b/src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/HTCondorResourceUsage.py deleted file mode 100644 index fc83c1f4b8f..00000000000 --- a/src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/HTCondorResourceUsage.py +++ /dev/null @@ -1,54 +0,0 @@ -""" The HTCondor TimeLeft utility interrogates the HTCondor batch system for the - current CPU consumed, as well as its limit. -""" -import os - -from DIRAC import S_OK, S_ERROR -from DIRAC.Resources.Computing.BatchSystems.TimeLeft.TimeLeft import runCommand -from DIRAC.Resources.Computing.BatchSystems.TimeLeft.ResourceUsage import ResourceUsage - - -class HTCondorResourceUsage(ResourceUsage): - """ - This is the HTCondor plugin of the TimeLeft Utility. - HTCondor does not provide any way to get the wallclock/cpu limit, the batch system just provides fair-sharing to - users and groups: the limit depends on many parameters. - However, some Sites have introduced a MaxRuntime variable that sets a wallclock time limit to the allocations and - allow us to get an estimation of the resources usage. - """ - - def __init__(self, jobID, parameters): - """Standard constructor""" - super().__init__("HTCondor", jobID, parameters) - - def getResourceUsage(self): - """Returns S_OK with a dictionary containing the entries WallClock, WallClockLimit, and Unit for current slot.""" - # $_CONDOR_JOB_AD corresponds to the path to the .job.ad file - # It contains info about the job: - # - MaxRuntime: wallclock time allocated to the job - not officially supported by HTCondor, - # only present on some Sites - # - CurrentTime: current time - # - JobCurrentStartDate: start of the job execution - cmd = f"condor_status -ads {self.info_path} -af MaxRuntime CurrentTime-JobCurrentStartDate" - result = runCommand(cmd) - if not result["OK"]: - return S_ERROR("Current batch system is not supported") - - output = str(result["Value"]).split(" ") - if len(output) != 2: - self.log.warn("Cannot open $_CONDOR_JOB_AD: output probably empty") - return S_ERROR("Current batch system is not supported") - - wallClockLimit = output[0] - wallClock = output[1] - if wallClockLimit == "undefined": - self.log.warn("MaxRuntime attribute is not supported") - return S_ERROR("Current batch system is not supported") - - wallClockLimit = float(wallClockLimit) - wallClock = float(wallClock) - - consumed = {"WallClock": wallClock, "WallClockLimit": wallClockLimit, "Unit": "WallClock"} - - self.log.debug("TimeLeft counters complete:", str(consumed)) - return S_OK(consumed) diff --git a/src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/test/Test_HTCondorResourceUsage.py b/src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/test/Test_HTCondorResourceUsage.py deleted file mode 100644 index f481b487857..00000000000 --- a/src/DIRAC/Resources/Computing/BatchSystems/TimeLeft/test/Test_HTCondorResourceUsage.py +++ /dev/null @@ -1,38 +0,0 @@ -""" Test class for SGEResourceUsage utility -""" - -import pytest - -from DIRAC import S_OK -from DIRAC.Resources.Computing.BatchSystems.TimeLeft.HTCondorResourceUsage import HTCondorResourceUsage - - -HTCONDOR_OUT_0 = "86400 3600" -HTCONDOR_OUT_1 = "undefined 3600" -HTCONDOR_OUT_2 = "" - - -def test_getResourceUsage(mocker): - mocker.patch( - "DIRAC.Resources.Computing.BatchSystems.TimeLeft.HTCondorResourceUsage.runCommand", - side_effect=[S_OK(HTCONDOR_OUT_0), S_OK(HTCONDOR_OUT_1), S_OK(HTCONDOR_OUT_2)], - ) - - # First test: everything is fine - htcondorResourceUsage = HTCondorResourceUsage("1234", {"Queue": "Test", "InfoPath": "/path/to/condor_ad"}) - res = htcondorResourceUsage.getResourceUsage() - assert res["OK"], res["Message"] - assert res["Value"]["WallClock"] == 3600 - assert res["Value"]["WallClockLimit"] == 86400 - - # Second test: MaxRuntime is undefined - htcondorResourceUsage = HTCondorResourceUsage("1234", {"Queue": "Test", "InfoPath": "/path/to/condor_ad"}) - res = htcondorResourceUsage.getResourceUsage() - assert not res["OK"] - assert res["Message"] == "Current batch system is not supported" - - # Third test: empty output - htcondorResourceUsage = HTCondorResourceUsage("1234", {"Queue": "Test", "InfoPath": "/path/to/condor_ad"}) - res = htcondorResourceUsage.getResourceUsage() - assert not res["OK"] - assert res["Message"] == "Current batch system is not supported"