ATLAS Offline Software
Loading...
Searching...
No Matches
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 = input_format
 setup = setup
 logger = 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 93 of file Tools/WorkflowTestRunner/python/Test.py.

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

◆ 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
void print(char *figname, TCanvas *c1)
Definition run.py:1

Member Data Documentation

◆ format

python.Checks.MetadataCheck.format = input_format

Definition at line 241 of file Checks.py.

◆ logger

python.Test.WorkflowCheck.logger = setup.logger
inherited

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

◆ setup

python.Test.WorkflowCheck.setup = setup
inherited

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


The documentation for this class was generated from the following file: