ATLAS Offline Software
Loading...
Searching...
No Matches
python.AODFixHelper Namespace Reference

Functions

 releaseInRange (flags, rel1, rel2, inputRelease=None)

Function Documentation

◆ releaseInRange()

python.AODFixHelper.releaseInRange ( flags,
rel1,
rel2,
inputRelease = None )

Definition at line 9 of file AODFixHelper.py.

9def releaseInRange(flags,rel1,rel2,inputRelease=None):
10 msg=logging.getLogger("releaseInRange")
11
12 #This regex matches 3 and 4 digit release numbers
13 #It also matches only something that start with Athena-xx
14 relPattern=re.compile(r"^Athena-(\d+(\.\d+){2,3}(\.\*)?)$")
15
16 for r in (rel1,rel2):
17 if not relPattern.match(r):
18 raise RuntimeError("Release number %s doesn't match the expected format"%r)
19
20 if inputRelease is None:
21 inputRelease=flags.Input.Release
22
23 # protection against AOD with very old releases or not read correctly by MetaReader.py
24 if inputRelease == "" or not inputRelease.startswith("Athena-"):
25 msg.debug("flags.Input.Release is read as empty or it does not start with 'Athena-'")
26 return False
27
28 if not relPattern.match(inputRelease):
29 raise RuntimeError("Input release number %s doesn't match the expected format"%inputRelease)
30
31 # convert 3 digits releases to 4 digits
32 if rel1.count(".") == 2: rel1=f"{rel1}.0"
33 if rel2.count(".") == 2: rel2=f"{rel2}.0"
34 if inputRelease.count(".") == 2: inputRelease=f"{inputRelease}.0"
35
36 #By Atlas convention, the first number denotes the major release, the second one the purpose (Tier0, Generation, ... )
37 #the third one is the running version number, the fourth one the patch number
38 #We request that the first two numbers are identical and the (third*10000 + forth) ones are in range
39
40 def identifyMajorAndMinorRel(rel):
41 idx = rel.rfind(".", 0, rel.rfind("."))
42 return rel[:idx]
43
44 def mangleRunningAndPatch(rel):
45 rel_split = rel.split(".")
46 return int(rel_split[2])*10000 + int(rel_split[3]) # running*10000 should be safely high enough
47
48 if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(rel2):
49 raise RuntimeError("Boundary releases not from the same release series, got %s and %s"%(rel1,rel2))
50
51 if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(inputRelease):
52 msg.info("Input release %s not from the same release series %s.", inputRelease, rel1)
53 return False
54
55 #convert number to int for comparison
56 lower=mangleRunningAndPatch(rel1)
57 upper=mangleRunningAndPatch(rel2)
58 current=mangleRunningAndPatch(inputRelease)
59
60 if (lower > upper):
61 raise RuntimeError("Lower boundary releases %s larger then upper boundary release %s" % (rel1,rel2))
62
63 if (current >= lower and current <= upper):
64 return True
65 else:
66 return False