Skip to content

Commit 33d5439

Browse files
authored
Merge pull request #8200 from chrisburr/diracx-unit-tests
[9.0] Add DiracX Unit Tests CI and fix diracx installs
2 parents 640e764 + f891345 commit 33d5439

File tree

5 files changed

+88
-38
lines changed

5 files changed

+88
-38
lines changed

.github/workflows/basic.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,49 @@ jobs:
108108
tests/Integration/WorkloadManagementSystem/Test_GenerateAndExecutePilotWrapper.py \
109109
src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py \
110110
src/DIRAC/Resources/Computing/BatchSystems/*.py
111+
112+
diracx:
113+
name: DiracX Unit Tests
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Checkout DIRAC
117+
uses: actions/checkout@v4
118+
with:
119+
fetch-depth: 0
120+
path: DIRAC
121+
- name: Checkout DiracX
122+
uses: actions/checkout@v4
123+
with:
124+
fetch-depth: 0
125+
repository: DIRACGrid/diracx
126+
path: diracx
127+
- uses: prefix-dev/[email protected]
128+
with:
129+
run-install: false
130+
post-cleanup: false
131+
- name: Apply workarounds
132+
run: |
133+
cd diracx
134+
# Workaround for https://github.com/prefix-dev/pixi/issues/3762
135+
sed -i.bak 's@editable = true@editable = false@g' pixi.toml
136+
rm pixi.toml.bak
137+
# Add annotations to github actions
138+
pixi add --no-install --pypi --feature diracx-core pytest-github-actions-annotate-failures
139+
# Add the current DIRAC clone to the pixi.toml
140+
pixi add --no-install --pypi --feature diracx-core 'DIRAC @ file://'$PWD'/../DIRAC'
141+
# Show any changes
142+
git diff
143+
- uses: prefix-dev/[email protected]
144+
with:
145+
cache: false
146+
manifest-path: diracx/pixi.toml
147+
environments: >-
148+
diracx-core
149+
diracx-db
150+
diracx-logic
151+
diracx-routers
152+
diracx-client
153+
diracx-api
154+
diracx-cli
155+
- name: Run pytest
156+
run: cd diracx && pixi run pytest-diracx-all-one-by-one

src/DIRAC/WorkloadManagementSystem/Agent/StalledJobAgent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB
2626
from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB import PilotAgentsDB
2727
from DIRAC.WorkloadManagementSystem.Utilities.JobParameters import getJobParameters
28-
from DIRAC.WorkloadManagementSystem.Utilities.JobStatusUtility import rescheduleJobs
28+
from DIRAC.WorkloadManagementSystem.Utilities.Utils import rescheduleJobs
2929

3030

3131
class StalledJobAgent(AgentModule):

src/DIRAC/WorkloadManagementSystem/Service/JobManagerHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
)
3535
from DIRAC.WorkloadManagementSystem.Utilities.JobModel import JobDescriptionModel
3636
from DIRAC.WorkloadManagementSystem.Utilities.ParametricJob import generateParametricJobs, getParameterVectorLength
37-
from DIRAC.WorkloadManagementSystem.Utilities.JobStatusUtility import rescheduleJobs
37+
from DIRAC.WorkloadManagementSystem.Utilities.Utils import rescheduleJobs
3838

3939
MAX_PARAMETRIC_JOBS = 20
4040

src/DIRAC/WorkloadManagementSystem/Utilities/JobStatusUtility.py

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
from DIRAC.Core.Utilities import TimeUtilities
1010
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
1111
from DIRAC.WorkloadManagementSystem.Client import JobStatus
12-
from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB
13-
from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB
14-
from DIRAC.WorkloadManagementSystem.DB.TaskQueueDB import TaskQueueDB
12+
13+
if TYPE_CHECKING:
14+
from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB
15+
from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB
1516

1617

1718
class JobStatusUtility:
@@ -242,35 +243,3 @@ def getNewStatus(
242243
minor = sDict.get("MinorStatus", minor)
243244
application = sDict.get("ApplicationStatus", application)
244245
return S_OK((status, minor, application))
245-
246-
247-
def rescheduleJobs(jobIDs: list[int], source: str = "") -> dict:
248-
"""Utility to reschedule jobs (not atomic, nor bulk)
249-
Requires direct access to the JobDB and TaskQueueDB
250-
251-
:param jobIDs: list of jobIDs
252-
:param source: source of the reschedule
253-
:return: S_OK/S_ERROR
254-
:rtype: dict
255-
256-
"""
257-
258-
failedJobs = []
259-
260-
for jobID in jobIDs:
261-
result = JobDB().rescheduleJob(jobID)
262-
if not result["OK"]:
263-
failedJobs.append(jobID)
264-
continue
265-
TaskQueueDB().deleteJob(jobID)
266-
JobLoggingDB().addLoggingRecord(
267-
result["JobID"],
268-
status=result["Status"],
269-
minorStatus=result["MinorStatus"],
270-
applicationStatus="Unknown",
271-
source=source,
272-
)
273-
274-
if failedJobs:
275-
return S_ERROR(f"Failed to reschedule jobs {failedJobs}")
276-
return S_OK()

src/DIRAC/WorkloadManagementSystem/Utilities/Utils.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
import sys
55
import json
66

7-
from DIRAC import gLogger, S_OK
7+
from DIRAC import gLogger, S_OK, S_ERROR
88
from DIRAC.Core.Utilities.File import mkDir
99
from DIRAC.FrameworkSystem.private.standardLogging.Logging import Logging
10+
from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB
11+
from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB
12+
from DIRAC.WorkloadManagementSystem.DB.TaskQueueDB import TaskQueueDB
1013

1114

1215
def createJobWrapper(
@@ -113,3 +116,35 @@ def createJobWrapper(
113116
if rootLocation != wrapperPath:
114117
generatedFiles["JobExecutableRelocatedPath"] = os.path.join(rootLocation, os.path.basename(jobExeFile))
115118
return S_OK(generatedFiles)
119+
120+
121+
def rescheduleJobs(jobIDs: list[int], source: str = "") -> dict:
122+
"""Utility to reschedule jobs (not atomic, nor bulk)
123+
Requires direct access to the JobDB and TaskQueueDB
124+
125+
:param jobIDs: list of jobIDs
126+
:param source: source of the reschedule
127+
:return: S_OK/S_ERROR
128+
:rtype: dict
129+
130+
"""
131+
132+
failedJobs = []
133+
134+
for jobID in jobIDs:
135+
result = JobDB().rescheduleJob(jobID)
136+
if not result["OK"]:
137+
failedJobs.append(jobID)
138+
continue
139+
TaskQueueDB().deleteJob(jobID)
140+
JobLoggingDB().addLoggingRecord(
141+
result["JobID"],
142+
status=result["Status"],
143+
minorStatus=result["MinorStatus"],
144+
applicationStatus="Unknown",
145+
source=source,
146+
)
147+
148+
if failedJobs:
149+
return S_ERROR(f"Failed to reschedule jobs {failedJobs}")
150+
return S_OK()

0 commit comments

Comments
 (0)