Skip to content

Pyproject.toml-based installation, updated dependencies, and automatic Docker builds #144

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

Merged
merged 70 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
8f473de
migrate setup.py to pyproject.toml, modify some dependency version re…
cailmdaley Mar 6, 2025
057096a
add beginnings of dockerfile
cailmdaley Mar 6, 2025
9955993
add cosmo_numba dependency
cailmdaley Mar 6, 2025
e28b1a5
add healsparse dependency
cailmdaley Mar 7, 2025
37f5066
fix temporarily_load_data usage
cailmdaley Apr 3, 2025
412e1fb
merge cosmo_val_utils and cosmo_val
cailmdaley Apr 4, 2025
6686d38
Merge remote-tracking branch 'martin/cosmo_val_mk' into pyproject_docker
cailmdaley Apr 4, 2025
61bb491
first try at automatic docker build
cailmdaley Apr 4, 2025
333e72b
use ghcr container address
cailmdaley Apr 4, 2025
22a478a
fit typo
cailmdaley Apr 4, 2025
06fdb80
fix deploy image test
cailmdaley Apr 4, 2025
5745f6d
tighten up dockerfile and pyproject.toml
cailmdaley Apr 7, 2025
84fcb71
reorganize library code to allow import
cailmdaley Apr 7, 2025
67b6703
add cllm dependency
cailmdaley Apr 7, 2025
59dc1bc
Merge branch 'develop' into pyproject_docker
cailmdaley Apr 7, 2025
27536b7
fix typo
cailmdaley Apr 8, 2025
a713b7f
add installation instructions
cailmdaley Apr 8, 2025
d3378ed
Update README.md
cailmdaley Apr 8, 2025
b7f84ee
Update README.md
cailmdaley Apr 8, 2025
78e76cd
delete files made obsolete by pyproject
cailmdaley Apr 8, 2025
3efc64e
add whisker getdist
cailmdaley Apr 8, 2025
62adb10
Merge branch 'cosmo_val_mk' into pyproject_docker
cailmdaley Apr 9, 2025
9b930fb
remove utils_cosmo_val imports
cailmdaley Apr 9, 2025
90bae88
merge cosmo_val_utils and cosmo_val
cailmdaley Apr 4, 2025
9e2718d
Merge branch 'cosmo_val_mk' into pyproject_docker
cailmdaley Apr 9, 2025
c49a1fb
add htop to container
cailmdaley Apr 9, 2025
b51f33d
modify 1.5.4 catalog paths
cailmdaley Apr 10, 2025
286f204
fix typo in cat_config
cailmdaley Apr 10, 2025
2a4ba7b
add tmux to container
cailmdaley Apr 10, 2025
9011a0f
run black on cosmo_val
cailmdaley Apr 11, 2025
8d07df5
propagate function name change
cailmdaley Apr 11, 2025
498aec8
better colors
cailmdaley Apr 14, 2025
5165c8b
show plots inline as well as saving them
cailmdaley Apr 14, 2025
1c3050d
don't overwrite global config when calculating rho tau fits
cailmdaley Apr 16, 2025
2a69f51
get rid of empty figures, improve weight column handling
cailmdaley Apr 16, 2025
7dfe6ec
switch to treecorr cross_patch_weight="match"
cailmdaley Apr 16, 2025
4b0e8c9
added plot_weights, generalized calculate_2pcf, simplified pure_eb
cailmdaley May 5, 2025
8c27a63
run_cosmo_val temp changes
cailmdaley May 6, 2025
30e0358
move cosmo_val back to old path to facilitate merge
cailmdaley May 6, 2025
d2084c4
Merge branch 'develop' into pyproject_docker
cailmdaley May 6, 2025
08932fb
update pyproject to reflect changes to defunct requirements.txt
cailmdaley May 6, 2025
bd2b41e
move cosmo_val back to proper path
cailmdaley May 6, 2025
05a3de2
delete hanging git merge string that was causing a syntax error, run …
cailmdaley May 6, 2025
f7d4d45
move orphaned class methods to the right place
cailmdaley May 7, 2025
38a35af
move helper functions/classes to rho_tau.py and plots.py
cailmdaley May 7, 2025
4d5d95b
fix imports
cailmdaley May 7, 2025
2693af4
always use w_col instead of w
cailmdaley May 7, 2025
cef3c5b
always use w_col instead of w
cailmdaley May 7, 2025
2df0c30
fix weight column
cailmdaley May 12, 2025
3401e96
allow multiple cosmo_val output directories
cailmdaley May 12, 2025
f0fd26a
use github rather than pypi for shear_psf_leakage dependency
cailmdaley May 12, 2025
2e6b78f
skip objectwise leakage for catalogs with no PSF keys, small fixe + d…
cailmdaley May 12, 2025
1fd54e7
more consistent plotting font sizes
cailmdaley May 20, 2025
014d7f9
add COSEBIs
cailmdaley May 20, 2025
6440a54
fix interactive plotting
cailmdaley May 23, 2025
85387b0
Apply suggestions from MK review
cailmdaley May 23, 2025
2080a7d
merge in cosmo_inference changes
cailmdaley Jun 24, 2025
a6c5550
add script to get best-fit model datavector
cailmdaley Jun 24, 2025
b15d2a8
plot style improvements
cailmdaley Jun 24, 2025
67c9f73
get xi_sys from best-fit, rename script
cailmdaley Jun 24, 2025
64c8857
Merge branch 'develop' into pyproject_docker
cailmdaley Jul 10, 2025
e43de51
finish merge
cailmdaley Jul 10, 2025
0aff076
steal sacha's cat_config
cailmdaley Jul 16, 2025
b7c343b
add missing dependencies
cailmdaley Jul 16, 2025
494f0ad
linting comments
cailmdaley Jul 16, 2025
e49ff02
no log yscale for theta * xi plots
cailmdaley Jul 16, 2025
9b1ad5c
don't plot xi with psf sys unless it is available
cailmdaley Jul 16, 2025
8116e65
update glass mock to use nuew star/psf catalogs
cailmdaley Jul 16, 2025
e05c117
add some paper plots
cailmdaley Jul 16, 2025
a66841a
improve patch & var_method handling
cailmdaley Jul 17, 2025
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
52 changes: 52 additions & 0 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create and publish a Docker image

