def test_submitJobWrapper(): with open("testJob.py", "w") as execFile: execFile.write(jobScript % "2") os.chmod("testJob.py", 0o755) jobParams = {"JobType": "User", "Executable": "testJob.py"} resourceParams = {"GridCE": "some_CE"} optimizerParams = {} wrapperFile = createJobWrapper( 2, jobParams, resourceParams, optimizerParams, logLevel="DEBUG")[ "Value"] # This is not under test, assuming it works fine shutil.copy(fj, os.curdir) ce = SingularityComputingElement("SingularityComputingElement") res = ce.submitJob( wrapperFile, proxy=None, numberOfProcessors=4, maxNumberOfProcessors=8, wholeNode=False, mpTag=True, jobDesc={ "jobParams": jobParams, "resourceParams": resourceParams, "optimizerParams": optimizerParams }, ) assert res["OK"] is False # This is False because the image can't be found assert res["ReschedulePayload"] is True res = ce.getCEStatus() assert res["OK"] is True if six.PY2: assert res["SubmittedJobs"] == 0 else: assert res["SubmittedJobs"] == 1 _stopJob(2) for ff in [ "testJob.py", "stop_job_2", "job.info", "std.out", "pilot.json" ]: if os.path.isfile(ff): os.remove(ff) if os.path.isdir("job"): shutil.rmtree("job")
def test_submitJob(): shutil.copy(fj, os.curdir) with open('testJob.py', 'w') as execFile: execFile.write(jobScript % '1') os.chmod('testJob.py', 0o755) ce = SingularityComputingElement('SingularityComputingElement') res = ce.submitJob('testJob.py', None) assert res['OK'] is False assert res['ReschedulePayload'] is True res = ce.getCEStatus() assert res['OK'] is True assert res['SubmittedJobs'] == 1 _stopJob(1) for ff in ['testJob.py', 'pilot.json']: if os.path.isfile(ff): os.remove(ff)
def test_submitJob(): shutil.copy(fj, os.curdir) shutil.copyfile(fc, os.path.join(os.curdir, "pilot.cfg")) with open("testJob.py", "w") as execFile: execFile.write(jobScript % "1") os.chmod("testJob.py", 0o755) ce = SingularityComputingElement("SingularityComputingElement") res = ce.submitJob("testJob.py", None) assert res["OK"] is False assert res["ReschedulePayload"] is True res = ce.getCEStatus() assert res["OK"] is True assert res["SubmittedJobs"] == 1 _stopJob(1) for ff in ["testJob.py", "pilot.json"]: if os.path.isfile(ff): os.remove(ff)
def test_submitJobWrapper(): with open('testJob.py', 'w') as execFile: execFile.write(jobScript % '2') os.chmod('testJob.py', 0o755) jobParams = {'JobType': 'User', 'Executable': 'testJob.py'} resourceParams = {'GridCE': 'some_CE'} optimizerParams = {} wrapperFile = createJobWrapper(2, jobParams, resourceParams, optimizerParams, logLevel='DEBUG')['Value'] # This is not under test, assuming it works fine shutil.copy(fj, os.curdir) ce = SingularityComputingElement('SingularityComputingElement') res = ce.submitJob(wrapperFile, proxy=None, numberOfProcessors=4, maxNumberOfProcessors=8, wholeNode=False, mpTag=True, jobDesc={"jobParams": jobParams, "resourceParams": resourceParams, "optimizerParams": optimizerParams}) assert res['OK'] is False # This is False because the image can't be found assert res['ReschedulePayload'] is True res = ce.getCEStatus() assert res['OK'] is True assert res['SubmittedJobs'] == 1 _stopJob(2) for ff in ['testJob.py', 'stop_job_2', 'job.info', 'std.out', 'pilot.json']: if os.path.isfile(ff): os.remove(ff) if os.path.isdir('job'): shutil.rmtree('job')
def executeJob(executableFile, proxy, taskID, inputs, **kwargs): """wrapper around ce.submitJob: decides which CE to use (Sudo or InProcess or Singularity) :param str executableFile: location of the executable file :param str proxy: proxy file location to be used for job submission :param int taskID: local task ID of the PoolCE :return: the result of the job submission (S_OK/S_ERROR) """ innerCESubmissionType = kwargs.pop("InnerCESubmissionType") if innerCESubmissionType == "Sudo": ce = SudoComputingElement("Task-" + str(taskID)) payloadUser = kwargs.get("PayloadUser") if payloadUser: ce.setParameters({"PayloadUser": payloadUser}) elif innerCESubmissionType == "Singularity": ce = SingularityComputingElement("Task-" + str(taskID)) else: ce = InProcessComputingElement("Task-" + str(taskID)) return ce.submitJob(executableFile, proxy, inputs=inputs)