Skip to content

Commit

Permalink
adjust logging & remove LOGGER.*->
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Oct 2, 2023
1 parent 7c7dc14 commit 51ebb6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
27 changes: 13 additions & 14 deletions skymap_scanner/utils/data_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ def stage_files(self, file_list: List[str]):
Args:
file_list (List[str]): list of file filenames to look up / retrieve.
"""
LOGGER.debug(f"Staging files in filelist: {file_list}")
LOGGER.info(f"Staging files in filelist: {file_list}")
for basename in file_list:
try:
filepath: str = self.get_local_filepath(basename)
except FileNotFoundError:
LOGGER.debug(
f"File {basename} is not available on default local paths."
)
LOGGER.info(f"File {basename} is not available on default local paths.")
if (self.staging_path / basename).is_file():
LOGGER.debug("File is available on staging path.")
LOGGER.info("File is available on staging path.")
else:
LOGGER.debug("Staging from HTTP source.")
LOGGER.info("Staging from HTTP source.")
self.stage_file(basename)

else:
LOGGER.debug(f"File {basename} is available at {filepath}.")
LOGGER.info(f"File {basename} is available at {filepath}.")

LOGGER.info(f"Finished staging files in filelist: {file_list}")

def stage_file(self, basename: str):
"""Retrieves a file from the HTTP source.
Expand Down Expand Up @@ -112,10 +112,9 @@ def get_local_filepath(self, filename: str) -> str:
filepath = subdir / filename
LOGGER.debug(f"Trying to read {filepath}...")
if filepath.is_file():
LOGGER.debug(f"-> success.")
filename = str(filepath)
return filename
else:
LOGGER.debug(f"-> fail.")
# File was not found in local paths.
raise FileNotFoundError(f"File {filename} is not available on any local path.")
LOGGER.debug(f"File found {filename}.")
return str(filepath)

raise FileNotFoundError(
f"File {filename} is not available on any local path: {self.local_paths}."
)
6 changes: 3 additions & 3 deletions skymap_scanner/utils/load_scan_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def get_baseline_gcd_frames(baseline_GCD_file, GCDQp_packet) -> List[icetray.I3F
try:
baseline_GCD_frames = load_framepacket_from_file(baseline_GCD_file)
except:
LOGGER.debug(" -> failed")
LOGGER.debug(f"Failed to read GCD from {baseline_GCD_file}")
raise RuntimeError("Unable to read baseline GCD. In the current design, this is unexpected. Possibly a bug or data corruption!")
if baseline_GCD_frames is not None:
LOGGER.debug(" -> success")
LOGGER.debug("Retrieved GCD from file")
# NOTE: Legacy code used to scan a list of GCD_BASE_DIRS.
# It is now assumed that assume that the passed `baseline_GCD_file` is a valid path to a baseline GCD file.

Expand Down Expand Up @@ -155,7 +155,7 @@ def load_GCDQp_state(event_metadata: EventMetadata, cache_dir="./cache/") -> dic
LOGGER.debug("load_GCDQp_state => reading source baseline GCD from {0}".format(read_path))
source_baseline_GCD_framepacket = load_framepacket_from_file(read_path)
except:
LOGGER.debug(" -> failed")
LOGGER.debug(f"Failed to load source baseline GCD from {read_path}")
source_baseline_GCD_framepacket = None
if source_baseline_GCD_framepacket is None:
raise RuntimeError(f"load_GCDQp_state => Could not read the source GCD file \"{source_baseline_GCD_metadata}\"")
Expand Down

0 comments on commit 51ebb6b

Please sign in to comment.