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

Public Member Functions

None __init__ (self, TestSetup setup, int max_events=-1)
 
bool run (self, WorkflowTest test)
 
Optional[Path] reference_file (self, "WorkflowTest" test, str file_name)
 

Public Attributes

 max_events
 
 setup
 
 logger
 

Detailed Description

Run AOD Digest Check.

Definition at line 376 of file Checks.py.

Constructor & Destructor Documentation

◆ __init__()

None python.Checks.AODDigestCheck.__init__ (   self,
TestSetup  setup,
int   max_events = -1 
)

Definition at line 379 of file Checks.py.

379  def __init__(self, setup: TestSetup, max_events: int = -1) -> None:
380  super().__init__(setup)
381  self.max_events = str(max_events)
382 

Member Function Documentation

◆ reference_file()

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

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

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

◆ run()

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

Definition at line 383 of file Checks.py.

383  def run(self, test: WorkflowTest) -> bool:
384  self.logger.info("---------------------------------------------------------------------------------------")
385  self.logger.info(f"Running {test.ID} AOD digest")
386 
387  file_name = "myAOD.pool.root"
388  output_name = f"{test.ID}_AOD_digest.txt"
389 
390  validation_file = test.validation_path / file_name
391  validation_output = test.validation_path / output_name
392  validation_log_file = test.validation_path / f"AODdigest-{test.ID}.log"
393  validation_command = f"xAODDigest.py {validation_file} {validation_output} > {validation_log_file} 2>&1"
394 
395  output_val, error_val = subprocess.Popen(["/bin/bash", "-c", validation_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
396  output_val, error_val = output_val.decode("utf-8"), error_val.decode("utf-8")
397  if error_val:
398  self.logger.error(f"Something went wrong with the digest calculation for test {test.ID}:")
399  self.logger.error(error_val)
400 
401  # Read references
402  if self.setup.validation_only:
403  # try to get the reference
404  reference_path = test.validation_path
405  reference_output_name = f"{test.ID}_AOD_digest.ref"
406  reference_output = reference_path / reference_output_name
407  subprocess.Popen(["/bin/bash", "-c", f"cd {reference_path}; get_files -remove -data {reference_output_name}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
408  if not reference_output.exists():
409  self.logger.info(f"No reference file '{reference_output_name}' to compare the digest with. Printing the full digest:")
410  with validation_output.open() as f:
411  for line in f:
412  self.logger.print(f" {line.strip()}")
413  return True
414  else:
415  reference_path = test.reference_path
416  reference_output = reference_path / output_name
417  reference_file = reference_path / file_name
418  reference_log_file = test.reference_path / f"AODdigest-{test.ID}.log"
419 
420  reference_command = f"xAODDigest.py {reference_file} {reference_output} > {reference_log_file} 2>&1"
421  subprocess.Popen(["/bin/bash", "-c", reference_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
422 
423  # Compute the diff
424  diff_output, diff_error = subprocess.Popen(["/bin/bash", "-c", f"diff {reference_output} {validation_output}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
425  diff_output, diff_error = diff_output.decode("utf-8"), diff_error.decode("utf-8")
426 
427  result = False
428  if not diff_output and not diff_error:
429  self.logger.info("Passed!\n")
430  result = True
431  else:
432  # print CI helper directly to avoid logger decorations
433  if self.setup.disable_release_setup:
434  self.logger.print(f"ATLAS-CI-ADD-LABEL: {test.run.value}-{test.type.value}-output-changed")
435  self.logger.print("")
436 
437  self.logger.error(f"Your change breaks the digest in test {test.ID}.")
438  self.logger.error("Please make sure this has been discussed in the correct meeting (RIG or Simulation) meeting and approved by the relevant experts.")
439  if self.setup.validation_only:
440  self.logger.error(f"The output '{output_name}' (>) differs from the reference '{reference_output_name}' (<):")
441  else:
442  self.logger.error(f"The output '{validation_output}' (>) differs from the reference '{reference_output}' (<):")
443  if diff_output:
444  with reference_output.open() as file:
445  self.logger.print(file.readline())
446  self.logger.print(diff_output)
447  if diff_error:
448  self.logger.print(diff_error)
449  self.logger.info("-----------------------------------------------------\n")
450 
451  return result
452 
453 

Member Data Documentation

◆ logger

python.Test.WorkflowCheck.logger
inherited

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

◆ max_events

python.Checks.AODDigestCheck.max_events

Definition at line 381 of file Checks.py.

◆ setup

python.Test.WorkflowCheck.setup
inherited

Definition at line 88 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
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
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
error
Definition: IImpactPoint3dEstimator.h:70