Skip to content
Snippets Groups Projects
Commit 910f9d79 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Rely on path/to/python -m for IPython, ipyparallel & nbconvert

parent 485a9a45
No related branches found
No related tags found
1 merge request!350Simplify how batch jobs find Python tools
...@@ -50,14 +50,6 @@ Clone from git:: ...@@ -50,14 +50,6 @@ Clone from git::
git clone https://git.xfel.eu/gitlab/detectors/pycalibration.git git clone https://git.xfel.eu/gitlab/detectors/pycalibration.git
cd pycalibration cd pycalibration
Edit path to the python environment in the bin/activate.sh file. Change::
export PATH=/home/${USER}/.local/bin:$PATH
to::
export PATH=/path/to/new/virtual/environment/bin:$PATH
Install the package:: Install the package::
pip install -r requirements.txt pip install -r requirements.txt
......
source /etc/profile.d/modules.sh
module load anaconda/3
module load texlive/2019
# export path to python environment
export PATH=$HOME/.local/bin:$PATH
...@@ -3,24 +3,18 @@ ...@@ -3,24 +3,18 @@
# set paths to use # set paths to use
nb_path=$1 nb_path=$1
python_path=$2 python_path=$2
ipython_path=$3 activate_path=$3
jupyter_path=$4 uuid=$4
ipcluster_path="${5}" notebook=$5
activate_path=$6 detector=$6
uuid=$7 caltype=${7}
notebook=$8 final=${8}
detector=$9 finalize=${9}
caltype=${10} cluster_cores=${10}
final=${11}
finalize=${12}
cluster_cores=${13}
echo "Running with the following parameters:" echo "Running with the following parameters:"
echo "Notebook path: $nb_path" echo "Notebook path: $nb_path"
echo "Python path: $python_path" echo "Python path: $python_path"
echo "IPython path: $ipython_path"
echo "Jupyter path: $jupyter_path"
echo "IP-Cluster path: $ipcluster_path"
echo "Environment activate: $activate_path" echo "Environment activate: $activate_path"
echo "IP-Cluster profile: $uuid" echo "IP-Cluster profile: $uuid"
echo "notebook: $notebook" echo "notebook: $notebook"
...@@ -45,20 +39,20 @@ export MPLBACKEND=AGG ...@@ -45,20 +39,20 @@ export MPLBACKEND=AGG
# start an ip cluster if requested # start an ip cluster if requested
if [ "${uuid}" != "NO_CLUSTER" ] if [ "${uuid}" != "NO_CLUSTER" ]
then then
${ipython_path} profile create ${uuid} --parallel ${python_path} -m IPython profile create ${uuid} --parallel
${ipcluster_path} start --n=${cluster_cores} --profile=${uuid} --daemon & ${python_path} -m ipyparallel.cluster start --n=${cluster_cores} --profile=${uuid} --daemon &
sleep 15 sleep 15
fi fi
echo "Running script" echo "Running script"
${jupyter_path} nbconvert --to rst --ExecutePreprocessor.timeout=36000 --ExecutePreprocessor.allow_errors=True --TemplateExporter.exclude_input=True --execute ${nb_path} ${python_path} -m nbconvert --to rst --ExecutePreprocessor.timeout=36000 --ExecutePreprocessor.allow_errors=True --TemplateExporter.exclude_input=True --execute ${nb_path}
# stop the cluster if requested # stop the cluster if requested
if [ "${uuid}" != "NO_CLUSTER" ] if [ "${uuid}" != "NO_CLUSTER" ]
then then
${ipcluster_path} stop --profile=${uuid} ${python_path} -m ipyparallel.cluster stop --profile=${uuid}
profile_path=`${ipython_path} locate profile ${uuid}` profile_path=$(${python_path} -m IPython locate profile ${uuid})
echo "Removing cluster profile from: $profile_path" echo "Removing cluster profile from: $profile_path"
rm -rf $profile_path rm -rf $profile_path
fi fi
......
...@@ -653,9 +653,6 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None, ...@@ -653,9 +653,6 @@ def concurrent_run(temp_path, nb, nbname, args, cparm=None, cval=None,
srun_base += [os.path.join(PKG_DIR, "bin", "slurm_calibrate.sh"), # path to helper sh srun_base += [os.path.join(PKG_DIR, "bin", "slurm_calibrate.sh"), # path to helper sh
os.path.abspath(nbpath), # path to notebook os.path.abspath(nbpath), # path to notebook
python_path, # path to python python_path, # path to python
ipython_path, # path to ipython
jupyter_path, # path to jupyter
ipcluster_path, # path to ipcluster
# python activate path # python activate path
activate_path if activate_path!="" else os.path.join(PKG_DIR, "bin", "activate.sh"), activate_path if activate_path!="" else os.path.join(PKG_DIR, "bin", "activate.sh"),
args.get("cluster_profile", "NO_CLUSTER"), args.get("cluster_profile", "NO_CLUSTER"),
......
import os import os
import sys
# path into which temporary files from each run are placed # path into which temporary files from each run are placed
temp_path = os.path.abspath("temp/") temp_path = os.path.abspath("temp/")
# Path to use for calling Python. If the environment is correctly set, simply the command # Path to use for calling Python. If the environment is correctly set, simply the command
python_path = "python" python_path = sys.executable
# Path to use for calling iPython. If the environment is correctly set, simply the command
ipython_path = "ipython"
# Path to use for calling Jupyter. If the environment is correctly set, simply the command
jupyter_path = "jupyter"
# Path to find activate script # Path to find activate script
activate_path = "" activate_path = ""
# Path to use for calling ipcluster. If the environment is correctly set, simply the command
ipcluster_path = "ipcluster"
# Path to store reports in # Path to store reports in
report_path = "{}/calibration_reports/".format(os.getcwd()) report_path = "{}/calibration_reports/".format(os.getcwd())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment