ATLAS Offline Software
Functions
dq_defect_ls Namespace Reference

Functions

def get_primary (ddb)
 
def get_virtual (ddb)
 
def get_both (ddb)
 
def show_tags (connection_string, args)
 
def show_defects (connection_string, tag, get_defects, patterns, args)
 
def show_defects_with_desc (connection_string, tag, get_defects, patterns, args)
 
def show_defects_with_logic (connection_string, tag, patterns, args)
 
def main ()
 

Detailed Description

dq_defect_ls.py

A short script to list defects.

Function Documentation

◆ get_both()

def dq_defect_ls.get_both (   ddb)

Definition at line 19 of file dq_defect_ls.py.

19 def get_both(ddb):
20  return ddb.defect_names | ddb.virtual_defect_names
21 

◆ get_primary()

def dq_defect_ls.get_primary (   ddb)

Definition at line 15 of file dq_defect_ls.py.

15 def get_primary(ddb):
16  return ddb.defect_names

◆ get_virtual()

def dq_defect_ls.get_virtual (   ddb)

Definition at line 17 of file dq_defect_ls.py.

17 def get_virtual(ddb):
18  return ddb.virtual_defect_names

◆ main()

def dq_defect_ls.main ( )

Definition at line 99 of file dq_defect_ls.py.

99 def main():
100  parser = ArgumentParser(description="List information from the defects "
101  "database")
102  a = parser.add_argument
103  add_group = parser.add_argument_group
104 
105  a("-c", "--connection-string", default=DEFAULT_CONNECTION_STRING,
106  help="Database connection to use (default: %s)" % DEFAULT_CONNECTION_STRING)
107 
108  #
109  # TAGS
110  #
111  tag_group = add_group("tags", "Show information about tags")
112  a = tag_group.add_argument
113 
114  a("--tags", action="store_true",
115  help="List all available hierarchical tags")
116 
117  a("--logic-tags", action="store_true",
118  help="Show all logic tags")
119 
120  a("--defect-tags", action="store_true",
121  help="Show all defect tags")
122 
123  #
124  # DEFECTS
125  #
126  defect_group = add_group("defects", "Show information about defects")
127  a = defect_group.add_argument
128 
129  a("-t", "--tag", default=None,
130  help="Tag to use (default: HEAD)")
131 
132  a("-l", "--logic", action="store_true",
133  help="Show logic used for virtual flags (use -v)")
134 
135  a("-V", "--show-virtuality", action="store_true",
136  help="Indicate virtual vs nonvirtual flags")
137 
138  a("-v", "--virtual", action="store_true",
139  help="Show only virtual flags")
140 
141  a("-p", "--primary", action="store_true",
142  help="Show only primary flags")
143 
144  a("-d", "--descriptions", action="store_true",
145  help="Show descriptions")
146 
147  a("patterns", metavar="defect", type=str, nargs="*", default=[],
148  help="One or more defect globs")
149 
150  # These options shouldn't be specified with tag listing options
151  DEFECT_OPTIONS = ["logic", "show_virtuality", "virtual", "primary",
152  "descriptions", "patterns", "tag"]
153 
154  args = parser.parse_args()
155 
156  #print args
157 
158  if args.tags or args.logic_tags or args.defect_tags:
159 
160  for arg in DEFECT_OPTIONS:
161  if getattr(args, arg):
162  raise RuntimeError("--%s doesn't work with any --tags options" % arg)
163 
164  show_tags(args.connection_string, args)
165 
166  else:
167  if not args.patterns:
168  # Default: show all
169  args.patterns = ["*"]
170  if not args.tag:
171  args.tag = "HEAD"
172 
173  if args.logic:
174  assert not args.primary, "--primary doesn't work with --logic"
175  assert not args.descriptions, "--descriptions doesn't work with --logic"
176  assert not args.show_virtuality, "--show-virtuality doesn't work with --logic"
177 
178  arguments = args.connection_string, args.tag, args.patterns, args
179 
180  show_defects_with_logic(*arguments)
181  return
182 
183  get_defects = get_both
184  if args.primary or args.virtual:
185  if args.primary and not args.virtual:
186  get_defects = get_primary
187  else:
188  get_defects = get_virtual
189 
190  arguments = args.connection_string, args.tag, get_defects, args.patterns, args
191 
192  if args.descriptions:
193  show_defects_with_desc(*arguments)
194  else:
195  show_defects(*arguments)
196 

◆ show_defects()

def dq_defect_ls.show_defects (   connection_string,
  tag,
  get_defects,
  patterns,
  args 
)

Definition at line 38 of file dq_defect_ls.py.

