Skip to content

Commit

Permalink
Merge pull request #5 from meteofrance/testpypi
Browse files Browse the repository at this point in the history
Working testpypi publishing
  • Loading branch information
tourniert authored Nov 4, 2024
2 parents 7831284 + 38816dc commit fcfe7e9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ logs/

# Meteo France certificates
matplotlibrc
mf.crt
mf.crt
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM pytorch/pytorch:2.3.1-cuda11.8-cudnn8-runtime

RUN apt -y update && apt -y install git
WORKDIR /app
COPY requirements.txt requirements.txt
COPY requirements_dev.txt requirements_dev.txt
RUN pip install --upgrade pip && pip install -r requirements.txt && pip install -r requirements_dev.txt

RUN pip install --upgrade build twine
ADD mfai /app/mfai
ADD tests /app/tests

38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ In addition to metrics available in [**torchmetrics**](https://lightning.ai/docs

# Installation

We will soon push the package to PyPI. In the meantime, you can install it from the source code.

## Cloning the repository

```bash
Expand All @@ -115,6 +113,14 @@ cd mfai
pip install -e .
```

## Using pip (experimental)

We have a first release on testpypi, you can install it with:

```bash
pip install --index-url https://test.pypi.org/simple/ mfai
```

# Usage

## Instanciate a model
Expand Down Expand Up @@ -511,6 +517,34 @@ We welcome contributions to this package. Our guidelines are the following:
- Make sure the current tests pass and add new tests if necessary to cover the new features. Our CI will fail with a **test coverage below 80%**.
- Make sure the code is formatted with [ruff](https://docs.astral.sh/ruff/) : `ruff format` and `ruff check`
# Publishing
We provide a script **build_and_publish.sh** to build the package and publish it to PyPI (**TestPyPI** by default). For now it uses Docker and our private/internal wrapper runai.
The full process is as follows (adjust the tag name and message to your needs):
```bash
git tag -a v0.1.0 -m "First release"
```
or
```bash
git tag v0.1.0
```
```bash
git push origin v0.1.0
./build_and_publish.sh
```
If you don't create and push a tag, the script will return an error.
In order to publish to pypi passes the argument **pypi**:
```bash
./build_and_publish.sh pypi
```
See the [Python Packaging User Guide](https://packaging.python.org/en/latest/guides/using-testpypi/) for more information on how to publish a package to PyPI.
# Acknowledgements
This package is maintained by the DSM/LabIA team at Météo-France. We would like to thank the authors of the papers and codes we used to implement the models (see [above links](#neural-network-architectures) to **arxiv** and **github**) and the authors of the libraries we use to build this package (see our [**requirements.txt**](requirements.txt)).
18 changes: 18 additions & 0 deletions build_and_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Script to build and publish mfai using runai (MF internal docker wrapper)

# Check if the repo is on a tag and if there is local modifications
set -e
git_tag=$(git describe --tags --abbrev=0 --exact-match)
if [ -n "$(git status --porcelain)" ]; then
echo "Error: You are on a git tag but there are local modifications. Please stash them or commit, push and tag your modifications."
exit 1
fi

# Fetch the latest tags from the remote and throw an error if the tag does not exist
git fetch --tags && git ls-remote --tags origin | grep -q "refs/tags/$git_tag" || { echo "Error: Tag '$git_tag' does not exist on the remote."; exit 1; }

rm -rf dist/mfai*.whl
rm -rf dist/mfai*.tar.gz
runai exec python -m build
# Use first arg if provided, otherwise use testpypi
runai exec python -m twine upload --verbose --repository ${1:-"testpypi"} dist/*
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta"

[project]
name = "mfai"
version = "1.0.0"
authors = [
{name="Frank Guibert", email="[email protected]"},
{name="Theo Tournier", email="[email protected]"},
Expand All @@ -16,15 +15,17 @@ readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache 2",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
dynamic = ["dependencies"]
dynamic = ["dependencies", "version"]
license = {file = "LICENSE"}
keywords = ["PyTorch", "Deep Learning", "Artificial Intelligence", "Meteo-France"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools_scm]

[project.urls]
Homepage = "https://github.com/meteofrance/mfai"

0 comments on commit fcfe7e9

Please sign in to comment.