ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
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)
 
Optional[Path] reference_file (self, "WorkflowTest" test, str file_name)
 

Public Attributes

 format
 
 max_events
 
 detailed_comparison
 
 setup
 
 logger
 

Detailed Description

Run Frozen Tier0 Policy Check.

Definition at line 105 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 108 of file Checks.py.

108  def __init__(self, setup: TestSetup, input_format: str, max_events: int) -> None:
109  super().__init__(setup)
110  self.format = input_format
111  self.max_events = str(max_events)
112  self.detailed_comparison = setup.detailed_comparison
113 

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

Definition at line 114 of file Checks.py.

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

Member Data Documentation

◆ detailed_comparison

python.Checks.FrozenTier0PolicyCheck.detailed_comparison

Definition at line 112 of file Checks.py.

◆ format

python.Checks.FrozenTier0PolicyCheck.format

Definition at line 110 of file Checks.py.

◆ logger

python.Test.WorkflowCheck.logger
inherited

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

◆ max_events

python.Checks.FrozenTier0PolicyCheck.max_events

Definition at line 111 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
vtune_athena.format
format
Definition: vtune_athena.py:14
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