Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Feb 8, 2024
1 parent 1720cea commit e92306b
Show file tree
Hide file tree
Showing 6 changed files with 555 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import hashlib
import sys
import json
import ast
import os

from DIRAC.WorkloadManagementSystem.JobWrapper.JobWrapperUtilities import getJobWrapper
Expand All @@ -40,14 +39,14 @@ def execute(jobID: str, arguments: dict, jobReport: JobReport):
if not payloadParams:
return 1

if not "PayloadResults" in arguments["Job"] or not "Checksum" in arguments["Job"]:
return 1

job = getJobWrapper(jobID, arguments, jobReport)
payloadResult = job.process(**payloadParams)
if not payloadResult["OK"]:
return 1

if not "PayloadResults" in arguments["Job"] or not "Checksum" in arguments["Job"]:
return 1

# Store the payload result
with open(arguments["Job"]["PayloadResults"], "w") as f:
json.dump(payloadResult, f)
Expand All @@ -58,7 +57,7 @@ def execute(jobID: str, arguments: dict, jobReport: JobReport):
if os.path.isfile(file):
hash_md5 = hashlib.md5()
with open(file, "rb") as f:
while chunk := f.read(128 * hash.block_size):
while chunk := f.read(128 * hash_md5.block_size):
hash_md5.update(chunk)
checksums[file] = hash_md5.hexdigest()

Expand All @@ -75,8 +74,7 @@ def execute(jobID: str, arguments: dict, jobReport: JobReport):
try:
jsonFileName = os.path.realpath(__file__) + ".json"
with open(jsonFileName) as f:
jobArgsFromJSON = json.loads(f.readlines()[0])
jobArgs = ast.literal_eval(jobArgsFromJSON)
jobArgs = json.load(f)
if not isinstance(jobArgs, dict):
raise TypeError(f"jobArgs is of type {type(jobArgs)}")
if "Job" not in jobArgs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"""
import sys
import json
import ast
import os

from DIRAC.WorkloadManagementSystem.JobWrapper.JobWrapperUtilities import (
Expand Down Expand Up @@ -92,8 +91,7 @@ def execute(jobID: str, arguments: dict, jobReport: JobReport):
try:
jsonFileName = os.path.realpath(__file__) + ".json"
with open(jsonFileName) as f:
jobArgsFromJSON = json.loads(f.readlines()[0])
jobArgs = ast.literal_eval(jobArgsFromJSON)
jobArgs = json.load(f)
if not isinstance(jobArgs, dict):
raise TypeError(f"jobArgs is of type {type(jobArgs)}")
if "Job" not in jobArgs:
Expand Down
6 changes: 3 additions & 3 deletions src/DIRAC/WorkloadManagementSystem/Utilities/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def createJobWrapper(

jobWrapperJsonFile = jobWrapperFile + ".json"
with open(jobWrapperJsonFile, "w", encoding="utf8") as jsonFile:
json.dump(str(arguments), jsonFile, ensure_ascii=False)
json.dump(arguments, jsonFile, ensure_ascii=False)

with open(jobWrapperFile, "w") as wrapper:
wrapper.write(wrapperTemplate)
Expand All @@ -93,7 +93,7 @@ def createJobWrapper(
""".format(
pythonPath,
jobWrapperDirect,
extraOptions,
extraOptions if extraOptions else "",
logLevel,
)
with open(jobExeFile, "w") as jobFile:
Expand All @@ -105,5 +105,5 @@ def createJobWrapper(
"JobWrapperPath": jobWrapperFile,
}
if rootLocation != wrapperPath:
generatedFiles["JobExecutableRelocatedPath"] = jobWrapperDirect
generatedFiles["JobExecutableRelocatedPath"] = os.path.join(rootLocation, os.path.basename(jobExeFile))
return S_OK(generatedFiles)
Loading

0 comments on commit e92306b

Please sign in to comment.