on:
push:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
BRANCH: ${{ github.ref }}

jobs:
build-and-push-image:
runs-on:
- ubuntu-latest
# - macos-latest
permissions:
contents: read
packages: write

steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Test
run: docker run --rm ${{ steps.meta.outputs.tags }} python -c "import sp_validation"

- name: Push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ notebooks/validation*.py
notebooks/main_set_up.py
notebooks/analyse_shear_cat/tutorial_UNIONS_SP_v1.0.py

notebooks/cosmo_val/output
notebooks/cosmo_val/output*
notebooks/cosmo_val/cosmo_val.ipynb
notebooks/cosmo_val/match_LF_SP.ipynb

Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Development image with more bells and whistles
FROM ghcr.io/cosmostat/shapepipe:develop

RUN apt-get update -y --quiet --fix-missing && \
apt-get dist-upgrade -y --quiet --fix-missing && \
apt-get install -y --quiet \
libgsl-dev \
htop \
tmux

RUN pip install --no-cache-dir \
snakemake

WORKDIR /sp_validation
COPY . /sp_validation

# Install sp_validation
RUN pip install --no-cache-dir -e .
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ tasks that can be performed by `sp_validation` are:
a shear validation run and performes cosmology inference using the two-point
correlation function.

## Container Installation (Recommended)

The easiest way to install sp_validation is via a container. Docker images are automatically built and pushed to the [Github Container Registry (GHCR)](ghcr.io/cosmostat/sp_validation) for each release. This image can be installed and run on most systems (including clusters) with just a few lines of code.

We recommend running the image with **Apptainer** (formerly Singularity) which is installed on most HPC clusters. To simply run the image, use the following command:

```bash
# build writeable "sandbox" container in the current directory
# ./sp_validation will be a directory that functions like a vm
apptainer build --sandbox sp_validation docker://ghcr.io/cosmostat/sp_validation:pyproject_docker

# open a shell in the container
apptainer shell --writable sp_validation
# and confirm that the installation was successful
python -c "import sp_validation"
```

You can also run the image with **Docker**:

```bash
docker run --rm -it ghcr.io/cosmostat/sp_validation:pyproject_docker python -c "import sp_validation"
```

