Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| technical:recipes:emcee-in-virtualenv [2020-07-16 10:25] – created frey | technical:recipes:emcee-in-virtualenv [2021-02-24 23:45] (current) – frey | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Python Virtualenv: emcee and pyKLIP ====== | ||
| + | Some portions of this recipe are specific to the IT-RCI HPC clusters (VALET-based environment setup) but otherwise should work on any system. | ||
| + | |||
| + | ===== Preparations ===== | ||
| + | |||
| + | Choose a directory in which to install the one (or more) virtual environments (virtualenvs). | ||
| + | |||
| + | * If setting-up this virtualenv for multiple users in the workgroup, choose '' | ||
| + | * If this virtualenv is solely for personal use, choose '' | ||
| + | |||
| + | Note that these examples assume a standard workgroup storage layout with group-writable '' | ||
| + | |||
| + | <code bash> | ||
| + | $ mkdir " | ||
| + | </ | ||
| + | |||
| + | The virtualenv will be created using Intel' | ||
| + | |||
| + | <code bash> | ||
| + | $ vpkg_require intel-python/ | ||
| + | </ | ||
| + | |||
| + | Make note of these two package identifiers: | ||
| + | |||
| + | ===== Versioning ===== | ||
| + | |||
| + | In order to maintain one or more distinct instances of the '' | ||
| + | |||
| + | ===== Create the Virtualenv ===== | ||
| + | |||
| + | Use the '' | ||
| + | |||
| + | <code bash> | ||
| + | $ conda create --prefix=" | ||
| + | </ | ||
| + | |||
| + | The basic dependencies do not require an extensive list of other packages, most notably the '' | ||
| + | |||
| + | <code bash> | ||
| + | $ source activate " | ||
| + | $ which pip | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ===== Update and Install Other Packages ===== | ||
| + | |||
| + | For the sake of the '' | ||
| + | |||
| + | <code bash> | ||
| + | $ pip install -U setuptools setuptools_scm pep517 pytest | ||
| + | </ | ||
| + | |||
| + | The '' | ||
| + | |||
| + | <code bash> | ||
| + | $ pip install --no-binary :all: mpi4py corner image_registration git+https:// | ||
| + | </ | ||
| + | |||
| + | The '' | ||
| + | |||
| + | ===== Install pyKLIP ===== | ||
| + | |||
| + | The '' | ||
| + | |||
| + | Rather than using the head of the git source tree -- corresponding to ongoing revisions/ | ||
| + | |||
| + | <code bash> | ||
| + | $ git clone https:// | ||
| + | $ cd pyklip-src | ||
| + | $ git checkout v2.1 | ||
| + | </ | ||
| + | |||
| + | Installation into the virtualenv proceeds simply: | ||
| + | |||
| + | <code bash> | ||
| + | $ python setup.py install | ||
| + | </ | ||
| + | |||
| + | Followed by removal of the cloned source: | ||
| + | |||
| + | <code bash> | ||
| + | $ cd .. | ||
| + | $ rm -rf pyklip-src | ||
| + | </ | ||
| + | |||
| + | ===== Completed virtualenv ===== | ||
| + | |||
| + | At this point the packages present in the completed virtualenv can be listed: | ||
| + | |||
| + | <code bash> | ||
| + | $ pip list | ||
| + | Package | ||
| + | ------------------ ------------------- | ||
| + | astropy | ||
| + | certifi | ||
| + | corner | ||
| + | cycler | ||
| + | debrisdiskfm | ||
| + | emcee 3.0.2 | ||
| + | FITS-tools | ||
| + | gqueue | ||
| + | image-registration 0.2.4 | ||
| + | kiwisolver | ||
| + | matplotlib | ||
| + | mkl-fft | ||
| + | mkl-random | ||
| + | mkl-service | ||
| + | mpi4py | ||
| + | numpy 1.18.5 | ||
| + | pep517 | ||
| + | pip 20.1.1 | ||
| + | pyklip | ||
| + | pyparsing | ||
| + | python-dateutil | ||
| + | schwimmbad | ||
| + | scipy 1.5.0 | ||
| + | setuptools | ||
| + | setuptools-scm | ||
| + | sip 4.19.13 | ||
| + | six 1.15.0 | ||
| + | toml | ||
| + | tornado | ||
| + | wheel 0.34.2 | ||
| + | </ | ||
| + | |||
| + | Version numbers may differ as newer versions of the component packages are released, but at the very least the | ||
| + | * emcee | ||
| + | * debrisdiskfm | ||
| + | * schwimmbad | ||
| + | * astropy | ||
| + | * matplotlib | ||
| + | * numpy | ||
| + | * pyklip | ||
| + | packages should all be present in the list. | ||
| + | |||
| + | Return the shell environment to its original state before proceeding: | ||
| + | |||
| + | <code bash> | ||
| + | $ vpkg_rollback all | ||
| + | </ | ||
| + | |||
| + | ===== VALET Package Definition ===== | ||
| + | |||
| + | To simplify the addition of this virtualenv to the runtime environment, | ||
| + | |||
| + | The package definition file uses the [[https:// | ||
| + | |||
| + | ^Item^Description^Value in this example^ | ||
| + | |'' | ||
| + | |'' | ||
| + | |'' | ||
| + | |'' | ||
| + | |||
| + | The package definition file should follow this format: | ||
| + | |||
| + | <code yaml> | ||
| + | «env-name»: | ||
| + | prefix: «prefix»/ | ||
| + | description: | ||
| + | flags: | ||
| + | - no-standard-paths | ||
| + | default-version: | ||
| + | actions: | ||
| + | - action: source | ||
| + | script: | ||
| + | sh: anaconda-activate.sh | ||
| + | success: 0 | ||
| + | versions: | ||
| + | " | ||
| + | description: | ||
| + | dependencies: | ||
| + | - openmpi/ | ||
| + | - intel-python/ | ||
| + | </ | ||
| + | |||
| + | For the virtualenv created in the course of this recipe, the resulting file '' | ||
| + | |||
| + | <code yaml> | ||
| + | mcmc-env: | ||
| + | prefix: / | ||
| + | description: | ||
| + | flags: | ||
| + | - no-standard-paths | ||
| + | default-version: | ||
| + | actions: | ||
| + | - action: source | ||
| + | script: | ||
| + | sh: anaconda-activate.sh | ||
| + | success: 0 | ||
| + | versions: | ||
| + | " | ||
| + | description: | ||
| + | dependencies: | ||
| + | - openmpi/ | ||
| + | - intel-python/ | ||
| + | </ | ||
| + | |||
| + | The file can be checked for proper syntax: | ||
| + | |||
| + | <code bash> | ||
| + | $ vpkg_check " | ||
| + | </ | ||
| + | |||
| + | If all is okay, then the virtualenv can be loaded in login sessions or in job scripts as: | ||
| + | |||
| + | <code bash> | ||
| + | $ vpkg_require «env-name»/ | ||
| + | </ | ||
| + | |||
| + | which for this recipe is: | ||
| + | |||
| + | <code bash> | ||
| + | $ vpkg_require mcmc-env/ | ||
| + | Adding dependency `libfabric/ | ||
| + | Adding dependency `openmpi/ | ||
| + | Adding dependency `intel-python/ | ||
| + | Adding package `mcmc-env/ | ||
| + | $ which python3 | ||
| + | / | ||
| + | $ which pip | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Adding New Instances of the virtualenv ==== | ||
| + | |||
| + | Each new instance of the virtualenv will receive a unique version identifier prior to being created. | ||
| + | |||
| + | <code yaml> | ||
| + | mcmc-env: | ||
| + | prefix: / | ||
| + | description: | ||
| + | flags: | ||
| + | - no-standard-paths | ||
| + | default-version: | ||
| + | actions: | ||
| + | - action: source | ||
| + | script: | ||
| + | sh: anaconda-activate.sh | ||
| + | success: 0 | ||
| + | versions: | ||
| + | " | ||
| + | description: | ||
| + | dependencies: | ||
| + | - openmpi/ | ||
| + | - intel-python/ | ||
| + | " | ||
| + | description: | ||
| + | dependencies: | ||
| + | - openmpi/ | ||
| + | - intel-python/ | ||
| + | </ | ||
| + | |||
| + | where the dependencies will change if different versions of the Open MPI library or Intel distribution for Python were used when creating the virtualenv. | ||
| + | |||
| + | If the new version should be promoted to being the default (e.g. when '' | ||