From 3cd82566b69983b78c63856bf7fd0449e544f89b Mon Sep 17 00:00:00 2001 From: Andrei Tsaregorodtsev Date: Fri, 28 Aug 2026 15:01:00 +0200 Subject: [PATCH] fix: do not bootstrap the workflow before setting command line parameters --- .pre-commit-config.yaml | 1 + .../scripts/dirac_jobexec.py | 2 -- tests/System/test_wf_job.py | 29 +++++++++++++++++++ tests/System/wms_scripts.sh | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100755 tests/System/test_wf_job.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 35b9933df05..8576986bf16 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,6 +57,7 @@ repos: src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py| tests/Integration/WorkloadManagementSystem/Test_GenerateAndExecutePilotWrapper.py )$ + language_version: python3.11 - repo: https://github.com/asottile/pyupgrade rev: v3.3.1 diff --git a/src/DIRAC/WorkloadManagementSystem/scripts/dirac_jobexec.py b/src/DIRAC/WorkloadManagementSystem/scripts/dirac_jobexec.py index 84844a56c4a..476f8f5ea7b 100755 --- a/src/DIRAC/WorkloadManagementSystem/scripts/dirac_jobexec.py +++ b/src/DIRAC/WorkloadManagementSystem/scripts/dirac_jobexec.py @@ -40,8 +40,6 @@ def jobexec(jobxml, wfParameters): sys.exit(1) workflow = fromXMLFile(jobfile) gLogger.debug(workflow) - code = workflow.createCode() - gLogger.debug(code) jobID = 0 if "JOBID" in os.environ: jobID = os.environ["JOBID"] diff --git a/tests/System/test_wf_job.py b/tests/System/test_wf_job.py new file mode 100755 index 00000000000..f0eee801004 --- /dev/null +++ b/tests/System/test_wf_job.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# Test the possibility to use general workflow parameters as variables +# in the job description + +import subprocess +import shlex +import sys +from pathlib import Path +from DIRAC.Interfaces.API.Job import Job + +job = Job() + +job.setExecutable("/bin/ls") +job.setExecutable("/bin/echo", arguments="@{InputData}") + +file = Path("jobDescription.xml") +file.write_text(job.workflow.toXML()) + +status = subprocess.call(shlex.split("dirac-jobexec jobDescription.xml -p InputData='{input_file_1,input_file_2}'")) +if status: + sys.exit(status) + +file = Path("Script2_echo.log") +content = file.read_text() +if not "input_file_1;input_file_2" in content: + print("Test failed !") + sys.exit(-1) + +print("Test successful !") diff --git a/tests/System/wms_scripts.sh b/tests/System/wms_scripts.sh index 0a60f8fc74e..022b3e4724e 100755 --- a/tests/System/wms_scripts.sh +++ b/tests/System/wms_scripts.sh @@ -13,6 +13,7 @@ declare -a commands=( 'dirac-wms-get-wn-parameters --Site=LCG.CERN.cern --Name=ce503.cern.ch --Queue=condor' 'dirac-admin-site-info LCG.CERN.cern' 'dirac-wms-select-jobs --Status=Running' +'test_wf_job.py' ) echo " "