We do not currently build images for Apple Silicon/amr64; however the amd64 images should work on these systems, albeit with reduced performance.



## Flow chart

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
results/*
plots/*
.snakemake/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: SP_v1.4.5
plot_style: config/paper.mplstyle

ini_dirs:
- /n23data1/n06data/lgoh/scratch/UNIONS/cosmo_inference/cosmosis_config/pipeline/
- /home/guerrini/sp_validation/cosmo_inference/cosmosis_config/


# chain: SP_v1.4.5_C_sc_10_150_new_ia
chain: SP_v1.4.5_A_sc_10_60

npatch: 256
min_sep: 0.1
max_sep: 250
nbins: 20

min_sep_int: 0.08
max_sep_int: 300
nbins_int: 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
figure.titlesize : 14
figure.titleweight : bold
figure.autolayout : True
axes.titlesize : 12
legend.fontsize : 8
lines.linewidth : 1.5
lines.markersize : 4
axes.labelsize : 10
xtick.labelsize : 10
ytick.labelsize : 10
text.usetex : True
font.family : serif
font.size : 12
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
configfile: "config/config.yaml"


def find_cosmosis_inputs():
chain = config["chain"]
for ini_dir in config["ini_dirs"]:
ini_file = Path(ini_dir) / f"cosmosis_pipeline_{chain}.ini"
if os.path.exists(ini_file):
return ini_file
raise FileNotFoundError(
f"Cosmosis input file not found for chain {chain} in specified directories."
)


rule get_bestfit_model:
input:
inference_ini=find_cosmosis_inputs(),
output:
bestfit_values_ini=f"results/{config['chain']}/bestfit_values.ini",
cosmosis_ini=f"results/{config['chain']}/cosmosis.ini",
xi_shear=f"results/{config['chain']}/bestfit_xi_shear.txt",
xi_sys=f"results/{config['chain']}/bestfit_xi_sys.txt",
params:
bestfit_dir=f"results/{config['chain']}",
script:
"scripts/get_bestfit_model.py"


rule paper_plots:
input:
bestfit_xi_shear=f"results/{config['chain']}/bestfit_xi_shear.txt",
bestfit_xi_sys=f"results/{config['chain']}/bestfit_xi_sys.txt",
xi_reporting="/n17data/cdaley/unions/sp_validation/notebooks/cosmo_val/output/{version}_xi_minsep={min_sep}_maxsep={max_sep}_nbins={nbins}_npatch={npatch}.txt".format(
**config
),
xi_integration="/n17data/cdaley/unions/sp_validation/notebooks/cosmo_val/output/{version}_xi_minsep={min_sep_int}_maxsep={max_sep_int}_nbins={nbins_int}_npatch={npatch}.txt".format(
**config
),
output:
xis="/n17data/cdaley/unions/pure_eb/results/paper_plots/{version}_eb_with_bestfit_minsep={min_sep}_maxsep={max_sep}_nbins={nbins}_minsepint={min_sep_int}_maxsepint={max_sep_int}_nbinsint={nbins_int}_npatch={npatch}_xis.pdf".format(
**config
),
ptes="/n17data/cdaley/unions/pure_eb/results/paper_plots/{version}_eb_minsep={min_sep}_maxsep={max_sep}_nbins={nbins}_minsepint={min_sep_int}_maxsepint={max_sep_int}_nbinsint={nbins_int}_npatch={npatch}_ptes.pdf".format(
**config
),
cov="/n17data/cdaley/unions/pure_eb/results/paper_plots/{version}_eb_minsep={min_sep}_maxsep={max_sep}_nbins={nbins}_minsepint={min_sep_int}_maxsepint={max_sep_int}_nbinsint={nbins_int}_npatch={npatch}_cov.pdf".format(
**config
),
params:
version=config["version"],
min_sep=lambda params: float(config["min_sep"]),
max_sep=lambda params: int(config["max_sep"]),
nbins=lambda params: int(config["nbins"]),
min_sep_int=lambda params: float(config["min_sep_int"]),
max_sep_int=lambda params: int(config["max_sep_int"]),
nbins_int=lambda params: int(config["nbins_int"]),
npatch=lambda params: int(config["npatch"]),
threads: 1
script:
"paper_plots.py"
Loading