|
| 1 | +# Add Packages to the desc-python Environment |
| 2 | + |
| 3 | +If you are new to DESC and DESC python environments, please consult our related documentation for [NERSC](https://confluence.slac.stanford.edu/display/LSSTDESC/Getting+Started+at+NERSC) or [IN2P3](https://doc.lsst.eu/). |
| 4 | + |
| 5 | +You may have additional packages or an updated version of a package that you want to install alongside desc-python. |
| 6 | + |
| 7 | +* If this is a package of general interest, please consult within your Working Groups and then request the package be added to desc-python by [opening an issue in desc-help](https://github.com/LSSTDESC/desc-help/issues). |
| 8 | + |
| 9 | +## First way to install additional package(s) for use with desc-python |
| 10 | +``` |
| 11 | +cd $SCRATCH # I just chose SCRATCH.. you could use another area |
| 12 | +mkdir <yourInstallArea> |
| 13 | +export DESCPYTHONUSERBASE=$PWD/<yourInstallArea> # This env var is recognized by the desc-python setup, so --user installs will use this dir |
| 14 | +# For desc-python-bleed, use DESCPYTHONBLEEDUSERBASE. For desc-stack-weekly or desc-stack-weekly-latest, use DESCSTACKUSERBASE |
| 15 | +python /global/common/software/lsst/common/miniconda/start-kernel-cli.py desc-python |
| 16 | +unset PYTHONNOUSERSITE |
| 17 | +pip install --user --no-build-isolation <NewPackage> |
| 18 | +``` |
| 19 | +If you are updating a package already available in the conda environment, include the `-U` option: |
| 20 | +``` |
| 21 | +pip install --user --no-build-isolation -U <NewPackage> |
| 22 | +``` |
| 23 | +If you are installing a package from source code rather than from PyPI, first obtain a copy of the source code, enter the package directory and pip install by doing: |
| 24 | +``` |
| 25 | +python3 -m pip install --user --no-build-isolation . |
| 26 | +``` |
| 27 | + |
| 28 | +To enable your installed packages the next time you set up desc-python in Jupyter or on the command line, you will need to set the following in your $HOME/.bashrc: |
| 29 | +``` |
| 30 | +export DESCPYTHONUSERBASE=<fullPathtoYourInstallArea> |
| 31 | +``` |
| 32 | + |
| 33 | +## Another way to install package(s): create your own conda environment |
| 34 | + |
| 35 | +* Create a full clone of the `desc-python` environment in your own area (this will take a few minutes) |
| 36 | + * ``` |
| 37 | + python /global/common/software/lsst/common/miniconda/start-kernel-cli.py desc-python |
| 38 | + conda create --clone base -p <PathToYourDir>/mydesc |
| 39 | + ``` |
| 40 | + * Activate your new environment and add your desired packages |
| 41 | + ``` |
| 42 | + conda activate <PathToYourDir>/mydesc |
| 43 | + mamba install <Your Package> OR pip install <Your Package> OR mamba install <Your Package> |
| 44 | + ``` |
| 45 | +
|
| 46 | +* To enable your cloned environment automatically when using the desc-python env, including when using Jupyter at NERSC, you need to set up an environment variable in your NERSC `$HOME/.bashrc` or `$HOME/.cshrc`. |
| 47 | +If using bash, you would add this to your $HOME/.bashrc (create this file if it does not already exist): |
| 48 | +
|
| 49 | +`export DESCUSERENV=<FullPathToYourCondaEnv>` |
| 50 | +
|
| 51 | +Example: |
| 52 | +
|
| 53 | +`export DESCUSERENV=/global/common/software/lsst/users/heatherk/mydesc` |
| 54 | +
|
| 55 | +With the `DESCUSERENV` environment variable set, the next time you start the `desc-python` jupyter kernel, you will be using your own environment, rather than the official `desc-python`. |
| 56 | +
|
| 57 | +**NOTE:** If you have previously set `DESCPYTHONPATH`, it is strongly recommended that you remove the `DESCPYTHONPATH` environment variable from your `$HOME/.bashrc` (or `$HOME/.bashrc.ext`). |
| 58 | +
|
| 59 | +Here is a full concrete example at NERSC |
| 60 | +
|
| 61 | +``` |
| 62 | +python /global/common/software/lsst/common/miniconda/start-kernel-cli.py desc-python |
| 63 | +conda create --clone base -p /global/common/software/lsst/users/heatherk/mydesc |
| 64 | +conda activate /global/common/software/lsst/users/heatherk/mydesc |
| 65 | +mamba install -c conda-forge astrocats |
| 66 | +``` |
| 67 | +Now your package(s) are installed in your personal desc conda environment: |
| 68 | +* Set up the `DESCUSERENV` environment variable, then you can enable your desc conda env by doing: |
| 69 | +``` |
| 70 | +python /global/common/software/lsst/common/miniconda/start-kernel-cli.py desc-python |
| 71 | +``` |
| 72 | +* If you later decide to ignore or discard your desc conda environment, just unset `DESCUSERENV` and the next time you enable `desc-python` you will be using the default desc conda environment. |
| 73 | +
|
| 74 | +### Example: Installing Firecrown |
| 75 | +
|
| 76 | +Assuming you have already set up your own desc conda environment, and set your DESCUSERENV env variable, you can add any additional packages by doing: |
| 77 | +
|
| 78 | +``` |
| 79 | +python /global/common/software/lsst/common/miniconda/start-kernel-cli.py desc-python |
| 80 | +mamba install -c conda-forge firecrown |
| 81 | +``` |
| 82 | +
|
| 83 | +Now I have firecrown installed in my own `mydesc` conda environment. To give it a try, I need the examples available in the firecrown git repo, so I clone it into my own area: |
| 84 | +``` |
| 85 | +cd /global/common/software/lsst/users/heatherk |
| 86 | +git clone https://github.com/LSSTDESC/firecrown |
| 87 | +``` |
| 88 | +Then I try a simple example: |
| 89 | +``` |
| 90 | +cd firecrown/examples/des_y1_3x2pt |
| 91 | +firecrown compute des_y1_3x2pt.yaml |
| 92 | +Watch out! Here comes a firecrown! |
| 93 | +analysis id: 190918deca4946d8879ac0b3c3d19232 |
| 94 | +loglike: -236.47695322891724 |
| 95 | +``` |
| 96 | +
|
| 97 | +A similar example starting from the default desc-python environment at CC: |
| 98 | +
|
| 99 | +```bash |
| 100 | +source /pbs/throng/lsst/software/desc/common/miniconda/setup_current_python.sh |
| 101 | +conda create --clone desc --prefix="$PWD/mydesc" |
| 102 | +conda activate /pbs/home/h/hkelly/mydesc |
| 103 | +pip install git+https://github.com/LSSTDESC/firecrown.git |
| 104 | +``` |
| 105 | + |
| 106 | +The shell prompt changes shown in the original transcript are omitted here for readability. |
| 107 | + |
| 108 | +Now I have firecrown installed in my own `mydesc` conda environment. To give it a try, I need the examples available in the firecrown git repo, so I clone it into my own area: |
| 109 | +``` |
| 110 | +git clone https://github.com/LSSTDESC/firecrown |
| 111 | +``` |
| 112 | +Then I try a simple example, first starting up an interactive session on a compute node: |
| 113 | + |
| 114 | +```bash |
| 115 | +qlogin -l sps=1,s_fsize=1G,s_cpu=1:00:00,s_rss=1G |
| 116 | +source /pbs/throng/lsst/software/desc/common/miniconda/setup_current_python.sh |
| 117 | +conda activate /pbs/home/h/hkelly/mydesc |
| 118 | +cd firecrown/examples/des_y1_3x2pt |
| 119 | +firecrown compute des_y1_3x2pt.yaml |
| 120 | +``` |
| 121 | + |
| 122 | +Example output: |
| 123 | + |
| 124 | +```text |
| 125 | +Watch out! Here comes a firecrown! |
| 126 | +analysis id: 190918deca4946d8879ac0b3c3d19232 |
| 127 | +loglike: -236.47695322891724 |
| 128 | +``` |
| 129 | +## Developer mode (not thoroughly checked) |
| 130 | +If a package is included in a cloned env, the logical steps would be |
| 131 | +``` |
| 132 | +conda uninstall <package> --force |
| 133 | +git clone <package> |
| 134 | +cd <package> && pip install --no-deps -e . |
| 135 | +``` |
0 commit comments