diff --git a/bootstrap.sh b/bootstrap.sh index 31079b5..9ea6792 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +LPC_CONDOR_CONFIG=/etc/condor/config.d/01_cmslpc_interactive +LPC_CONDOR_LOCAL=/usr/local/bin/cmslpc-local-conf.py + cat < shell #!/usr/bin/env bash @@ -18,15 +21,18 @@ else export COFFEA_IMAGE=\$1 fi -grep -v '^include' /etc/condor/config.d/01_cmslpc_interactive > .condor_config - -export APPTAINER_BINDPATH=/uscmst1b_scratch,/cvmfs,/cvmfs/grid.cern.ch/etc/grid-security:/etc/grid-security +export APPTAINER_BINDPATH=${APPTAINER_BINDPATH}${APPTAINER_BINDPATH:+,}/uscmst1b_scratch,/cvmfs,/cvmfs/grid.cern.ch/etc/grid-security:/etc/grid-security,${LPC_CONDOR_CONFIG},${LPC_CONDOR_LOCAL}:${LPC_CONDOR_LOCAL}.orig,.cmslpc-local-conf:${LPC_CONDOR_LOCAL} APPTAINER_SHELL=\$(which bash) apptainer exec -B \${PWD}:/srv --pwd /srv \\ /cvmfs/unpacked.cern.ch/registry.hub.docker.com/\${COFFEA_IMAGE} \\ /bin/bash --rcfile /srv/.bashrc EOF +cat < .cmslpc-local-conf +#!/bin/bash +python3 ${LPC_CONDOR_LOCAL}.orig | grep -v "LOCAL_CONFIG_FILE" +EOF + cat < .bashrc LPCJQ_VERSION="0.3.1" install_env() { @@ -40,8 +46,10 @@ install_env() { rm -rf \$TMPDIR && unset TMPDIR .env/bin/python -m pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION} echo "done." + set +e } +export CONDOR_CONFIG=${LPC_CONDOR_CONFIG} export JUPYTER_PATH=/srv/.jupyter export JUPYTER_RUNTIME_DIR=/srv/.local/share/jupyter/runtime export JUPYTER_DATA_DIR=/srv/.local/share/jupyter @@ -54,5 +62,5 @@ alias pip="python -m pip" pip show lpcjobqueue 2>/dev/null | grep -q "Version: \${LPCJQ_VERSION}" || pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION} EOF -chmod u+x shell .bashrc +chmod u+x shell .bashrc .cmslpc-local-conf echo "Wrote shell and .bashrc to current directory. You can delete this file. Run ./shell to start the apptainer shell" diff --git a/src/lpcjobqueue/schedd.py b/src/lpcjobqueue/schedd.py index 1351422..d1ddd05 100644 --- a/src/lpcjobqueue/schedd.py +++ b/src/lpcjobqueue/schedd.py @@ -5,10 +5,12 @@ import re logger = logging.getLogger(__name__) -os.environ["CONDOR_CONFIG"] = os.path.join("/srv/.condor_config") -if not os.path.isfile(os.environ['CONDOR_CONFIG']): - logger.warn(f"Condor configuration not found! run the following command outside the apptainer instance") - logger.warn(f"grep -v '^include' /etc/condor/config.d/01_cmslpc_interactive > .condor_config") +if "CONDOR_CONFIG" not in os.environ or not os.path.isfile(os.environ["CONDOR_CONFIG"]): + raise RuntimeError( + f"Condor configuration {os.environ.get('CONDOR_CONFIG', '')} not found!\n" + "Please download and run bootstrap.sh again to update the shell with:\n" + "curl -OL https://raw.githubusercontent.com/CoffeaTeam/lpcjobqueue/main/bootstrap.sh; bash bootstrap.sh" + ) import htcondor # noqa: E402