Skip to content

Commit 6d0314e

Browse files
authored
Merge pull request #173 from LSSTDESC/doc-april2026
Start doc refresh
2 parents 3cf64a0 + baa9c4c commit 6d0314e

5 files changed

Lines changed: 236 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ Collection of DESC python environments and jupyter kernels
44
## Setup for use on the Command line
55
NERSC: ```source /global/common/software/lsst/common/miniconda/setup_current_python.sh```
66

7-
CC: ```source /pbs/throng/lsst/software/desc/common/miniconda/setup_current_python.sh```
7+
CC-IN2P3: ```source /pbs/throng/lsst/software/desc/common/miniconda/setup_current_python.sh```
88

9-
## [How to Add User Installed Packages To Your Environment](https://github.com/LSSTDESC/desc-python/wiki/Add-Packages-to-the-desc-python-environment)
9+
## Documentation
10+
See the [doc directory](./doc/) for guides and how-to documentation, including:
11+
- [How to Add User Installed Packages To Your Environment](./doc/Add-Packages-to-the-desc-python-environment.md)
12+
- [Add Your Own Packages to the desc stack Environment](./doc/Add-Your-Own-Packages-to-the-desc-stack-Environment.md)
1013

1114
## Initial User setup for Jupyter (Only need to do this once)
1215
See: https://confluence.slac.stanford.edu/display/LSSTDESC/Using+Jupyter+at+NERSC (Confluence log-in required)
@@ -20,5 +23,5 @@ See: https://confluence.slac.stanford.edu/display/LSSTDESC/Using+Jupyter+at+NERS
2023
## List of Packages Included in the desc-python Environment
2124
see [here](https://github.com/LSSTDESC/desc-python/blob/main/conda/lock/environment.yml) and [here](https://github.com/LSSTDESC/desc-python/blob/main/conda/lock/pyproject.toml)
2225

23-
[Current versions of all packages](https://github.com/LSSTDESC/desc-python/blob/main/conda/export/desc-python-nersc-2025-09-11-49-44.yml)
26+
[Current versions of all packages](https://github.com/LSSTDESC/desc-python/blob/main/conda/desc-py-lock.yml)
2427

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Complex Package Install Example (BATSim)
2+
3+
Example package: [BATSim](https://github.com/CMacM/BATSim)
4+
5+
Pip installation requires the GalSim C++ library
6+
7+
## Steps
8+
9+
How to pip install BATSim against the desc-stack[-weekly-latest] container?
10+
11+
1. Initialize your user package area and start the environment.
12+
13+
```bash
14+
mkdir "$PSCRATCH/mypackages"
15+
export DESCSTACKUSERBASE="$PSCRATCH/mypackages"
16+
python /global/common/software/lsst/common/miniconda/start-kernel-cli.py desc-stack-weekly-latest
17+
unset PYTHONNOUSERSITE
18+
```
19+
20+
2. Check the version of GalSim already installed in the container.
21+
22+
```bash
23+
conda list galsim
24+
```
25+
26+
For this example, the expected version is `galsim 2.8.3`.
27+
28+
3. Build/install the matching GalSim sources.
29+
30+
```bash
31+
cd "$DESCSTACKUSERBASE"
32+
git clone https://github.com/GalSim-developers/GalSim.git
33+
cd GalSim
34+
git checkout v2.8.3 # matching the version in the container
35+
export FFTW_DIR="$CONDA_PREFIX"
36+
export EIGEN_DIR="$CONDA_PREFIX/include/eigen3"
37+
python setup.py build_shared_clib
38+
python3 -m pip install --user --no-build-isolation .
39+
cp "$DESCSTACKUSERBASE"/GalSim/build/shared_clib/*.so "$DESCSTACKUSERBASE"/lib/python3.13/site-packages/galsim
40+
```
41+
42+
4. Install BATSim with the required include/library environment variables.
43+
44+
```bash
45+
cd "$DESCSTACKUSERBASE"
46+
git clone https://github.com/CMacM/BATSim.git
47+
cd BATSim
48+
export LD_LIBRARY_PATH="$DESCSTACKUSERBASE/lib/python3.13/site-packages/galsim:$LD_LIBRARY_PATH"
49+
export LIBRARY_PATH="$DESCSTACKUSERBASE/lib/python3.13/site-packages/galsim:$LIBRARY_PATH"
50+
export CPLUS_INCLUDE_PATH="$(python -c "import galsim, os; print(os.path.join(os.path.dirname(galsim.__file__), 'include'))"):$CPLUS_INCLUDE_PATH"
51+
python3 -m pip install --user --no-build-isolation .
52+
```
53+
54+
## Persist for Jupyter
55+
56+
To use this new installation of BATSim in jupyter.nersc.gov, add this to `$HOME/.bashrc`:
57+
58+
```bash
59+
export DESCSTACKUSERBASE=$PSCRATCH/mypackages
60+
```

doc/Add-Packages-desc-python.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
```

doc/Add-Packages-desc-stack.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add Packages to the desc-stack 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-stack (or desc-stack-weekly or desc-stack-weekly-latest).
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 and/or desc-stack by [opening an issue in desc-help](https://github.com/LSSTDESC/desc-help/issues).
8+
9+
## To add package(s) locally to your desc-stack environment
10+
Create a directory to store the installation artifacts associated with your new packages, create the DESCSTACKUSERBASE environment variable and then pip install the packages you wish to add.
11+
* ```
12+
cd $SCRATCH # I just chose SCRATCH.. you could use another area
13+
mkdir <yourInstallArea>
14+
export DESCSTACKUSERBASE=$PWD/<yourInstallArea> # This env var is recognized by the desc-stack-weekly setup, so --user installs will use this dir
15+
# For desc-python, use DESCPYTHONUSERAREA. For desc-python-bleed, use DESCPYTHONBLEEDUSERBASE
16+
python /global/common/software/lsst/common/miniconda/start-kernel-cli.py desc-stack-weekly
17+
unset PYTHONNOUSERSITE
18+
pip install --user --no-build-isolation <NewPackage>
19+
```
20+
To enable your installed packages the next time you set up desc-stack-weekly in Jupyter or on the command line, you will need to set the following in your $HOME/.bashrc:
21+
22+
```
23+
export DESCSTACKUSERBASE=<fullPathtoYourInstallArea>
24+
```
25+

doc/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# DESC Python Wiki Pages
2+
3+
This directory contains Markdown pages imported from the GitHub wiki:
4+
https://github.com/LSSTDESC/desc-python/wiki
5+
6+
## Index
7+
8+
- [Add Packages to the desc-python environment](Add-Packages-desc-python.md)
9+
- [Add Packages to the desc-stack environment](Add-Packages-desc-stack.md)
10+
- [Complex install example (BATSim)](Add-Packages-Complex-Install.md)

0 commit comments

Comments
 (0)