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

Update CI tools and dependencies #24

Merged
merged 32 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a98dc83
Start adapting to [email protected]
glatterf42 Oct 3, 2023
35ab99a
Add some type hints
glatterf42 Oct 3, 2023
1913280
Address further [email protected] issues
glatterf42 Oct 4, 2023
81f9fe7
Start adapting api layer for [email protected]
glatterf42 Oct 4, 2023
542b3ef
remove Annotated type hint
meksor Oct 5, 2023
2e3c6b8
hopefully fix pydantic validator
meksor Oct 5, 2023
a9a1279
Let pydantic return a SchemaError instead of InconsistentIamcType
glatterf42 Oct 10, 2023
0e64dcc
Clean up accidental comment
glatterf42 Oct 10, 2023
f736024
Use pandera.DataFrameModel instead of pandera.SchemaModel
glatterf42 Oct 10, 2023
bf845f0
Clean up changes in API layer
glatterf42 Oct 10, 2023
3510253
Clean up changes in data/db to enable tests again
glatterf42 Oct 10, 2023
d024f96
Set field.alias only when it does not equal field.name
glatterf42 Oct 10, 2023
647dc54
Update version of ruff
glatterf42 Oct 10, 2023
72f1aea
Set field alias in Field directly
glatterf42 Oct 10, 2023
bec7440
Use httpx-preferred content to send bytes/raw content/json st
glatterf42 Oct 10, 2023
571b053
Use alias for model_ fields that conflict with pydantic protected nam…
glatterf42 Oct 10, 2023
a13a498
Use variable rather than unmapped class reference to resolve SAwarning
glatterf42 Oct 11, 2023
ba4c313
Delete unused import
glatterf42 Oct 11, 2023
e5df31c
Bump mypy and poetry versions
glatterf42 Oct 11, 2023
cfc29ae
Use pre-commit over lint-GHA
glatterf42 Oct 12, 2023
d89c162
Bump sphinx version
glatterf42 Oct 12, 2023
764cbec
Update docstrings according to new sphinx version
glatterf42 Oct 12, 2023
a0b35dc
Delete duplicate docs files
glatterf42 Oct 13, 2023
fb19369
TEMPORARY Use own fork for sphinxcontrib-openapi workaround
glatterf42 Oct 16, 2023
129e803
Bump dask,sqlalchemy,pre-commit versions
glatterf42 Oct 16, 2023
8de9433
restore filter framework api
meksor Oct 18, 2023
04b5df1
fix union types with filter subojects
meksor Oct 18, 2023
1b4be7e
fix code style
meksor Oct 18, 2023
0f0c1b0
fix formatting error
meksor Oct 18, 2023
274884a
Remove outdated comments
glatterf42 Oct 18, 2023
0f1ab0c
Update various things:
glatterf42 Oct 18, 2023
9c36ebc
Include pre-commit, ruff, etc in DEVELOPING.md
glatterf42 Oct 19, 2023
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
68 changes: 0 additions & 68 deletions .github/workflows/lint.yaml

This file was deleted.

44 changes: 43 additions & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
Expand Down Expand Up @@ -74,3 +73,46 @@ jobs:
run: |
source .venv/bin/activate
pytest --cov-report xml:.coverage.xml --cov-report term --cov=ixmp4 -rsx --benchmark-skip

pre-commit:
name: Code quality
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev,server
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# run pre-commit/(mypy, black, ruff)
#----------------------------------------------
- uses: pre-commit/[email protected]
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
hooks:
- id: mypy
entry: bash -c "poetry run mypy ."
language: system
- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
hooks:
- id: ruff
50 changes: 50 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,53 @@ It is overwritten on the fly by the poetry-dynamic-versioning plugin.
(without the rc<N>).
1. Check that the "Publish to PyPI and TestPyPI" GitHub action passed and that the
distributions are published on https://pypi.org/project/ixmp4/ .

## Contributing

Contributions to the code are always welcome! Please make sure your code follows our
code style so that the style is consistent. Each PR will be checked by a Code Quality
test that examines compliance with black, ruff, and mypy.

### Running pre-commit locally

We use [pre-commit](https://pre-commit.com/) to check the code style. You can install
pre-commit locally by installing ixmp4 with the optional `dev` group. Running

```bash
pre-commit install
```

will set pre-commit up to run on every `git commit`. Per default, pre-commit will run
on changed files, but if you want to run it on all files, you can run

```bash
pre-commit run --all-files
```

If you only want certain hooks to run, choose from `ruff`, `black`, and `mypy` as
`hook-ids` and run

```bash
pre-commit run <hook-ids> --all-files
```

### Ensuring compliance

Whether you run pre-commit locally or see it on your PR for the first time, the checks
are the same. You can, of course, run the code style tools manually. From within the
ixmp4 directory, this would look similar to this:

```bash
black .
mypy .
ruff check .

# Or to enable ruff's automic fixes
ruff check --fix .
```

However, it is easy to forget running these commands manually. Therefore, we recommend
setting your editor up to run at least
[black](https://black.readthedocs.io/en/stable/integrations/editors.html) and
[ruff](https://docs.astral.sh/ruff/usage/#vs-code) automatically whenever you hit
`save`. A few minutes of configuration will save you time and nerves later on.
1 change: 1 addition & 0 deletions doc/source/devs/ixmp4.core/iamc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ IAMC Data
:members:
:undoc-members:
:show-inheritance:
:noindex:


.. automodule:: ixmp4.core.iamc.repository
Expand Down
3 changes: 2 additions & 1 deletion doc/source/devs/ixmp4.core/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Core API (ixmp4.core)

platform
run
model
scenario
iamc
meta
region
unit
exceptions

2 changes: 1 addition & 1 deletion doc/source/devs/ixmp4.core/scenario.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Scenarios
=======
=========

.. toctree::
:maxdepth: 1
Expand Down
70 changes: 0 additions & 70 deletions doc/source/modules.rst

This file was deleted.

2 changes: 1 addition & 1 deletion doc/source/openapi-v1.json

Large diffs are not rendered by default.

82 changes: 0 additions & 82 deletions doc/source/tests.rst

This file was deleted.

2 changes: 1 addition & 1 deletion ixmp4/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def login(
),
):
try:
auth = ManagerAuth(username, password, settings.manager_url)
auth = ManagerAuth(username, password, str(settings.manager_url))
user = auth.get_user()
utils.good(f"Successfully authenticated as user '{user.username}'.")
if typer.confirm(
Expand Down
Loading
Loading