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

Introduce poetry #82

Merged
merged 21 commits into from
Jan 14, 2022
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
54 changes: 42 additions & 12 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,54 @@

:tada: Thanks, for considering to contribute to EKO!

:pray: For the sake of simplicity we switch below to imperative language, however, please read a "Please" infront of everything.

- :brain: Be reasonable and use common sense when contributing: we added some points we would like to highlight below
- :family: Follow our [Code of Conduct](https://github.com/N3PDF/eko/blob/master/.github/CODE_OF_CONDUCT.md) and use the provided
[Issue Templates](https://github.com/N3PDF/eko/issues/new/choose)
:pray: For the sake of simplicity we switch below to imperative
language, however, please read a "Please" infront of everything.

- :brain: Be reasonable and use common sense when contributing: we
added some points we would like to highlight below
- :family: Follow our [Code of
Conduct](https://github.com/N3PDF/eko/blob/master/.github/CODE_OF_CONDUCT.md)
and use the provided [Issue
Templates](https://github.com/N3PDF/eko/issues/new/choose)

## Tools

- [`poetry`](https://github.com/python-poetry/poetry) is the
dependency manager and packaging back-end of choice for this
project, refers to official [installation
guide](https://python-poetry.org/docs/#installation)
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved
- [`poery-dynamic-versioning`](https://github.com/mtkennerly/poetry-dynamic-versioning),
is used to update the package version based on VCS status (tags and
commits); note that since the version is dumped in output object,
this is to be used not only for releases, but whenever output is
generated (and intended to be used)
- [`pre-commit`](https://pre-commit.com/) is used to enforce
automation and standardize the tools for all developers; if you want
to contribute to this project, please
[install](https://pre-commit.com/#install) it and \[setup\]

## Testing

- :elephant: Make sure to not break the old tests (unless there was a mistake)
- :hatching_chick: Write new tests for your new code - the coverage should be back to 100% if possible
- :elephant: Make sure to not break the old tests (unless there was a
mistake)
- :hatching_chick: Write new tests for your new code - the coverage
should be back to 100% if possible

## Style Conventions

### Python Styleguide
- :art: Run [black](https://github.com/psf/black) to style your code
- :blue_book: Use [numpy documentation guide](https://numpydoc.readthedocs.io/en/latest/format.html)

- :art: Run [black](https://github.com/psf/black) to style your code
- :blue_book: Use [numpy documentation
guide](https://numpydoc.readthedocs.io/en/latest/format.html)

### Git
- :octocat: Make sure the commit message is written properly ([This blogpost](https://chris.beams.io/posts/git-commit/) explains it nicely)
- :sailboat: Use [git-flow](https://github.com/nvie/gitflow) - note there is a [cheat sheet](https://danielkummer.github.io/git-flow-cheatsheet/index.html)
and [shell completion](https://github.com/bobthecow/git-flow-completion)

- :octocat: Make sure the commit message is written properly ([This
blogpost](https://chris.beams.io/posts/git-commit/) explains it
nicely)
- :sailboat: Use [git-flow](https://github.com/nvie/gitflow) - note
there is a [cheat
sheet](https://danielkummer.github.io/git-flow-cheatsheet/index.html)
and [shell
completion](https://github.com/bobthecow/git-flow-completion)
56 changes: 35 additions & 21 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,49 @@ name: deploy
on:
push:
tags:
- '*'
- "*"

jobs:
build-n-publish:
publish:
felixhekhorn marked this conversation as resolved.
Show resolved Hide resolved
name: Build and publish Python 🐍 distributions 📦 to PyPI

strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.9]

#if: startsWith(github.event.ref, 'refs/tags')
python-version: [3.8, 3.9, 3.10]

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

steps:
- uses: actions/checkout@master
- name: Setup Python 🐍
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
pip install -e .
- name: Package the distribution
run: |
# package the pure python wheel
pip wheel . -w dist --no-deps
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_TOKEN }}
- uses: actions/checkout@master
- name: Setup Python 🐍
id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-path: ~/.virtualenvs
installer-parallel: true
- name: Cache Poetry virtualenv
uses: actions/cache@v2
id: cache
with:
path: ~/.virtualenvs
key: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install package
run: |
pip install poetry-dynamic-versioning
poetry install
# run tests just before deployment
pip install poethepoet
poe test
- name: Package the distribution
run: |
# package the pure python wheel
poetry build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_TOKEN }}
35 changes: 21 additions & 14 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,44 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
# max-parallel: 2
matrix:
python-version: [3.7, 3.8, 3.9]
fail-fast: false

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }} 🐍
id: setup-python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-path: ~/.virtualenvs
installer-parallel: true
- name: Cache Poetry virtualenv
uses: actions/cache@v1
id: cache
with:
path: ~/.virtualenvs
key: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
run: poetry install --no-interaction --no-root
if: steps.cache.outputs.cache-hit != 'true'
- name: Install project
run: poetry install --no-interaction
- name: Install task runner
run: pip install poethepoet
- name: Lint with pylint
run: |
pip install pylint
# Search for actual errors
pylint src/eko -E
poe lint
# For warnings instead return always zero
pylint src/eko --exit-zero
poe lint-warnings
- name: Test with pytest
run: |
# add test packages
pip install -r dev_requirements.txt
# until https://github.com/numba/numba/pull/5660 is confirmed we need to deactivate numba prior running
export NUMBA_DISABLE_JIT=1
pytest
poe test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# ignore version
src/eko/version.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

Expand All @@ -15,8 +14,9 @@ sphinx:

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
version: "3.8"
install:
- method: pip
path: .
- requirements: dev_requirements.txt
extra_requirements:
- docs
11 changes: 1 addition & 10 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@
"affiliation": "Università degli Studi di Milano",
"name": "Candido, Alessandro"
},
{
"orcid": "0000-0002-0079-6753",
"affiliation": "Università degli Studi di Milano",
"name": "Carrazza, Stefano"
},
{
"orcid": "0000-0002-8061-1965",
"affiliation": "Università degli Studi di Milano",
"name": "Cruz-Martinez, Juan M."
},
{
"orcid": "0000-0001-8752-8008",
"affiliation": "Università degli Studi di Milano",
"name": "Hekhorn, Felix"
},
{
"orcid": "0000-0003-1699-4815",
"affiliation": "Nikhef",
"name": "Magni, Giacomo"
}
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ EKO is available via PyPI: <a href="https://pypi.org/project/eko/"><img alt="PyP
pip install eko
```

### Development

If you want to install from source you can run
```bash
git clone git@github.com:N3PDF/eko.git
cd eko
python setup.py install
poetry install
```

To setup `poetry`, and other tools, see [Contribution
Guidlines](https://github.com/N3PDF/eko/blob/master/.github/CONTRIBUTING.md).

## Documentation
- The documentation is available here: <a href="https://eko.readthedocs.io/en/latest/?badge=latest"><img alt="Docs" src="https://readthedocs.org/projects/eko/badge/?version=latest"></a>
- To build the documentation from source install [graphviz](https://www.graphviz.org/) and run in addition to the installation commands
Expand Down
33 changes: 33 additions & 0 deletions benchmarks/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "ekomark"
version = "0.1.0"
description = "eko benchmarks"
authors = [
"Alessandro Candido <alessandro.candido@mi.infn.it>",
"Felix Hekhorn <felix.hekhorn@mi.infn.it>",
"Giacomo Magni <gmagni@nikhef.nl>",
]
include = ["banana.yaml", "ekomark/benchmark/external/LHA.yaml"]

[tool.poetry.dependencies]
python = ">=3.8,<3.10"
banana-hep = "^0.4.0"
sqlalchemy = "^1.4.21"
pandas = "^1.3.0"
matplotlib = "^3.5.1"
PyYAML = "^6.0"
# eko should be a dependency, but this would made it circular, since we want
# yadmark to be in the environment of eko, thus we rely on this package
# being installed with eko (since it is a dev-dependency) in this repo, and
# it will never be released on any public registry
# eko = { path = "../" }

[tool.poetry.scripts]
ekonavigator = "ekomark.navigator:launch_navigator"

[tool.poetry.dev-dependencies]
black = "^21.9b0"
31 changes: 0 additions & 31 deletions benchmarks/setup.py

This file was deleted.

19 changes: 0 additions & 19 deletions dev_requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ help:
html: todos
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

server:
python3 -m http.server 8000 --bind 127.0.0.1 --directory build/html

view: html
$(BROWSER) $(BUILDDIR)/html/index.html

Expand Down
Loading