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

Public Member Functions

bool run (self, WorkflowTest test)
 
Optional[Path] reference_file (self, "WorkflowTest" test, str file_name)
 

Public Attributes

 setup
 
 logger
 

Detailed Description

Run AOD Content Check.

Definition at line 303 of file Checks.py.

Member Function Documentation

◆ reference_file()

Optional[Path] python.Test.WorkflowCheck.reference_file (   self,
"WorkflowTest"  test,
str  file_name 
)
inherited

Definition at line 90 of file Tools/WorkflowTestRunner/python/Test.py.

90  def reference_file(self, test: "WorkflowTest", file_name: str) -> Optional[Path]:
91  reference_path: Path = test.reference_path
92  reference_file = reference_path / file_name
93 
94  # Read references from CVMFS
95  if self.setup.validation_only:
96  # Resolve the subfolder first. Results are stored like: main_folder/branch/test/version/.
97  reference_revision = references_map[f"{test.ID}"]
98  cvmfs_path = Path(references_CVMFS_path)
99  rel_path = Path(self.setup.release_ID) / test.ID / reference_revision
100  reference_path = cvmfs_path / rel_path
101  reference_file = reference_path / file_name
102 
103  if not reference_path.exists():
104  self.logger.error(f"CVMFS reference location {reference_path} does not exist!")
105  return None
106 
107  if references_override_url is not None:
108  import requests
109 
110  url = references_override_url
111  if not url.endswith("/"): url += "/"
112  url += str(rel_path / file_name)
113  self.logger.info("Checking for reference override at %s", url)
114  if requests.head(url).ok: # file exists at url
115  reference_file = Path.cwd() / f"reference_{file_name}"
116  self.logger.info("Downloading reference from %s to %s", url, reference_file)
117  r = requests.get(url, stream=True)
118  with reference_file.open('wb') as f:
119  for chunk in r.iter_content(chunk_size=1024):
120  if chunk: # filter out keep-alive new chunks
121  f.write(chunk)
122  else:
123  self.logger.info("No reference override found")
124 
125  return reference_file
126 
127 

◆ run()

bool python.Checks.AODContentCheck.run (   self,
WorkflowTest  test 
)

Definition at line 306 of file Checks.py.

306  def run(self, test: WorkflowTest) -> bool:
307  self.logger.info("---------------------------------------------------------------------------------------")
308  self.logger.info(f"Running {test.ID} AOD content check")
309 
310  file_name = "myAOD.pool.root"
311  output_name = f"{test.ID}_AOD_content.txt"
312 
313  validation_file = test.validation_path / file_name
314  validation_output = test.validation_path / output_name
315  validation_command = f"acmd.py chk-file {validation_file} | awk '/---/{{flag=1;next}}/===/{{flag=0}}flag' | awk '{{print $10}}' | LC_ALL=C sort | uniq > {validation_output}"
316 
317  output_val, error_val = subprocess.Popen(["/bin/bash", "-c", validation_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
318  output_val, error_val = output_val.decode("utf-8"), error_val.decode("utf-8")
319  if error_val:
320  self.logger.error(f"Something went wrong with retrieving the content for test {test.ID}:")
321  self.logger.error(error_val)
322 
323  # Read references
324  if self.setup.validation_only:
325  # try to get the reference
326  reference_path = test.validation_path
327  reference_output_name = f"{test.ID}_AOD_content.ref"
328  reference_output = reference_path / reference_output_name
329  subprocess.Popen(["/bin/bash", "-c", f"cd {reference_path}; get_files -remove -data {reference_output_name}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
330  if not reference_output.exists():
331  self.logger.info(f"No reference file '{reference_output_name}' to compare the content with.")
332  return True
333  else:
334  reference_path = test.reference_path
335  reference_output = reference_path / output_name
336  reference_file = reference_path / file_name
337 
338  reference_command = f"acmd.py chk-file {reference_file} | awk '/---/{{flag=1;next}}/===/{{flag=0}}flag' | awk '{{print $10}}' | LC_ALL=C sort | uniq > {reference_output}"
339  subprocess.Popen(["/bin/bash", "-c", reference_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
340 
341  # Remove HLT containers in some cases
342  extra_diff_args = ""
343  if test.type == WorkflowType.MCReco or test.type == WorkflowType.MCPileUpReco:
344  extra_diff_args = "-I '^HLT' -I '^LVL1' -I '^L1'"
345 
346  # Compute the diff
347  diff_output, diff_error = subprocess.Popen(["/bin/bash", "-c", f"diff {extra_diff_args} {reference_output} {validation_output}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
348  diff_output, diff_error = diff_output.decode("utf-8"), diff_error.decode("utf-8")
349 
350  result = False
351  if not diff_output and not diff_error:
352  self.logger.info("Passed!\n")
353  result = True
354  else:
355  # print CI helper directly to avoid logger decorations
356  if self.setup.disable_release_setup:
357  self.logger.print(f"ATLAS-CI-ADD-LABEL: {test.run.value}-{test.type.value}-output-changed")
358  self.logger.print("")
359 
360  self.logger.error(f"Your change modifies the output in test {test.ID}.")
361  self.logger.error("Please make sure this has been discussed in the correct meeting (RIG or Simulation) meeting and approved by the relevant experts.")
362  if self.setup.validation_only:
363  self.logger.error(f"The output '{output_name}' (>) differs from the reference '{reference_output_name}' (<):")
364  else:
365  self.logger.error(f"The output '{validation_output}' (>) differs from the reference '{reference_output}' (<):")
366  if diff_output:
367  self.logger.print("")
368  self.logger.print(diff_output)
369  if diff_error:
370  self.logger.print(diff_error)
371  self.logger.info("-----------------------------------------------------\n")
372 
373  return result
374 
375 

Member Data Documentation

◆ logger

python.Test.WorkflowCheck.logger
inherited

Definition at line 88 of file Tools/WorkflowTestRunner/python/Test.py.

◆ setup

python.Test.WorkflowCheck.setup
inherited

Definition at line 87 of file Tools/WorkflowTestRunner/python/Test.py.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
error
Definition: IImpactPoint3dEstimator.h:70