From d4fda8d2fb8400fa6cb11f2a0e8840fd2c65c8a2 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Wed, 20 Apr 2022 11:28:25 +0100 Subject: [PATCH] Use env_cache with pyenv to get environment for specified Python version --- setup.py | 1 + src/xfel_calibrate/repeat.py | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 9f91ce5d9..901698b3c 100644 --- a/setup.py +++ b/setup.py @@ -58,6 +58,7 @@ install_requires = [ "dill==0.3.0", "docutils==0.17.1", "dynaconf==3.1.4", + "env_cache==0.1", "extra_data==1.11.0", "extra_geom==1.6.0", "gitpython==3.1.0", diff --git a/src/xfel_calibrate/repeat.py b/src/xfel_calibrate/repeat.py index 7f43cd4d2..564968826 100644 --- a/src/xfel_calibrate/repeat.py +++ b/src/xfel_calibrate/repeat.py @@ -5,7 +5,7 @@ from datetime import datetime from pathlib import Path import nbformat -from env_cache import EnvsManager, FixedPythonEnvMaker +from env_cache import EnvsManager, PyenvEnvMaker from nbparameterise import extract_parameters, parameter_values, replace_definitions from cal_tools.tools import CalibrationMetadata @@ -33,10 +33,10 @@ def new_report_path(old_out_folder, old_report_path, new_out_folder): return str(Path(new_out_folder, report_in_output)) def get_python(args, py_version): - if args.env_from_python: + if args.env_cache: reqs = (args.from_dir / 'requirements.txt').read_text() env_mgr = EnvsManager( - Path(temp_path, 'envs'), FixedPythonEnvMaker(args.env_from_python) + Path(args.env_cache), PyenvEnvMaker() ) return env_mgr.get_env(py_version, reqs) / 'bin' / 'python' elif args.python: @@ -50,9 +50,10 @@ def main(argv=None): env_args = ap.add_mutually_exclusive_group() env_args.add_argument("--python", help="Path to Python executable to run notebooks") env_args.add_argument( - "--env-from-python", - help="Make a virtualenv from this Python & install the library versions" - " these notebooks previously used" + "--env-cache", + help="Make/reuse a virtualenv in this cache directory with the Python " + "version & library versions these notebooks previously used. " + "This requires the pyenv command to be available." ) ap.add_argument("--out-folder", help="Directory to put output data") ap.add_argument("--slurm-partition", help="Submit jobs in this Slurm partition") -- GitLab