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

Classes

class  Test

Functions

 getLastGlobalTag (prevFlags)
 getDatabaseInstanceDefault (flags)
 getCrestServer ()
 getCrestAPI ()
 getCrestConnection (server=None, api=None)

Variables

 log = logging.getLogger('IOVDbAutoCfgFlags')

Function Documentation

◆ getCrestAPI()

getCrestAPI ( )
Return default Crest API version

Definition at line 64 of file IOVDbAutoCfgFlags.py.

64def getCrestAPI():
65 """Return default Crest API version"""
66 return "api-v6.0"
67
68

◆ getCrestConnection()

getCrestConnection ( server = None,
api = None )
Build connection string for Crest server based on server name and api.
If server is a valid file name, return that instead.

Definition at line 69 of file IOVDbAutoCfgFlags.py.

69def getCrestConnection(server=None, api=None):
70 """Build connection string for Crest server based on server name and api.
71 If server is a valid file name, return that instead."""
72
73 from urllib.parse import urljoin, urlsplit
74
75 # Split URL assuming default protocol
76 url = urlsplit(server or getCrestServer(), scheme='https')
77
78 # Valid URL with server name
79 if url.netloc:
80 return urljoin(url.geturl(), api or getCrestAPI())
81
82 # Or check if there is a local file
83 if os.access(url.path, os.F_OK):
84 return url.path
85
86 raise RuntimeError(f"Invalid URL or non-existent file: {server}")
87
88
89#
90# Unit tests:
91#

◆ getCrestServer()

getCrestServer ( )
Return default Crest server URL (can be set via ${CREST_SERVER})

Definition at line 49 of file IOVDbAutoCfgFlags.py.

49def getCrestServer():
50 """Return default Crest server URL (can be set via ${CREST_SERVER})"""
51 from urllib.parse import urlsplit
52
53 url = os.getenv("CREST_SERVER", "").strip()
54 if not url:
55 return "https://crest.cern.ch"
56
57 # Ensure we have a protocol, default to https
58 if not urlsplit(url).scheme:
59 url = "https://" + url.lstrip("/")
60
61 return url
62
63

◆ getDatabaseInstanceDefault()

getDatabaseInstanceDefault ( flags)

Definition at line 31 of file IOVDbAutoCfgFlags.py.

31def getDatabaseInstanceDefault(flags):
32 # MC
33 if flags.Input.isMC:
34 return "OFLP200"
35
36 # real-data
37 try:
38 year = int(flags.Input.ProjectName[4:6])
39 except Exception:
40 log.warning("Failed to extract year from project tag %s. Assuming CONDBR2.", flags.Input.ProjectName)
41 return "CONDBR2"
42
43 if year > 13:
44 return "CONDBR2"
45 else:
46 return "COMP200"
47
48

◆ getLastGlobalTag()

getLastGlobalTag ( prevFlags)

Definition at line 8 of file IOVDbAutoCfgFlags.py.

8def getLastGlobalTag(prevFlags):
9 if not prevFlags.Input.Files:
10 return ""
11
12 from AthenaConfiguration.AutoConfigFlags import GetFileMD
13 globaltag = GetFileMD(prevFlags.Input.Files).get("IOVDbGlobalTag", None)
14 if globaltag is None:
15 return ""
16
17 if isinstance(globaltag, list): # if different tags have been used at different steps
18 globaltag = globaltag[-1]
19
20
21 #With the migration to crest, the global tag name also changed,
22 #even for tags that are straight copies from COOL. Adjust global
23 #tag names read from input metadata
24 if prevFlags.IOVDb.UseCREST and globaltag in ("OFLCOND-MC21-SDR-RUN4-05",
25 "OFLCOND-MC21-SDR-RUN4-06"):
26 globaltag=globaltag[3:]
27
28 return globaltag
29
30
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132

Variable Documentation

◆ log

python.IOVDbAutoCfgFlags.log = logging.getLogger('IOVDbAutoCfgFlags')

Definition at line 6 of file IOVDbAutoCfgFlags.py.