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

Use uv package management tool #54

Merged
merged 7 commits into from
Sep 6, 2024
Merged
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
23 changes: 23 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Linting

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Set up Python
uses: actions/setup-python@v5

- name: Run pre-commit hooks
run: uvx pre-commit run --all-files
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
on:
push:
tags:
- "v*.*.*"

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Set up Python
uses: actions/setup-python@v5

- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
uv build
uvx twine upload dist/*
29 changes: 0 additions & 29 deletions .github/workflows/run_tests.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

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

- name: Install the project
run: uv sync --all-extras --dev

- name: Run tests
run: uv run pytest tests
38 changes: 21 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
# install pre-commit hooks with
# `pre-commit install`

# auto-update pre-commit hooks
# `pre-commit autoupdate`

# run pre-commit hooks on all files
# `pre-commit run --all-files`

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
hooks:
- id: black
- id: ruff
args: [ --fix ]
- id: ruff-format

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.3.0
hooks:
- id: codespell
types_or: [python, markdown]
additional_dependencies: [tomli]
- id: codespell

- repo: local
- repo: https://github.com/frazane/check-latex-math
rev: v0.2.2
hooks:
- id: ruff
name: ruff
entry: ruff
args: ["--exit-non-zero-on-fix"]
require_serial: true
language: system
types: [python]
exclude: examples/
- id: latex-math-validation
args: ["scoringrules/", "docs/", "*.py", "*.md"]
2 changes: 1 addition & 1 deletion docs/api/crps.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ where $F(x) = P(X<x)$ is the forecast CDF and $\mathbb{1}\{x \le y\}$ the empiri
of the scalar observation $y$. $\mathbb{1}$ is the indicator function. The CRPS can
also be viewed as the Brier score integrated over all real-valued thresholds.

When the true forecast CDF is not fully known, but represented by a finite ensemble, the CRPS can be estimated with some error. Several estimators exist and they are implemented in `scoringrules`. For a thorough review of CRPS estimators and their respective biases, refer to Zamo and Naveau (2018)[@zamo_estimation_2018] and Jordan (2016)[@jordan_facets_2016].
<!-- When the true forecast CDF is not fully known, but represented by a finite ensemble, the CRPS can be estimated with some error. Several estimators exist and they are implemented in `scoringrules`. For a thorough review of CRPS estimators and their respective biases, refer to Zamo and Naveau (2018)[@zamo_estimation_2018] and Jordan (2016)[@jordan_facets_2016]. -->


## Analytical formulations
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/images/banner_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/assets/images/banner_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 20 additions & 8 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,42 @@ Fork the repository on GitHub and clone it to your computer:
git clone https://github.com/<your-username>/scoringrules.git
```

We use [poetry](https://python-poetry.org/) for dependencies management and packaging. Once you've set it up, you can install the library and all dependencies (including development dependencies), install the pre-commit hooks and activate the environment:
We use [uv](https://docs.astral.sh/uv/) for project management and packaging. Install it with

```
poetry install
poetry run pre-commit install
poetry shell
curl -LsSf https://astral.sh/uv/install.sh | sh
```

From here you can work on your changes! Once you're satisfied with your changes (and followed the additional instructions below), push everything to your repository and open a pull request on GitHub.
Then, you can install the library and all dependencies (including development dependencies) and install the pre-commit hooks:

```
uv install
uv run pre-commit install
```

From here you can work on your changes! Once you're satisfied with your changes, and followed the additional instructions below, push everything to your repository and open a pull request on GitHub.


### Contributing to the codebase
Commit changes to the codebase within the project environment, so as to run pre-commit hooks:

```
uv run git commit -m "your commit message"
```

Don't forget to include new tests if necessary, then make sure that all tests are passing with

```
pytest tests/
uv run pytest tests/
```

### Contributing to the documentation

You can work on the documentation by modifying `mkdocs.yaml` and files in `docs/`. The most convenient way to do it is to run

```
mkdocs serve
uvx --with-requirements docs/requirements.txt mkdocs serve
```

and open the locally hosted documentation on your browser. It will be updated automatically every time you make changes and save.
and open the locally hosted documentation on your browser. It will be updated automatically every time you make changes and save. If you edit or add pieces of LaTex math, please make sure they
are rendered correctly.
6 changes: 6 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdocs
mkdocs-bibtex
mkdocs-material
mkdocs-section-index
mkdocstrings-python
black
Loading
Loading