Skip to content

Commit

Permalink
Do not fail when a DQM result could not be fetched from DIRAC, but in…
Browse files Browse the repository at this point in the history
…stead skip to next DQM run.
  • Loading branch information
jlenain committed Oct 1, 2024
1 parent 9901aab commit fe7fc86
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/nectarchain/user_scripts/jlenain/parse_dqm_fits_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
db_read_keys = list(db_read.root.keys())
db_read.abort_and_close()

db = DQMDB(read_only=False)

for run in args.runs:
if not args.force and f"NectarCAM_Run{run}" in db_read_keys:
logger.warning(
Expand All @@ -80,8 +78,14 @@
printOutput=True,
)

with tarfile.open(os.path.basename(lfn), "r") as tar:
tar.extractall(".")
try:
with tarfile.open(os.path.basename(lfn), "r") as tar:
tar.extractall(".")
except FileNotFoundError as e:
logger.warning(
f"Could not fetch DQM results from DIRAC for run {run}, received error {e}, skipping this run..."
)
continue

fits_file = (
f"./NectarCAM_DQM_Run{run}/output/NectarCAM_Run{run}/"
Expand All @@ -102,7 +106,12 @@
keyname = hdu[extname].header[f"TTYPE{i+1}"]
outdict[extname][keyname] = hdu[extname].data[keyname]

db.insert(f"NectarCAM_Run{run}", outdict)
try:
db = DQMDB(read_only=False)
db.insert(f"NectarCAM_Run{run}", outdict)
db.commit_and_close()
except ZEO.Exceptions.ClientDisconnected as e:
logger.critical(f"Impossible to feed the ZODB data base. Received error: {e}")

# Remove DQM archive file and directory
try:
Expand All @@ -115,8 +124,3 @@
dirpath = Path(f"./NectarCAM_DQM_Run{run}")
if dirpath.exists() and dirpath.is_dir():
shutil.rmtree(dirpath)

try:
db.commit_and_close()
except ZEO.Exceptions.ClientDisconnected as e:
logger.critical(f"Impossible to feed the ZODB data base. Received error: {e}")

0 comments on commit fe7fc86

Please sign in to comment.