Belle II Software light-2406-ragdoll
PayloadInformation Class Reference

Public Member Functions

def from_json (cls, payload, iov=None)
 
def __init__ (self, payload_id, name, revision, checksum, payload_url, base_url, iov_id=None, iov=None)
 
def url (self)
 
def __hash__ (self)
 
def __eq__ (self, other)
 
def __lt__ (self, other)
 
def readable_iov (self)
 

Public Attributes

 name
 name of the payload
 
 checksum
 checksum of the payload
 
 iov
 interval of validity
 
 revision
 revision, not used for comparisons
 
 payload_id
 payload id in CDB, not used for comparisons
 
 iov_id
 iov id in CDB, not used for comparisons
 
 base_url
 base url
 
 payload_url
 payload url
 

Detailed Description

Small container class to help compare payload information for efficient
comparison between globaltags

Definition at line 136 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  payload_id,
  name,
  revision,
  checksum,
  payload_url,
  base_url,
  iov_id = None,
  iov = None 
)
Create a new object from the given information

Definition at line 162 of file __init__.py.

162 def __init__(self, payload_id, name, revision, checksum, payload_url, base_url, iov_id=None, iov=None):
163 """
164 Create a new object from the given information
165 """
166
167 self.name = name
168
169 self.checksum = checksum
170
171 self.iov = iov
172
173 self.revision = revision
174
175 self.payload_id = payload_id
176
177 self.iov_id = iov_id
178
179 self.base_url = base_url
180
181 self.payload_url = payload_url
182

Member Function Documentation

◆ __eq__()

def __eq__ (   self,
  other 
)
Check if two payloads are equal

Definition at line 192 of file __init__.py.

192 def __eq__(self, other):
193 """Check if two payloads are equal"""
194 return (self.name, self.checksum, self.iov) == (other.name, other.checksum, other.iov)
195

◆ __hash__()

def __hash__ (   self)
Make object hashable

Definition at line 188 of file __init__.py.

188 def __hash__(self):
189 """Make object hashable"""
190 return hash((self.name, self.checksum, self.iov))
191

◆ __lt__()

def __lt__ (   self,
  other 
)
Sort payloads by name, iov, revision

Definition at line 196 of file __init__.py.

196 def __lt__(self, other):
197 """Sort payloads by name, iov, revision"""
198 return (self.name.lower(), self.iov, self.revision) < (other.name.lower(), other.iov, other.revision)
199

◆ from_json()

def from_json (   cls,
  payload,
  iov = None 
)
Set all internal members from the json information of the payload and the iov.

Arguments:
    payload (dict): json information of the payload as returned by REST api
    iov (dict): json information of the iov as returned by REST api

Definition at line 141 of file __init__.py.

141 def from_json(cls, payload, iov=None):
142 """Set all internal members from the json information of the payload and the iov.
143
144 Arguments:
145 payload (dict): json information of the payload as returned by REST api
146 iov (dict): json information of the iov as returned by REST api
147 """
148 if iov is None:
149 iov = {"payloadIovId": None, "expStart": None, "runStart": None, "expEnd": None, "runEnd": None}
150
151 return cls(
152 payload['payloadId'],
153 payload['basf2Module']['name'],
154 payload['revision'],
155 payload['checksum'],
156 payload['payloadUrl'],
157 payload['baseUrl'],
158 iov['payloadIovId'],
159 (iov["expStart"], iov["runStart"], iov["expEnd"], iov["runEnd"]),
160 )
161

◆ readable_iov()

def readable_iov (   self)
return a human readable name for the IoV

Definition at line 200 of file __init__.py.

200 def readable_iov(self):
201 """return a human readable name for the IoV"""
202 if self.iov is None:
203 return "none"
204
205 if self.iov == (0, 0, -1, -1):
206 return "always"
207
208 e1, r1, e2, r2 = self.iov
209 if e1 == e2:
210 if r1 == 0 and r2 == -1:
211 return f"exp {e1}"
212 elif r2 == -1:
213 return f"exp {e1}, runs {r1}+"
214 elif r1 == r2:
215 return f"exp {e1}, run {r1}"
216 else:
217 return f"exp {e1}, runs {r1} - {r2}"
218 else:
219 if e2 == -1 and r1 == 0:
220 return f"exp {e1} - forever"
221 elif e2 == -1:
222 return f"exp {e1}, run {r1} - forever"
223 elif r1 == 0 and r2 == -1:
224 return f"exp {e1}-{e2}, all runs"
225 elif r2 == -1:
226 return f"exp {e1}, run {r1} - exp {e2}, all runs"
227 else:
228 return f"exp {e1}, run {r1} - exp {e2}, run {r2}"
229
230

◆ url()

def url (   self)
Return the full url to the payload on the server

Definition at line 184 of file __init__.py.

184 def url(self):
185 """Return the full url to the payload on the server"""
186 return urllib.parse.urljoin(self.base_url + '/', self.payload_url)
187

Member Data Documentation

◆ base_url

base_url

base url

Definition at line 179 of file __init__.py.

◆ checksum

checksum

checksum of the payload

Definition at line 169 of file __init__.py.

◆ iov

iov

interval of validity

Definition at line 171 of file __init__.py.

◆ iov_id

iov_id

iov id in CDB, not used for comparisons

Definition at line 177 of file __init__.py.

◆ name

name

name of the payload

Definition at line 167 of file __init__.py.

◆ payload_id

payload_id

payload id in CDB, not used for comparisons

Definition at line 175 of file __init__.py.

◆ payload_url

payload_url

payload url

Definition at line 181 of file __init__.py.

◆ revision

revision

revision, not used for comparisons

Definition at line 173 of file __init__.py.


The documentation for this class was generated from the following file: