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

Public Member Functions

None __init__ (self, TestSetup setup, str input_format, int max_events)
bool run (self, WorkflowTest test)
Path|None reference_file (self, "WorkflowTest" test, str file_name)

Public Attributes

 format = input_format
 max_events = str(max_events)
 detailed_comparison = setup.detailed_comparison
 allow_tolerance = setup.allow_tolerance
 setup = setup
 logger = setup.logger

Detailed Description

Run Frozen Tier0 Policy Check.

Definition at line 101 of file Checks.py.

Constructor & Destructor Documentation

◆ __init__()

None python.Checks.FrozenTier0PolicyCheck.__init__ ( self,
TestSetup setup,
str input_format,
int max_events )

Definition at line 104 of file Checks.py.

104 def __init__(self, setup: TestSetup, input_format: str, max_events: int) -> None:
105 super().__init__(setup)
106 self.format = input_format
107 self.max_events = str(max_events)
108 self.detailed_comparison = setup.detailed_comparison
109 self.allow_tolerance = setup.allow_tolerance
110

Member Function Documentation

◆ reference_file()

Path | None 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) -> Path | None:
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.FrozenTier0PolicyCheck.run ( self,
WorkflowTest test )

Definition at line 111 of file Checks.py.

111 def run(self, test: WorkflowTest) -> bool:
112 self.logger.info("---------------------------------------------------------------------------------------")
113 self.logger.info(f"Running {test.ID} Frozen Tier0 Policy Check on {self.format} for {self.max_events} events")
114
115 diff_rules_path: Path = self.setup.diff_rules_path
116 diff_rules_exclusion_filename: str = f"{test.ID}_{self.format}_diff-exclusion-list.txt"
117 diff_rules_interest_filename: str = f"{test.ID}_{self.format}_diff-interest-list.txt"
118 diff_rules_file = None
119
120 file_name = f"my{self.format}.pool.root"
121 if test.type == WorkflowType.Derivation:
122 file_name = f"{self.format}.myOutput.pool.root"
123 reference_file = self.reference_file(test, file_name)
124 if reference_file is None:
125 self.logger.error(f"Reference file {file_name} not found")
126 return False
127
128 if self.setup.validation_only:
129 cvmfs_path = Path(references_CVMFS_path)
130 diff_rules_path = cvmfs_path / self.setup.release_ID / test.ID
131
132 self.logger.info(f"Reading the reference file from location {reference_file}")
133
134 # try to get the exclusion list or the list of branches of interest
135 branches_of_interest = False
136 if self.setup.diff_rules_path is None:
137 diff_rules_exclusion_local_path = test.validation_path / diff_rules_exclusion_filename
138 diff_rules_interest_local_path = test.validation_path / diff_rules_interest_filename
139 subprocess.Popen(["/bin/bash", "-c", f"cd {test.validation_path}; get_files -remove -data {diff_rules_exclusion_filename}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
140 subprocess.Popen(["/bin/bash", "-c", f"cd {test.validation_path}; get_files -remove -data {diff_rules_interest_filename}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
141 if not diff_rules_exclusion_local_path.exists() and not diff_rules_interest_local_path.exists():
142 self.logger.info(f"Neither '{diff_rules_exclusion_local_path}' nor '{diff_rules_interest_local_path}' files exist in the release.")
143 elif diff_rules_exclusion_local_path.exists():
144 diff_rules_file = diff_rules_exclusion_local_path
145 elif diff_rules_interest_local_path.exists():
146 diff_rules_file = diff_rules_interest_local_path
147 branches_of_interest = True
148
149 if diff_rules_file is None and diff_rules_path is not None:
150 diff_rules_file = diff_rules_path / diff_rules_exclusion_filename
151 if not diff_rules_file.exists():
152 diff_rules_file = diff_rules_path / diff_rules_interest_filename
153 if diff_rules_file.exists():
154 branches_of_interest = True
155
156 if diff_rules_file is not None and diff_rules_file.exists():
157 self.logger.info(f"Reading the diff rules file from location {diff_rules_file}")
158 diff_root_list = []
159 with diff_rules_file.open() as f:
160 for line in f:
161 stripped_line = line.rstrip()
162 if stripped_line and stripped_line[0] != '#':
163 diff_root_list.append(rf"'{stripped_line}'")
164 else:
165 self.logger.info("No diff rules file exists, using the default list")
166 diff_root_list = [r"'index_ref'"]
167
168 if self.allow_tolerance and test.diff_tolerances is not None:
169 self.logger.info(f"Reading the tolerances from location {test.diff_tolerances}")
170 else:
171 self.logger.info("Default diff-root tolerances will be used")
172
173 validation_file = test.validation_path / file_name
174 log_file = test.validation_path / f"diff-root-{test.ID}.{self.format}.log"
175 diff_root_list = " ".join(diff_root_list)
176 diff_root_mode = "--branches-of-interest" if branches_of_interest else "--ignore-leaves"
177 tolerances_mode = f"--tolerances @{test.diff_tolerances}" if self.allow_tolerance and test.diff_tolerances is not None else ""
178
179 comparison_mode = "detailed" if self.detailed_comparison else "semi-detailed"
180 comparison_command = f"acmd.py diff-root {reference_file} {validation_file} --order-trees --nan-equal --exact-branches --mode {comparison_mode} --error-mode resilient {diff_root_mode} {diff_root_list} --entries {self.max_events} {tolerances_mode} > {log_file} 2>&1"
181 output, error = subprocess.Popen(["/bin/bash", "-c", comparison_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
182 output, error = output.decode("utf-8"), error.decode("utf-8")
183
184 # We want to catch/print both container additions/subtractions as well as
185 # changes in these containers. `allGood_return_code` is meant to catch
186 # other issues found in the diff (not expected, but just to be safe)
187 passed_frozen_tier0_test = True
188 all_good = False
189 with log_file.open() as file:
190 for line in file:
191 if "WARNING" in line: # Catches container addition/subtractions
192 self.logger.error(line.strip())
193 passed_frozen_tier0_test = False
194 if "leaves differ" in line: # Catches changes in branches
195 self.logger.error(line.strip())
196 passed_frozen_tier0_test = False
197 if "ERROR" in line: # Catches other issues (including unmatched branches)
198 self.logger.error(line.strip())
199 passed_frozen_tier0_test = False
200 if "INFO all good." in line:
201 all_good = True
202
203 result = passed_frozen_tier0_test and all_good
204 if result:
205 self.logger.info("Passed!\n")
206 else:
207 # print CI helper directly to avoid logger decorations
208 if self.setup.disable_release_setup:
209 self.logger.print(f"ATLAS-CI-ADD-LABEL: {test.run.value}-{test.type.value}-output-changed")
210 self.logger.print("")
211
212 if "DAOD" in self.format:
213 self.logger.error(f"Your change breaks the frozen derivation policy in test {test.ID}.")
214 self.logger.error("Please make sure you explain the reason for the change and ask relevant experts for approval.")
215 else:
216 self.logger.error(f"Your change affects standard outputs in test {test.ID}.")
217 self.logger.error("Please make sure you explain the reason for the change and ask relevant experts for approval.")
218
219 # copy the artifacts
220 if self.setup.disable_release_setup:
221 comparison_command = f"CopyCIArtifact.sh {validation_file}"
222 output, error = subprocess.Popen(["/bin/bash", "-c", comparison_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
223 output, error = output.decode("utf-8"), error.decode("utf-8")
224
225 if error or not output:
226 self.logger.error(f"Tried copying '{validation_file}' to the CI artifacts area but it failed.")
227 self.logger.error(f" {error.strip()}")
228 else:
229 self.logger.error(output)
230
231 with log_file.open() as file:
232 for line in file:
233 self.logger.info(f" {line.strip()}")
234 self.logger.info("-----------------------------------------------------\n")
235
236 return result
237
238
void print(char *figname, TCanvas *c1)
int run(int argc, char *argv[])

Member Data Documentation

◆ allow_tolerance

python.Checks.FrozenTier0PolicyCheck.allow_tolerance = setup.allow_tolerance

Definition at line 109 of file Checks.py.

◆ detailed_comparison

python.Checks.FrozenTier0PolicyCheck.detailed_comparison = setup.detailed_comparison

Definition at line 108 of file Checks.py.

◆ format

python.Checks.FrozenTier0PolicyCheck.format = input_format

Definition at line 106 of file Checks.py.

◆ logger

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

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

◆ max_events

python.Checks.FrozenTier0PolicyCheck.max_events = str(max_events)

Definition at line 107 of file Checks.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: