Belle II Software
release-08-01-10
|
Classes | |
class | RequestError |
Public Member Functions | |
def | __init__ (self, base_url=None, max_connections=10, retries=3) |
def | set_authentication_token (self, token) |
def | request (self, method, url, message=None, *args, **argk) |
def | get_globalTags (self) |
def | has_globalTag (self, name) |
def | get_globalTagInfo (self, name) |
def | get_globalTagType (self, name) |
def | create_globalTag (self, name, description, user) |
def | get_all_iovs (self, globalTag, exp=None, run=None, message=None, run_range=None, fully_contained=False) |
def | get_payloads (self, global_tag=None) |
def | check_payloads (self, payloads, information="payloadId") |
def | get_revisions (self, entries) |
def | create_payload (self, module, filename, checksum=None) |
def | create_iov (self, globalTagId, payloadId, firstExp, firstRun, finalExp, finalRun) |
def | delete_iov (self, iovId) |
def | modify_iov (self, iovId, firstExp, firstRun, finalExp, finalRun) |
def | get_iovs (self, globalTagName, payloadName=None) |
def | upload (self, filename, global_tag, normalize=False, ignore_existing=False, nprocess=1, uploaded_entries=None) |
def | staging_request (self, filename, normalize, data, password) |
Static Public Member Functions | |
def | get_base_urls (given_url) |
Static Public Attributes | |
list | BASE_URLS = [conditions.default_metadata_provider_url] |
base url to the conditions db to be used if no custom url is given | |
Private Attributes | |
_session | |
session object to get keep-alive support and connection pooling | |
_base_url | |
base url to be prepended to all requests | |
Class to interface conditions db REST interface
Definition at line 230 of file __init__.py.
def __init__ | ( | self, | |
base_url = None , |
|||
max_connections = 10 , |
|||
retries = 3 |
|||
) |
Create a new instance of the interface Args: base_url (string): base url of the rest interface max_connections (int): number of connections to keep open, mostly useful for threaded applications retries (int): number of retries in case of connection problems
Definition at line 272 of file __init__.py.
def check_payloads | ( | self, | |
payloads, | |||
information = "payloadId" |
|||
) |
Check for the existence of payloads in the database. Arguments: payloads (list((str,str))): A list of payloads to check for. Each payload needs to be a tuple of the name of the payload and the md5 checksum of the payload file. information (str): The information to be extracted from the payload dictionary Returns: A dictionary with the payload identifiers (name, checksum) as keys and the requested information as values for all payloads which are already present in the database.
Definition at line 539 of file __init__.py.
def create_globalTag | ( | self, | |
name, | |||
description, | |||
user | |||
) |
Create a new globaltag
Definition at line 441 of file __init__.py.
def create_iov | ( | self, | |
globalTagId, | |||
payloadId, | |||
firstExp, | |||
firstRun, | |||
finalExp, | |||
finalRun | |||
) |
Create an iov. Args: globalTagId (int): id of the globaltag, obtain with get_globalTagId() payloadId (int): id of the payload, obtain from create_payload() or get_payloads() firstExp (int): first experiment for which this iov is valid firstRun (int): first run for which this iov is valid finalExp (int): final experiment for which this iov is valid finalRun (int): final run for which this iov is valid Returns: payloadIovId of the created iov, None if creation was not successful
Definition at line 635 of file __init__.py.
def create_payload | ( | self, | |
module, | |||
filename, | |||
checksum = None |
|||
) |
Create a new payload Args: module (str): name of the module filename (str): name of the file checksum (str): md5 hexdigest of the file. Will be calculated automatically if not given
Definition at line 592 of file __init__.py.
def delete_iov | ( | self, | |
iovId | |||
) |
Delete an iov Args: iovId (int): id of the iov to be deleted
Definition at line 670 of file __init__.py.
def get_all_iovs | ( | self, | |
globalTag, | |||
exp = None , |
|||
run = None , |
|||
message = None , |
|||
run_range = None , |
|||
fully_contained = False |
|||
) |
Return list of all payloads in the given globaltag where each element is a `PayloadInformation` instance Parameters: gobalTag (str): name of the globaltag exp (int): if given limit the list of payloads to the ones valid for the given exp,run combination run (int): if given limit the list of payloads to the ones valid for the given exp,run combination message (str): additional message to show when downloading the payload information. Will be directly appended to "Obtaining lists of iovs for globaltag {globalTag}" run_range (tuple): if given limit the list of payloads to the ones overlapping with the given run range, if fully_contained (bool): if True and the run_range is not None it limits the list of payloads to the ones fully contained in the given run range Warning: Both, exp and run, need to be given at the same time. Just supplying an experiment or a run number will not work
Definition at line 454 of file __init__.py.
|
static |
Resolve the list of server urls. If a url is given just return it. Otherwise return servers listed in BELLE2_CONDB_SERVERLIST or the builtin defaults Arguments: given_url (str): Explicit base_url. If this is not None it will be returned as is in a list of length 1 Returns: a list of urls to try for database connectivity
Definition at line 241 of file __init__.py.
def get_globalTagInfo | ( | self, | |
name | |||
) |
Get the id of the globaltag with the given name. Returns either the id or None if the tag was not found
Definition at line 410 of file __init__.py.
def get_globalTags | ( | self | ) |
Get a list of all globaltags. Returns a dictionary with the globaltag names and the corresponding ids in the database
Definition at line 384 of file __init__.py.
def get_globalTagType | ( | self, | |
name | |||
) |
Get the dictionary describing the given globaltag type (currently one of DEV or RELEASE). Returns None if tag type was not found.
Definition at line 422 of file __init__.py.
def get_iovs | ( | self, | |
globalTagName, | |||
payloadName = None |
|||
) |
Return existing iovs for a given tag name. It returns a dictionary which maps (payloadId, first runId, final runId) to iovId Parameters: globalTagName(str): Global tag name. payloadName(str): Payload name (if None, selection by name is not performed.
Definition at line 697 of file __init__.py.
def get_payloads | ( | self, | |
global_tag = None |
|||
) |
Get a list of all defined payloads (for the given global_tag or by default for all). Returns a dictionary which maps (module, checksum) to the payload id.
Definition at line 515 of file __init__.py.
def get_revisions | ( | self, | |
entries | |||
) |
Get the revision numbers of payloads in the database. Arguments: entries (list): A list of payload entries. Each entry must have the attributes module and checksum. Returns: True if successful.
Definition at line 571 of file __init__.py.
def has_globalTag | ( | self, | |
name | |||
) |
Check whether the globaltag with the given name exists.
Definition at line 400 of file __init__.py.
def modify_iov | ( | self, | |
iovId, | |||
firstExp, | |||
firstRun, | |||
finalExp, | |||
finalRun | |||
) |
Modify the validity range of a given iov Args: iovId (int): id of the iov to be modified firstExp (int): first experiment for which this iov is valid firstRun (int): first run for which this iov is valid finalExp (int): final experiment for which this iov is valid finalRun (int): final run for which this iov is valid
Definition at line 681 of file __init__.py.
def request | ( | self, | |
method, | |||
url, | |||
message = None , |
|||
* | args, | ||
** | argk | ||
) |
Request function, similar to requests.request but adding the base_url Args: method (str): GET, POST, etc. url (str): url for the request, base_url will be prepended message (str): message to show when starting the request and if it fails All other arguments will be forwarded to requests.request.
Definition at line 329 of file __init__.py.
def set_authentication_token | ( | self, | |
token | |||
) |
Set authentication token when talking to the database Args: token (str): JWT to hand to the database. Will not be checked for validity here.
Definition at line 319 of file __init__.py.
def staging_request | ( | self, | |
filename, | |||
normalize, | |||
data, | |||
password | |||
) |
Upload a testing payload storage to a staging globaltag and create or update a jira issue Parameters: filename (str): filename of the testing payload storage file that should be uploaded normalize (Union[bool, str]): if True the payload root files will be normalized to have the same checksum for the same content, if normalize is a string in addition the file name in the root file metadata will be set to it data (dict): a dictionary with the information provided by the user: * task: category of globaltag, either main, online, prompt, data, mc, or analysis * tag: the globaltag name * request: type of request, either Update, New, or Modification. The latter two imply task == main because if new payload classes are introduced or payload classes are modified then they will first be included in the main globaltag. Here a synchronization of code and payload changes has to be managed. If new or modified payload classes should be included in other globaltags they must already be in a release. * pull-request: number of the pull request containing new or modified payload classes, only for request == New or Modified * backward-compatibility: description of what happens if the old payload is encountered by the updated code, only for request == Modified * forward-compatibility: description of what happens if a new payload is encountered by the existing code, only for request == Modified * release: the required release version * reason: the reason for the request * description: a detailed description for the globaltag manager * issue: identifier of an existing jira issue (optional) * user: name of the user * time: time stamp of the request password: the password for access to jira or the access token and secret for oauth access Returns: True if the upload and jira issue creation/upload was successful
Definition at line 873 of file __init__.py.
def upload | ( | self, | |
filename, | |||
global_tag, | |||
normalize = False , |
|||
ignore_existing = False , |
|||
nprocess = 1 , |
|||
uploaded_entries = None |
|||
) |
Upload a testing payload storage to the conditions database. Parameters: filename (str): filename of the testing payload storage file that should be uploaded global_tage (str): name of the globaltag to which the data should be uploaded normalize (Union[bool, str]): if True the payload root files will be normalized to have the same checksum for the same content, if normalize is a string in addition the file name in the root file metadata will be set to it ignore_existing (bool): if True do not upload payloads that already exist nprocess (int): maximal number of parallel uploads uploaded_entries (list): the list of successfully uploaded entries Returns: True if the upload was successful
Definition at line 728 of file __init__.py.