|
| 1 | +import copy |
| 2 | +import os |
| 3 | + |
| 4 | +def GenericV(config, validationDir): |
| 5 | + ##List with all jobs |
| 6 | + jobs = [] |
| 7 | + GenericVType = "single" |
| 8 | + |
| 9 | + ##List with all wished IOVs |
| 10 | + IOVs = [] |
| 11 | + |
| 12 | + ##Start with single GenericV jobs |
| 13 | + if not GenericVType in config["validations"]["Generic"]: |
| 14 | + raise Exception("No 'single' key word in config for GenericV") |
| 15 | + |
| 16 | + for singleName in config["validations"]["Generic"][GenericVType]: |
| 17 | + for IOV in config["validations"]["Generic"][GenericVType][singleName]["IOV"]: |
| 18 | + ##Save IOV to loop later for merge jobs |
| 19 | + if not IOV in IOVs: |
| 20 | + IOVs.append(IOV) |
| 21 | + |
| 22 | + for alignment in config["validations"]["Generic"][GenericVType][singleName]["alignments"]: |
| 23 | + ##Work directory for each IOV |
| 24 | + workDir = "{}/GenericV/{}/{}/{}/{}".format(validationDir, GenericVType, singleName, alignment, IOV) |
| 25 | + |
| 26 | + ##Write local config |
| 27 | + local = {} |
| 28 | + local["output"] = "{}/{}/GenericV/{}/{}/{}/{}".format(config["LFS"], config["name"], GenericVType, alignment, singleName, IOV) |
| 29 | + local["alignment"] = copy.deepcopy(config["alignments"][alignment]) |
| 30 | + local["validation"] = copy.deepcopy(config["validations"]["Generic"][GenericVType][singleName]) |
| 31 | + local["validation"].pop("alignments") |
| 32 | + local["validation"]["IOV"] = IOV |
| 33 | + if "dataset" in local["validation"]: |
| 34 | + local["validation"]["dataset"] = local["validation"]["dataset"].format(IOV) |
| 35 | + if "goodlumi" in local["validation"]: |
| 36 | + local["validation"]["goodlumi"] = local["validation"]["goodlumi"].format(IOV) |
| 37 | + |
| 38 | + ##Write job info |
| 39 | + job = { |
| 40 | + "name": "GenericV_{}_{}_{}_{}".format(GenericVType, alignment, singleName, IOV), |
| 41 | + "dir": workDir, |
| 42 | + "exe": "cmsRun", |
| 43 | + "cms-config": "{}/src/Alignment/OfflineValidation/python/TkAlAllInOneTool/GenericV_cfg.py".format(os.environ["CMSSW_BASE"]), |
| 44 | + "run-mode": "Condor", |
| 45 | + "dependencies": [], |
| 46 | + "config": local, |
| 47 | + } |
| 48 | + |
| 49 | + jobs.append(job) |
| 50 | + |
| 51 | + ##Do merge GenericV if wished |
| 52 | + if "merge" in config["validations"]["Generic"]: |
| 53 | + ##List with merge jobs, will be expanded to jobs after looping |
| 54 | + mergeJobs = [] |
| 55 | + GenericVType = "merge" |
| 56 | + |
| 57 | + ##Loop over all merge jobs/IOVs which are wished |
| 58 | + for mergeName in config["validations"]["Generic"][GenericVType]: |
| 59 | + for IOV in IOVs: |
| 60 | + ##Work directory for each IOV |
| 61 | + workDir = "{}/GenericV/{}/{}/{}".format(validationDir, GenericVType, mergeName, IOV) |
| 62 | + |
| 63 | + ##Write job info |
| 64 | + local = {} |
| 65 | + |
| 66 | + job = { |
| 67 | + "name": "GenericV_{}_{}_{}".format(GenericVType, mergeName, IOV), |
| 68 | + "dir": workDir, |
| 69 | + "exe": "GenericVmerge", |
| 70 | + "run-mode": "Condor", |
| 71 | + "dependencies": [], |
| 72 | + "config": local, |
| 73 | + } |
| 74 | + |
| 75 | + for alignment in config["alignments"]: |
| 76 | + ##Deep copy necessary things from global config |
| 77 | + local.setdefault("alignments", {}) |
| 78 | + if alignment in config["validations"]["Generic"]["single"][mergeName]["alignments"]: |
| 79 | + local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment]) |
| 80 | + local["validation"] = copy.deepcopy(config["validations"]["Generic"][GenericVType][mergeName]) |
| 81 | + local["output"] = "{}/{}/GenericV/{}/{}/{}".format(config["LFS"], config["name"], GenericVType, mergeName, IOV) |
| 82 | + |
| 83 | + ##Loop over all single jobs |
| 84 | + for singleJob in jobs: |
| 85 | + ##Get single job info and append to merge job if requirements fullfilled |
| 86 | + alignment, singleName, singleIOV = singleJob["name"].split("_")[2:] |
| 87 | + |
| 88 | + if int(singleIOV) == IOV and singleName in config["validations"]["Generic"][GenericVType][mergeName]["singles"]: |
| 89 | + local["alignments"][alignment]["file"] = singleJob["config"]["output"] |
| 90 | + job["dependencies"].append(singleJob["name"]) |
| 91 | + |
| 92 | + mergeJobs.append(job) |
| 93 | + |
| 94 | + jobs.extend(mergeJobs) |
| 95 | + |
| 96 | + return jobs |
0 commit comments