38 def show_defects(connection_string, tag, get_defects, patterns, args):
39  ddb = DefectsDB(connection_string, tag=tag)
40 
41  all_defects = get_defects(ddb)
42 
43  for pattern in patterns:
44  if len(patterns) != 1:
45  print() # Extra newline to separate the patterns
46  print(f"{pattern}:")
47  for defect in sorted(fnmatch.filter(all_defects, pattern)):
48  print(defect)
49 

◆ show_defects_with_desc()

def dq_defect_ls.show_defects_with_desc (   connection_string,
  tag,
  get_defects,
  patterns,
  args 
)

Definition at line 50 of file dq_defect_ls.py.

50 def show_defects_with_desc(connection_string, tag, get_defects, patterns, args):
51  ddb = DefectsDB(connection_string, tag=tag)
52 
53  descriptions = ddb.all_defect_descriptions if args.descriptions else {}
54 
55  all_defects = get_defects(ddb)
56  all_matching = [d for pat in patterns for d in fnmatch.filter(all_defects, pat)]
57  if not all_matching:
58  return
59 
60  get_virtuality = lambda defect: ""
61  if args.show_virtuality:
62  primary_defects = ddb.defect_names
63  def get_virtuality(defect):
64  if defect in primary_defects:
65  return "[P] "
66  return "[V] "
67 
68  ldl = longest_defect_length = max(len(d) for d in all_matching)
69 
70  for pattern in patterns:
71  if len(patterns) != 1:
72  print(f"{pattern}:")
73  for defect in sorted(fnmatch.filter(all_defects, pattern)):
74  desc = descriptions.get(defect, "")
75  print("{virtuality}{0:<{width}}: {1}".format(
76  defect, desc, width=ldl, virtuality=get_virtuality(defect)))
77  print
78 

◆ show_defects_with_logic()

def dq_defect_ls.show_defects_with_logic (   connection_string,
  tag,
  patterns,
  args 
)

Definition at line 79 of file dq_defect_ls.py.

79 def show_defects_with_logic(connection_string, tag, patterns, args):
80  ddb = DefectsDB(connection_string, tag=tag)
81 
82  defects = ddb.virtual_defect_names
83  logics = ddb.virtual_defect_logics
84 
85  all_matching = [d for pat in patterns for d in fnmatch.filter(defects, pat)]
86  if not all_matching:
87  return
88 
89  ldl = longest_defect_length = max(len(d) for d in all_matching)
90 
91  for pattern in patterns:
92  if len(patterns) != 1:
93  print(f"{pattern}:")
94  for defect in sorted(fnmatch.filter(defects, pattern)):
95  print("{0:<{width}}: {1}".format(
96  defect, ", ".join(logics[defect].clauses), width=ldl))
97  print
98 

◆ show_tags()

def dq_defect_ls.show_tags (   connection_string,
  args 
)

Definition at line 22 of file dq_defect_ls.py.

22 def show_tags(connection_string, args):
23  ddb = DefectsDB(connection_string)
24 
25  nspec = sum(bool(x) for x in (args.tags, args.defect_tags, args.logic_tags))
26  assert nspec == 1, "Only one of --tags, --logic-tags and --defect-tags can be specified."
27 
28  if args.tags:
29  tags = ddb.tags
30  if args.logic_tags:
31  tags = ddb.logics_tags
32  if args.defect_tags:
33  tags = ddb.defects_tags
34 
35  for t in tags:
36  print(t)
37 
dq_defect_ls.get_primary
def get_primary(ddb)
Definition: dq_defect_ls.py:15
max
#define max(a, b)
Definition: cfImp.cxx:41
vtune_athena.format
format
Definition: vtune_athena.py:14
dq_defect_ls.get_both
def get_both(ddb)
Definition: dq_defect_ls.py:19
dq_defect_ls.show_tags
def show_tags(connection_string, args)
Definition: dq_defect_ls.py:22
dq_defect_ls.show_defects_with_desc
def show_defects_with_desc(connection_string, tag, get_defects, patterns, args)
Definition: dq_defect_ls.py:50
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
dq_defect_ls.get_virtual
def get_virtual(ddb)
Definition: dq_defect_ls.py:17
a
TList * a
Definition: liststreamerinfos.cxx:10
dq_defect_ls.show_defects
def show_defects(connection_string, tag, get_defects, patterns, args)
Definition: dq_defect_ls.py:38
dq_defect_ls.show_defects_with_logic
def show_defects_with_logic(connection_string, tag, patterns, args)
Definition: dq_defect_ls.py:79
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
dq_defect_ls.main
def main()
Definition: dq_defect_ls.py:99
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60