Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making CLMM conda instalable #651

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ This is a brief guide to contributing to CLMM, including information about ident
4. [Reviewing an open pull request](#reviewing_an_open_pull_request)
5. [Steps to merging a pull request](#steps_to_merging_a_pull_request)
6. [Updating Public Documentation on lsstdesc.org](#updating_public_docs)
7. [Additional resources](#additional_resources)
8. [Contact](#contact)
7. [Creating installation via pip and conda](#creating_pip_conda)
8. [Additional resources](#additional_resources)
9. [Contact](#contact)

## Identifying Issues <a name="identifying_issues"></a>

Expand Down Expand Up @@ -113,6 +114,48 @@ All these steps should be done on the `publish-docs` branch (just `git checkout
2. If you have figures in notebooks that you would like rendered on the website, you will want to execute all cells of demo notebooks.
3. From the `main` CLMM directory (the one that contains `setup.py`) run `./publish_docs` (note, this is different from `./update_docs` that you did in your development branch) and it does all of the work for you (including automatically pushing changes to Github)!

## Creating installation via pip and conda <a name="creating_pip_conda"></a>
After new changes to the main code have been made, you will want to update the existing clmm package at the Pypi repository to create an installation via `pip`. To do so, the following steps must be followed:
1. First, install the `hatch` package with pip with the following command:
```bash
pip install hatch
```
You can check [Publish your Python package with Hatch](https://www.pyopensci.org/python-package-guide/tutorials/publish-pypi.html) for more information.

2. In the `CLMM` repository, create the virtual environment with the command:
```bash
cd CLMM
hatch env create
```
3. If new packages are required as dependencies, add the packages to the `pyproject.toml` file in the repository in the dependencies section. The installation files will be generated from this file, so if any changes are required, look carefully inside the `pyproject.toml` file for the sections related to the changes.
4. Next, build the needed files for publication with the command:
```bash
hatch build
```
This will create a `clmm-1.14.4.tar.gz` and `clmm-1.14.4-py3-none-any.whl` files in the `dist` folder inside the repository. Note that the name of the files will change for the given version to be publicated.

5. To publish the package to pip, we will use `twine`, which should be installed with the following:
```bash
pip install twine
```
6. To make sure that the package is working properly, we can first publish `clmm` to `PypiTest` running the command:
```bash
twine upload --repository testpypi dist/* --verbose
```
Once the package is published, one can install it by running:
```bash
pip install -i https://test.pypi.org/simple/ clmm==1.14.4 --extra-index-url https://pypi.org/simple clmm==1.14.4
```
with the proper version number. This step will require an account at [PypiTest](https://test.pypi.org/) and you will need to generate a token that is required to publish packages. Note that some of the required dependencies may note be published to `PypiTest` and thus we need the extra index url to import the packages from `Pypi`. If the package was properly installed, we are now ready to publish it to `Pypi`.

7. To publish to `Pypi`, run the command:
```bash
twine upload dist/*
```
This last step must be done with the token used to publish `CLMM` from the right account at `Pypi`. Once this is done, you will find the latest version of `CLMM` at the `Pypi` repository. To test it, try running
```bash
pip install clmm
```
## Additional resources <a name="additional_resources"></a>

Here's a list of additional resources which you may find helpful in navigating git for the first time.
Expand Down
55 changes: 35 additions & 20 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@

# Installation instructions

* [Main readme](README.md)
We strongly recommend you make a new conda environment for the installation of CLMM so you can avoid conflicts with versions of
libraries used for other programs.
Here we present several ways to do it.

## Table of contents
1. [Basic installation](#basic_install)
2. [Access to the proper environment on cori.nersc.gov](#access_to_the_proper_environment_on_cori)
2. [Manual installation](#manual_install)
* [Setting up the proper environment on cori.nersc.gov](#access_to_the_proper_environment_on_cori)
3. [An alternative installation at NERSC or at CC-IN2P3 for DESC members](#from_desc_conda_env)
4. [Making a local copy of CLMM](#making_a_local_copy_of_clmm)


## Basic procedure <a name="basic_install"></a>

Here we provide a quick guide for a basic instalation, this will install all the packages in your current environment.
To create a specific conda environment for CLMM, we recommend you to check the begining of section
[Access to the proper environment on cori.nersc.gov](#access_to_the_proper_environment_on_cori).
These commands will create a new local environment ready for CLMM installation:

```bash
conda env create -f environment.yml
conda activate clmm
```

You can now install CLMM in a local and stable environment with the usual procedure.

## Manual procedure <a name="basic_install"></a>

Here we provide a quick guide for a maual instalation, this will install all the packages in your current environment.

To create your conda environment, run:

```bash
module load python # Also loads anaconda
conda create --name clmmenv # Create an anaconda environment for clmm
source activate clmmenv # switch to your newly created environment
```


Install some basic packages you will need:

```bash
conda install pip # need pip to install everything else necessary for clmm
conda install ipython # need to have the ipython tied to this environment
conda install -c conda-forge firefox # Need a browser to view jupyter notebooks
```

### Theory backend installation
First, choose and install a theory backend for CLMM.
Expand Down Expand Up @@ -65,18 +93,7 @@ Now, you can install CLMM and its dependencies as
python setup.py install # build from source
```

### Local environment for CLMM

Alternatively, you can create a new local environment by running

```bash
conda env create -f environment.yml
conda activate clmm
```

You can now install CLMM in a local and stable environment with the usual procedure.

## Access to the proper environment on cori.nersc.gov <a name="access_to_the_proper_environment_on_cori"></a>
### Setting up the proper environment on cori.nersc.gov <a name="access_to_the_proper_environment_on_cori"></a>

If you have access to NERSC, this will likely be the easiest to make sure you have the appropriate environment. After logging into cori.nersc.gov, you will need to execute the following. We recommend executing line-by-line to avoid errors:

Expand Down Expand Up @@ -154,5 +171,3 @@ If you do have edit privileges to CLMM, it may be easier to simply clone the bas
``` bash
git clone [email protected]:LSSTDESC/CLMM.git
```


36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CLMM
[![Build and Check](https://github.com/LSSTDESC/CLMM/workflows/Build%20and%20Check/badge.svg)](https://github.com/LSSTDESC/CLMM/actions?query=workflow%3A%22Build+and+Check%22)
[![Coverage Status](https://coveralls.io/repos/github/LSSTDESC/CLMM/badge.svg?branch=main)](https://coveralls.io/github/LSSTDESC/CLMM?branch=main)
[![Documentation](https://readthedocs.org/projects/clmm/badge/?version=latest)](http://lsstdesc.org/CLMM/)
[![DOI](https://img.shields.io/badge/DOI-10.3847%2F1538--4365%2Fab1658-B31B1B.svg)](https://doi.org/10.1093/mnras/stab2764)

The LSST-DESC Cluster Lensing Mass Modeling (CLMM) code is a DESC tool consisting of a Python library for performing galaxy cluster mass reconstruction from weak lensing observables. CLMM is associated with Key Tasks _DC1 SW+RQ_ and _DC2 SW_ of the LSST-DESC [Science Roadmap](https://lsstdesc.org/sites/default/files/DESC_SRM_V1_4.pdf) pertaining to absolute and relative mass calibration.
<!---CLMM is descended from [clmassmod](https://github.com/deapplegate/clmassmod) but distinguished by its modular structure and scope, which encompasses both simulated data sets with a known truth and observed data from which we aim to discover the truth.--->
Expand All @@ -17,9 +19,33 @@ link to this repository: https://github.com/LSSTDESC/CLMM. Please follow the gui

# Installing CLMM <a name="installing"></a>

CLMM can be installed with `pip` or `conda`.
There commands will install most of the dependencies for CLMM,
with the exception of the backend to be used on theoretical predictions,
check [this](#backends) section for details.

For a `pip` installation, run:

```bash
pip install clmm
```

For a `conda` installation, run:

```bash
conda install -c conda-forge clmm
```

We highly recommend you make a new conda environment for the installation of CLMM,
see [INSTALL documentation](INSTALL.md) for instructions on how to do it.

## Requirements <a name="requirements"></a>

CLMM requires Python version 3.8 or later. CLMM has the following dependencies:
CLMM requires Python version 3.8 or later.

### Dependencies <a name="dependencies"></a>

CLMM has the following dependencies:

- [NumPy](https://www.numpy.org/) (v1.17 or later)
- [SciPy](https://scipy.org/) (v1.6 or later)
Expand All @@ -31,6 +57,8 @@ CLMM requires Python version 3.8 or later. CLMM has the following dependencies:
pip install numpy scipy astropy matplotlib
```

### Back-ends <a name="backends"></a>

For the theoretical predictions of the signal, CLMM relies on existing libraries and **at least one of the following must be installed as well**:

- [cluster-toolkit](https://cluster-toolkit.readthedocs.io/en/latest/)
Expand All @@ -40,6 +68,8 @@ For the theoretical predictions of the signal, CLMM relies on existing libraries

(See the [INSTALL documentation](INSTALL.md) for more detailed installation instructions.)

### Developers <a name="developers"></a>

For developers, you will also need to install:

- [pytest](https://docs.pytest.org/en/latest/) (3.x or later for testing)
Expand All @@ -51,9 +81,9 @@ These are also pip installable:
```
Note, the last item, `sphinx_rtd_theme` is to make the docs.

## Installation <a name="installation"></a>
## Manual installation <a name="installation"></a>

To install CLMM you currently need to build it from source:
To install CLMM manually, you need to build it from source:

```
git clone https://github.com/LSSTDESC/CLMM.git
Expand Down
Binary file added dist/clmm-1.14.4-py3-none-any.whl
Binary file not shown.
Binary file added dist/clmm-1.14.4.tar.gz
Binary file not shown.
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.metadata]
allow-direct-references = true

[project]
name = "clmm"
dynamic = ["version"]
description = "A comprehensive package for galaxy cluster weak lensing"
readme = "README.md"
license = "bsd-3-clause"
requires-python = ">=3.8"
authors = [
{ name = "The LSST DESC CLMM Contributors" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
]
dependencies = [
"astropy>=4, !=5.0",
"matplotlib",
"numpy>=1.17",
"scipy>=1.3",
"healpy",
"qp-prob"
]



[project.urls]
Repository = "https://github.com/LSSTDESC/CLMM"

[tool.hatch.version]
path = "clmm/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/clmm",
]

[tool.black]
line-length = 100

Expand Down
Loading