From 910f9d79a467d131e7f30f80964ccf7673a96ce2 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Wed, 9 Sep 2020 16:30:37 +0100 Subject: [PATCH] Rely on path/to/python -m for IPython, ipyparallel & nbconvert --- README.rst | 8 -------- bin/activate.sh | 5 ----- bin/slurm_calibrate.sh | 32 +++++++++++++------------------- xfel_calibrate/calibrate.py | 3 --- xfel_calibrate/settings.py | 12 ++---------- 5 files changed, 15 insertions(+), 45 deletions(-) delete mode 100644 bin/activate.sh diff --git a/README.rst b/README.rst index b62b5285b..6328ee618 100644 --- a/README.rst +++ b/README.rst @@ -50,14 +50,6 @@ Clone from git:: git clone https://git.xfel.eu/gitlab/detectors/pycalibration.git 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:: pip install -r requirements.txt diff --git a/bin/activate.sh b/bin/activate.sh deleted file mode 100644 index 8c8a0500e..000000000 --- a/bin/activate.sh +++ /dev/null @@ -1,5 +0,0 @@ -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 diff --git a/bin/slurm_calibrate.sh b/bin/slurm_calibrate.sh index 44be0e93e..d5e87ebc3 100755 --- a/bin/slurm_calibrate.sh +++ b/bin/slurm_calibrate.sh @@ -3,24 +3,18 @@ # set paths to use nb_path=$1 python_path=$2 -ipython_path=$3 -jupyter_path=$4 -ipcluster_path="${5}" -activate_path=$6 -uuid=$7 -notebook=$8 -detector=$9 -caltype=${10} -final=${11} -finalize=${12} -cluster_cores=${13} +activate_path=$3 +uuid=$4 +notebook=$5 +detector=$6 +caltype=${7} +final=${8} +finalize=${9} +cluster_cores=${10} echo "Running with the following parameters:" echo "Notebook path: $nb_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 "IP-Cluster profile: $uuid" echo "notebook: $notebook" @@ -45,20 +39,20 @@ export MPLBACKEND=AGG # start an ip cluster if requested if [ "${uuid}" != "NO_CLUSTER" ] then - ${ipython_path} profile create ${uuid} --parallel - ${ipcluster_path} start --n=${cluster_cores} --profile=${uuid} --daemon & + ${python_path} -m IPython profile create ${uuid} --parallel + ${python_path} -m ipyparallel.cluster start --n=${cluster_cores} --profile=${uuid} --daemon & sleep 15 fi 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 if [ "${uuid}" != "NO_CLUSTER" ] then - ${ipcluster_path} stop --profile=${uuid} - profile_path=`${ipython_path} locate profile ${uuid}` + ${python_path} -m ipyparallel.cluster stop --profile=${uuid} + profile_path=$(${python_path} -m IPython locate profile ${uuid}) echo "Removing cluster profile from: $profile_path" rm -rf $profile_path fi diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py index 8bdbdbe15..352c4ca3b 100755 --- a/xfel_calibrate/calibrate.py +++ b/xfel_calibrate/calibrate.py @@ -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 os.path.abspath(nbpath), # path to notebook python_path, # path to python - ipython_path, # path to ipython - jupyter_path, # path to jupyter - ipcluster_path, # path to ipcluster # python activate path activate_path if activate_path!="" else os.path.join(PKG_DIR, "bin", "activate.sh"), args.get("cluster_profile", "NO_CLUSTER"), diff --git a/xfel_calibrate/settings.py b/xfel_calibrate/settings.py index cbe4c21b6..78c3053e7 100644 --- a/xfel_calibrate/settings.py +++ b/xfel_calibrate/settings.py @@ -1,23 +1,15 @@ import os +import sys # path into which temporary files from each run are placed temp_path = os.path.abspath("temp/") # Path to use for calling Python. If the environment is correctly set, simply the command -python_path = "python" - -# 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" +python_path = sys.executable # Path to find activate script 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 report_path = "{}/calibration_reports/".format(os.getcwd()) -- GitLab