-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add script to be used as cronjob to automatically submit DQM jobs on DIRAC once a run has been transferred from CEA to DIRAC * Check if a DQM job has already been submitted for a given NectarCAM run * Activate proper conda environment when starting the script * Cleaning * Add a check whether a run is already present in the ZODB database before parsing it. * Add cronjob script to parse DQM results and feed the ZODB database. * Process a list of runs instead of a single run at once. * Adapt cronjob to pass a list of runs as argument to DQM parser script. * Do not fail when a DQM result could not be fetched from DIRAC, but instead skip to next DQM run. * Change location of log file. * Automatically renew DIRAC proxy --------- Co-authored-by: Jean-Philippe Lenain <[email protected]>
- Loading branch information
Showing
3 changed files
with
151 additions
and
58 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/nectarchain/user_scripts/jlenain/cronjob_parse_dqm_fits_file.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This script is to be used as a cronjob on the nectarcam-dqm-rw VM on the LPNHE OpenStack cloud platform, in order to feed the ZODB database from DQM run on DIRAC. | ||
|
||
# Log everything to $LOGFILE | ||
LOGFILE=${0%".sh"}_$(date +%F).log | ||
LOGFILE=$HOME/log/$(basename $LOGFILE) | ||
exec 1>"$LOGFILE" 2>&1 | ||
|
||
. "/opt/conda/etc/profile.d/conda.sh" | ||
conda activate nectar-dev | ||
|
||
# Initialize DIRAC proxy from user certificate: | ||
if ! dirac-proxy-init -M -g cta_nectarcam --pwstdin < ~/.dirac.pwd; then | ||
echo "DIRAC proxy initialization failed..." | ||
exit 1 | ||
fi | ||
|
||
remoteParentDir="/vo.cta.in2p3.fr/user/j/jlenain/nectarcam/dqm" | ||
nectarchainScriptDir="/opt/cta/nectarchain/src/nectarchain/user_scripts/jlenain" | ||
|
||
python ${nectarchainScriptDir}/parse_dqm_fits_file.py -r $(dls ${remoteParentDir} | grep -ve "/vo.cta" | awk -F. '{print $1}' | awk -Fn '{print $2}' | tr '\n' ' ') |
46 changes: 46 additions & 0 deletions
46
src/nectarchain/user_scripts/jlenain/dqm_job_submitter/cronjob_launchDQM.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Author: Jean-Philippe Lenain <[email protected]> | ||
# | ||
# Script as a cronjob to dynamically launch NectarCAM DQM runs on DIRAC after data transfer, to be run once a day on sedipccaa23 in CEA/Irfu. | ||
|
||
# Log everything to $LOGFILE | ||
LOGFILE=${0%".sh"}_$(date +%F).log | ||
LOGFILE=$HOME/log/$(basename $LOGFILE) | ||
exec 1>"$LOGFILE" 2>&1 | ||
|
||
source /opt/cta/mambaforge/etc/profile.d/conda.sh | ||
conda activate ctadirac | ||
|
||
localParentDir="/data/nvme/ZFITS" | ||
remoteParentDir="/vo.cta.in2p3.fr/nectarcam" | ||
nectarchainScriptDir="$HOME/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/jlenain/dqm_job_submitter" | ||
|
||
cd $nectarchainScriptDir || (echo "Failed to cd into ${nectarchainScriptDir}, exiting..."; exit 1) | ||
|
||
for run in $(find ${localParentDir} -type f -name "NectarCAM*.fits.fz" | awk -F. '{print $2}' | awk -Fn '{print $2}' | sort | uniq); do | ||
echo "Probing files for run ${run}" | ||
nbLocalFiles=$(find ${localParentDir} -type f -name "NectarCAM.Run${run}.????.fits.fz" | wc -l) | ||
echo " Found $nbLocalFiles local files for run $run" | ||
nbRemoteFiles=$(dfind ${remoteParentDir} | grep -e "NectarCAM.Run${run}" | grep --count -e "fits.fz") | ||
echo " Found $nbRemoteFiles remote files on DIRAC for run $run" | ||
# If number of local and remote files matching, will attempt to launch a DQM run | ||
if [ ${nbLocalFiles} -eq ${nbRemoteFiles} ]; then | ||
echo " Run $run: number of local and remote files matching, will attempt to submit a DQM job" | ||
# Has this DQM run already been submitted ? | ||
if [ $(dstat | grep --count -e "NectarCAM DQM run ${run}") -eq 0 ]; then | ||
yyyymmdd=$(find ${localParentDir} -type f -name "NectarCAM.Run${run}.????.fits.fz" | head -n 1 | awk -F/ '{print $6}') | ||
yyyy=${yyyymmdd:0:4} | ||
mm=${yyyymmdd:4:2} | ||
dd=${yyyymmdd:6:2} | ||
cmd="python submit_dqm_processor.py -d "${yyyy}-${mm}-${dd}" -r $run" | ||
echo "Running: $cmd" | ||
eval $cmd | ||
else | ||
echo " DQM job for run $run already submitted, either ongoing or failed, skipping it." | ||
fi | ||
else | ||
echo " Run $run is not yet complete on DIRAC, will wait another day before launching a DQM job on it." | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters