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

Public Member Functions

None __init__ (self, TestSetup setup, str input_format)
 
bool run (self, WorkflowTest test)
 
Optional[Path] reference_file (self, "WorkflowTest" test, str file_name)
 

Public Attributes

 format
 
 setup
 
 logger
 

Detailed Description

Run metadata check.

Definition at line 236 of file Checks.py.

Constructor & Destructor Documentation

◆ __init__()

None python.Checks.MetadataCheck.__init__ (   self,
TestSetup  setup,
str  input_format 
)

Definition at line 239 of file Checks.py.

239  def __init__(self, setup: TestSetup, input_format: str) -> None:
240  super().__init__(setup)
241  self.format = input_format
242 

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.MetadataCheck.run (   self,
WorkflowTest  test 
)

Definition at line 243 of file Checks.py.

243  def run(self, test: WorkflowTest) -> bool:
244  self.logger.info("---------------------------------------------------------------------------------------")
245  self.logger.info(f"Running {test.ID} metadata check on {self.format}")
246 
247  file_name = f"my{self.format}.pool.root"
248  if test.type == WorkflowType.Derivation:
249  file_name = f"{self.format}.myOutput.pool.root"
250 
251  reference_file = self.reference_file(test, file_name)
252  if reference_file is None:
253  self.logger.error(f"Reference file {file_name} not found")
254  return False
255 
256  self.logger.info(f"Reading the reference file from location {reference_file}")
257 
258  exclusion_list = " ".join(["file_guid", "file_size", "/TagInfo/AtlasRelease", "FileMetaData/productionRelease", "StreamDAOD_PHYS/eventTypes", "StreamDAOD_PHYSLITE/eventTypes"])
259 
260  validation_file = test.validation_path / file_name
261  log_file = test.validation_path / f"meta-diff-{test.ID}.{self.format}.log"
262 
263  comparison_command = f"meta-diff --ordered -m full -x diff {reference_file} {validation_file} --drop {exclusion_list} --ignoreTrigger > {log_file} 2>&1"
264  output, error = subprocess.Popen(["/bin/bash", "-c", comparison_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
265  output, error = output.decode("utf-8"), error.decode("utf-8")
266 
267  result = True
268  with log_file.open() as file:
269  for line in file:
270  if line.strip():
271  result = False
272 
273  if result:
274  self.logger.info("Passed!\n")
275  else:
276  # print CI helper directly to avoid logger decorations
277  if self.setup.disable_release_setup:
278  self.logger.print(f"ATLAS-CI-ADD-LABEL: {test.run.value}-{test.type.value}-output-changed")
279  self.logger.print("")
280 
281  self.logger.error(f"Your change breaks the frozen tier0 policy in test {test.ID}.")
282  self.logger.error("Please make sure this has been discussed in the correct meeting (RIG or Simulation) meeting and approved by the relevant experts.")
283 
284  # copy the artifacts
285  if self.setup.disable_release_setup:
286  comparison_command = f"CopyCIArtifact.sh {validation_file}"
287  output, error = subprocess.Popen(["/bin/bash", "-c", comparison_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
288  output, error = output.decode("utf-8"), error.decode("utf-8")
289 
290  if error or not output:
291  self.logger.error(f"Tried copying '{validation_file}' to the CI artifacts area but it failed.")
292  self.logger.error(f" {error.strip()}")
293  else:
294  self.logger.error(output)
295 
296  with log_file.open() as file:
297  for line in file:
298  self.logger.info(f" {line.strip()}")
299  self.logger.info("-----------------------------------------------------\n")
300 
301  return result
302 

Member Data Documentation

◆ format

python.Checks.MetadataCheck.format

Definition at line 241 of file Checks.py.

◆ logger

python.Test.WorkflowCheck.logger
inherited

Definition at line 89 of file Tools/WorkflowTestRunner/python/Test.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
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
error
Definition: IImpactPoint3dEstimator.h:70