ATLAS Offline Software
Public Member Functions | Public Attributes | Private Member Functions | List of all members
python.tags.DefectsDBTagsMixin Class Reference
Inheritance diagram for python.tags.DefectsDBTagsMixin:
Collaboration diagram for python.tags.DefectsDBTagsMixin:

Public Member Functions

None __init__ (self)
 
List[strlogics_tags (self)
 
List[strdefects_tags (self)
 
str next_logics_tag (self)
 
str new_hierarchical_tag (self, str defects_tag, str logics_tag)
 
bool defects_tag_valid (self)
 
bool logics_tag_valid (self)
 
None check_tag_validity (self)
 
str defects_tag (self)
 
str logics_tag (self)
 
tagtype tag (self)
 
List[strtags (self)
 
str new_logics_tag (self, str description="")
 
str new_defects_tag (self, str name, str description, Optional[Iterable] iovranges=None)
 

Public Attributes

 logics_tag
 

Private Member Functions

None _tag_head_and_lock (self, cool.IFolder folder, str name, str description)
 

Detailed Description

Definition at line 20 of file tags.py.

Constructor & Destructor Documentation

◆ __init__()

None python.tags.DefectsDBTagsMixin.__init__ (   self)

Definition at line 21 of file tags.py.

21  def __init__(self) -> None:
22  super(DefectsDBTagsMixin, self).__init__()
23 
24  self.check_tag_validity()
25 

Member Function Documentation

◆ _tag_head_and_lock()

None python.tags.DefectsDBTagsMixin._tag_head_and_lock (   self,
cool.IFolder  folder,
str  name,
str  description 
)
private
Give the current HEAD of `folder` a new tag and lock it.

Definition at line 52 of file tags.py.

52  def _tag_head_and_lock(self, folder: cool.IFolder, name: str, description: str) -> None:
53  """
54  Give the current HEAD of `folder` a new tag and lock it.
55  """
56  LOCKED = cool.HvsTagLock.LOCKED
57  aname = name.encode('ascii')
58  folder.cloneTagAsUserTag('HEAD', aname, description.encode('utf-8'))
59  folder.setTagLockStatus(aname, LOCKED)
60 

◆ check_tag_validity()

None python.tags.DefectsDBTagsMixin.check_tag_validity (   self)
Ensure that the tags that this DefectsDB instance was constructed with
are functional

Definition at line 110 of file tags.py.

110  def check_tag_validity(self) -> None:
111  """
112  Ensure that the tags that this DefectsDB instance was constructed with
113  are functional
114  """
115  if not (self.defects_tag_valid or self.logics_tag_valid):
116  raise InvalidTagError("Tag doesn't resolve: {0}".format(self._tag))
117 

◆ defects_tag()

str python.tags.DefectsDBTagsMixin.defects_tag (   self)
Return the tag used for retrieving defects on this DefectsDB instance

Definition at line 119 of file tags.py.

119  def defects_tag(self) -> str:
120  """
121  Return the tag used for retrieving defects on this DefectsDB instance
122  """
123  if self._tag.defects == "HEAD": return "HEAD"
124  try:
125  return self.defects_folder.resolveTag(self._tag.defects)
126  except Exception:
127  if self._read_only:
128  raise InvalidDefectTagError(self._tag.defects)
129  # assume user knows what they're doing (e.g. writing to fresh tag)
130  return self._tag.defects
131 

◆ defects_tag_valid()

bool python.tags.DefectsDBTagsMixin.defects_tag_valid (   self)

Definition at line 93 of file tags.py.

93  def defects_tag_valid(self) -> bool:
94  try:
95  self.defects_tag
96  except InvalidTagError:
97  return False
98  else:
99  return True
100 

◆ defects_tags()

List[str] python.tags.DefectsDBTagsMixin.defects_tags (   self)
Returns a list of existing defect tags

Definition at line 34 of file tags.py.

34  def defects_tags(self) -> List[str]:
35  """
36  Returns a list of existing defect tags
37  """
38  return [str(t) for t in self.defects_folder.listTags()]
39 

◆ logics_tag()

str python.tags.DefectsDBTagsMixin.logics_tag (   self)
Return the tag used for retrieving virtual defect clauses

Definition at line 133 of file tags.py.

133  def logics_tag(self) -> str:
134  """
135  Return the tag used for retrieving virtual defect clauses
136  """
137  if self._tag.logic == "HEAD": return "HEAD"
138  try:
139  return self.defect_logic_folder.resolveTag(self._tag.logic)
140  except Exception:
141  if self._read_only:
142  raise InvalidLogicTagError(self._tag.logic)
143  # assume user knows what they're doing (e.g. writing to fresh tag)
144  return self._tag.logic
145 

◆ logics_tag_valid()

bool python.tags.DefectsDBTagsMixin.logics_tag_valid (   self)

Definition at line 102 of file tags.py.

102  def logics_tag_valid(self) -> bool:
103  try:
104  self.logics_tag
105  except InvalidTagError:
106  return False
107  else:
108  return True
109 

◆ logics_tags()

List[str] python.tags.DefectsDBTagsMixin.logics_tags (   self)
Returns a list of existing logic tags

Definition at line 27 of file tags.py.

27  def logics_tags(self) -> List[str]:
28  """
29  Returns a list of existing logic tags
30  """
31  return [str(t) for t in self.defect_logic_folder.listTags()]
32 

◆ new_defects_tag()

str python.tags.DefectsDBTagsMixin.new_defects_tag (   self,
str  name,
str  description,
Optional[Iterable]   iovranges = None 
)
Clones the current DEFECTS tag (specified in the constructor) to a new one
If iovranges != None, does the slower thing of copying IOVs one by one

Parameters:
    `name` : Name of the new tag
    `description` : Description of the contents of this tag

Definition at line 175 of file tags.py.

175  def new_defects_tag(self, name: str, description: str, iovranges: Optional[Iterable] = None) -> str:
176  """
177  Clones the current DEFECTS tag (specified in the constructor) to a new one
178  If iovranges != None, does the slower thing of copying IOVs one by one
179 
180  Parameters:
181  `name` : Name of the new tag
182  `description` : Description of the contents of this tag
183  """
184  if name.startswith("DetStatus"):
185  raise RuntimeError("Only specify the last part of the defect tag")
186  adescription = description.encode('utf-8')
187 
188  log.info("Creating new tag %s", name)
189 
190  name = f"DetStatusDEFECTS-{name}"
191  aname = name.encode('ascii')
192 
193  if iovranges is None:
194  self.defects_folder.cloneTagAsUserTag(self.defects_tag.encode('ascii'), aname, adescription)
195  return name
196 
197  # Fetch all primary defects relevant to `iovranges`
198  kwargs = dict(primary_only=True, nonpresent=True, intersect=True)
199  iovsets = (self.retrieve(*iovrange, **kwargs) for iovrange in iovranges)
200  to_copy = IOVSet.from_iovsets(iovsets)
201 
202  log.info("Copying IoVs: %r", to_copy)
203 
204  with self.storage_buffer:
205  for iov in to_copy:
206  self._insert_iov(iov, name)
207 
208  # If there are no IOVs to copy, there is no new tag to describe
209  if to_copy:
210  self.defects_folder.setTagDescription(aname, adescription)
211 
212  return name

◆ new_hierarchical_tag()

str python.tags.DefectsDBTagsMixin.new_hierarchical_tag (   self,
str  defects_tag,
str  logics_tag 
)
Create a new heirarchical tag relating the defects and logics

New tag is of the form
"DetStatus-[Logic revision number]-[Defect tagname]"
and has description
"(v%i) blah"

Definition at line 61 of file tags.py.

61  def new_hierarchical_tag(self, defects_tag: str, logics_tag: str) -> str:
62  """
63  Create a new heirarchical tag relating the defects and logics
64 
65  New tag is of the form
66  "DetStatus-[Logic revision number]-[Defect tagname]"
67  and has description
68  "(v%i) blah"
69  """
70  logic_revision = int(logics_tag.split("-")[-1])
71  defect_part = "-".join(defects_tag.split("-")[1:])
72  hierarchical_tag = "DetStatus-v%02i-%s" % (logic_revision, defect_part)
73  logicspart = "(%i) " % logic_revision
74 
75  adefects_tag = defects_tag.encode('ascii')
76  alogics_tag = logics_tag.encode('ascii')
77  ahierarchical_tag = hierarchical_tag.encode('ascii')
78  logicspart = logicspart.encode('ascii')
79  defect_descr = self.defects_folder.tagDescription(adefects_tag).encode('utf-8')
80 
81  # Protection here against making descriptions too long
82  description = logicspart + defect_descr[:255 - len(logicspart)]
83 
84  parent_folder = self.parent_folderset
85  self.defects_folder.createTagRelation(ahierarchical_tag, adefects_tag)
86  self.defect_logic_folder.createTagRelation(ahierarchical_tag, alogics_tag)
87  parent_folder.setTagDescription(ahierarchical_tag, description)
88 
89  log.info("New hierarchical tag %s", hierarchical_tag)
90  return hierarchical_tag
91 

◆ new_logics_tag()

str python.tags.DefectsDBTagsMixin.new_logics_tag (   self,
str   description = "" 
)
Create a new tag for the logic folder and lock it.

Parameters:
    `description` : What changed in this tag? (optional, default "")

Definition at line 160 of file tags.py.

160  def new_logics_tag(self, description: str = "") -> str:
161  """
162  Create a new tag for the logic folder and lock it.
163 
164  Parameters:
165  `description` : What changed in this tag? (optional, default "")
166  """
167  assert self.logics_tag == "HEAD", NONHEAD_MODIFICATION_MSG
168 
169  new_tag_name = self.next_logics_tag
170  folder = self.defect_logic_folder
171  self._tag_head_and_lock(folder, new_tag_name, description)
172  log.info("Tagged DEFECTLOGICS HEAD with %s", new_tag_name)
173  return new_tag_name
174 

◆ next_logics_tag()

str python.tags.DefectsDBTagsMixin.next_logics_tag (   self)
Gives the next available DEFECTLOGICS tag

Definition at line 41 of file tags.py.

41  def next_logics_tag(self) -> str:
42  """
43  Gives the next available DEFECTLOGICS tag
44  """
45  existing_tags = self.logics_tags
46  if existing_tags:
47  new_id = max(int(str(t).split("-")[-1]) for t in existing_tags) + 1
48  else:
49  new_id = 0
50  return DEFECT_LOGIC_TAG_FORMAT % new_id
51 

◆ tag()

tagtype python.tags.DefectsDBTagsMixin.tag (   self)
Readonly property stating the tag that the database was instantiated on

Definition at line 147 of file tags.py.

147  def tag(self) -> tagtype:
148  """
149  Readonly property stating the tag that the database was instantiated on
150  """
151  return self._tag
152 

◆ tags()

List[str] python.tags.DefectsDBTagsMixin.tags (   self)
The list of tags which are on the database

Definition at line 154 of file tags.py.

154  def tags(self) -> List[str]:
155  """
156  The list of tags which are on the database
157  """
158  return [str(t) for t in self.parent_folderset.listTags()]
159 

Member Data Documentation

◆ logics_tag

python.tags.DefectsDBTagsMixin.logics_tag

Definition at line 167 of file tags.py.


The documentation for this class was generated from the following file:
max
#define max(a, b)
Definition: cfImp.cxx:41
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
python.PerfMonSerializer.encode
def encode(data, use_base64=True)
Definition: PerfMonSerializer.py:375
Trk::split
@ split
Definition: LayerMaterialProperties.h:38