ATLAS Offline Software
Loading...
Searching...
No Matches
python.Checks.WarningsComparisonCheck Class Reference
Inheritance diagram for python.Checks.WarningsComparisonCheck:
Collaboration diagram for python.Checks.WarningsComparisonCheck:

Public Member Functions

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

Public Attributes

 setup = setup
 logger = setup.logger

Detailed Description

Run WARNINGS check.

Definition at line 529 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 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()

python.Checks.WarningsComparisonCheck.run ( self,
WorkflowTest test )

Definition at line 532 of file Checks.py.

532 def run(self, test: WorkflowTest):
533 self.logger.info("-----------------------------------------------------")
534 self.logger.info(f"Running {test.ID} WARNINGS Check\n")
535
536 result = True
537 for step in test.steps:
538 log_name = f"log.{step}"
539 reference_log = test.reference_path / log_name
540 validation_log = test.validation_path / log_name
541 warnings_reference = warnings_count(reference_log)
542 warnings_validation = warnings_count (validation_log)
543
544 wr=[]
545 for w in warnings_reference:
546 wr.append(w[9:])
547 wv=[]
548 for w in warnings_validation:
549 wv.append(w[9:])
550
551 wn = list(set(wv)-set(wr))
552 wo = list(set(wr)-set(wv))
553
554
555 if len(warnings_validation) > len(warnings_reference):
556 self.logger.error(f"Validation log file {validation_log} has {len(warnings_validation) - len(warnings_reference)} more warning(s) than the reference log file {reference_log}")
557 self.logger.error("Please remove the new warning message(s):")
558 for w in wn:
559 self.logger.error(w)
560 result = False
561 elif len(warnings_validation) < len(warnings_reference):
562 self.logger.info(f"Validation log file {validation_log} has {len(warnings_reference) - len(warnings_validation)} less warnings than the reference log file {reference_log}")
563 self.logger.info("The reduction of unnecessary WARNINGs is much appreciated. Is it expected?")
564 self.logger.info("The following warning messages have been removed:")
565 for w in wo:
566 self.logger.info(w)
567 result = True
568 else :
569 self.logger.info(f"Validation log file {validation_log} has the same number of warnings as the reference log file {reference_log}")
570 result = True
571
572 if result:
573 self.logger.info("Passed!\n")
574 else :
575 self.logger.error("Failed!\n")
576
577 return result
578
579
STL class.
Definition run.py:1

Member Data Documentation

◆ 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: