Skip to content

Commit

Permalink
add modifications for 2024 session (#5)
Browse files Browse the repository at this point in the history
* add modifications for 2024 session

* add linters to optional dependencies

* run isort
  • Loading branch information
sfarrens authored Aug 26, 2024
1 parent a079780 commit 0092d0a
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 28 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

Expand All @@ -31,7 +31,7 @@ jobs:
sphinx-build docs/source docs/build
- name: Deploy API documentation
uses: peaceiris/actions-gh-pages@v3.5.9
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check Python version
run: python --version

- name: Install dependencies
run: python -m pip install ".[test]"
run: python -m pip install ".[lint,test]"

- name: Run tests
run: python -m pytest
- name: Run unit tests
run: python -m pytest

- name: Run linting tests
run: |
black --check .
isort --check .
2 changes: 1 addition & 1 deletion .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Verification

on: workflow_dispatch

jobs:
test-full:
name: Run Verification Tests
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check Python version
run: python --version

- name: Install dependencies
run: python -m pip install ".[test,verify]"

- name: Run unit tests
run: python -m pytest scripts/astropy_verification.py
5 changes: 3 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ image: python:latest

before_script:
- python --version
- python -m pip install ".[docs,test]"
- python -m pip install ".[dev]"

test:
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
script:
- python -m pytest
- black --check .
- isort --check .
only:
refs:
- merge_requests
Expand All @@ -16,7 +18,6 @@ test:
Verification:
script:
- export TF_CPP_MIN_LOG_LEVEL=1
- python -m pip install astropy
- python -m pytest scripts/astropy_verification.py
when: manual
only:
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ WORKDIR /home
ENV SHELL /bin/bash

RUN apt-get update
RUN apt-get install build-essential -y
RUN apt-get install -y build-essential && \
apt-get install -y nano

COPY * .

RUN conda env create -f environment.yml
RUN conda env create -f environment.yml

RUN echo "conda activate mycosmo" >> ~/.bashrc
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
This repository was made for a course on scientific software development at the [2023 edition of the Euclid Summer School](https://ecole-euclid.cnrs.fr/2023-accueil/).

> The content was updated for the [2024 edition of the Rodolphe Clédassou Summer School](https://ecole-euclid.cnrs.fr/2024-accueil/)
The slides accompanying this repository can be found [here](https://sfarrens.github.io/presentations/#/).

Example API documentation can be found [here](https://sfarrens.github.io/ecole-euclid-2023/).
Expand All @@ -13,11 +15,12 @@ Example API documentation can be found [here](https://sfarrens.github.io/ecole-e
To follow this course you will need to have Python (ideally v3.11) installed with the following dependencies:

- numpy
- astropy
- black
- isort
- myst-parser
- numpydoc
- pytest
- pytest-black
- pytest-pydocstyle
- pytest-emoji
- pytest-cov
Expand Down Expand Up @@ -53,12 +56,12 @@ Finally, you can avoid installing any of the packages by simply pulling the prov

```bash
docker pull ghcr.io/sfarrens/ecole-euclid-2023:main
docker tag ghcr.io/sfarrens/ecole-euclid-2023:main ecole-euclid-2023
docker tag ghcr.io/sfarrens/ecole-euclid-2023:main ecole-rc-2024
```

Then you can launch an interactive container as follows:

```bash
docker run -it ecole-euclid-2023
docker run -it ecole-rc-2024
conda activate mycosmo
```
3 changes: 1 addition & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import sys
import os

import sys

sys.path.insert(0, os.path.abspath("../.."))

Expand Down
4 changes: 3 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ channels:
dependencies:
- python=3.11
- numpy>=1.25
- astropy
- black
- build
- isort
- myst-parser
- numpydoc
- pytest
- pytest-black
- pytest-emoji
- pytest-cov
- sphinx
Expand Down
2 changes: 1 addition & 1 deletion mycosmo/cosmology.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np

from .constants import Mpc, G
from .constants import G, Mpc


def hubble(redshift, cosmo_dict):
Expand Down
2 changes: 1 addition & 1 deletion mycosmo/tests/test_cosmology.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import numpy.testing as npt

from mycosmo.cosmology import hubble, critical_density
from mycosmo.cosmology import critical_density, hubble


class TestCosmology:
Expand Down
9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,22 @@ version = "0.0.1"

[project.optional-dependencies]
docs = ["myst-parser", "numpydoc", "sphinx", "sphinx-book-theme"]
lint = ["black"]
lint = ["black", "isort"]
release = ["build", "twine"]
test = [
"pytest",
"pytest-black",
"pytest-cov",
"pytest-emoji",
"pytest-pydocstyle",
]
verify = ["astropy"]

# Install for development
dev = ["mycosmo[docs,lint,release,test]"]

[tool.black]
line-length = 88

[tool.pydocstyle]
convention = "numpy"

[tool.pytest.ini_options]
addopts = ["--verbose", "--black", "--emoji", "--pydocstyle", "--cov=mycosmo"]
addopts = ["--verbose", "--emoji", "--pydocstyle", "--cov=mycosmo"]
testpaths = ["mycosmo"]
2 changes: 1 addition & 1 deletion scripts/astropy_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
from astropy.cosmology import WMAP9 as cosmo

from mycosmo.cosmology import hubble, critical_density
from mycosmo.cosmology import critical_density, hubble


class TestAstropy:
Expand Down

0 comments on commit 0092d0a

Please sign in to comment.