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

Develop with rye #50

Merged
merged 7 commits into from
Sep 12, 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
30 changes: 19 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,28 @@ on:

jobs:
tests:
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout the repository
uses: actions/checkout@v4

- uses: pdm-project/setup-pdm@v3
name: setup pdm
- name: Install the latest version of rye
uses: eifinger/setup-rye@v4
with:
python-version: "3.11" # Version range or exact version of a Python version to use, the same as actions/setup-python
architecture: x64 # The target architecture (x86, x64) of the Python interpreter. the same as actions/setup-python
prerelease: false # Allow prerelease versions to be installed
enable-pep582: true # Enable PEP 582 package loading globally
enable-cache: true
cache-prefix: ${{ matrix.python-version }}

- name: install dependencies
run: pdm install -G test
- name: Pin python-version ${{ matrix.python-version }}
run: rye pin ${{ matrix.python-version }}

- name: run tests
run: pdm run test_coverage
- name: Sync dependencies
run: rye sync

- name: Run tests
run: rye test
18 changes: 7 additions & 11 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,18 @@ jobs:
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: pdm-project/setup-pdm@main
name: setup pdm
- name: Install the latest version of rye
uses: eifinger/setup-rye@v4
with:
python-version: "3.10" # Version range or exact version of a Python version to use, the same as actions/setup-python
architecture: x64 # The target architecture (x86, x64) of the Python interpreter. the same as actions/setup-python
version: 2.1.5 # The version of PDM to install. Leave it as empty to use the latest version from PyPI
prerelease: false # Allow prerelease versions to be installed
enable-pep582: true # Enable PEP 582 package loading globally
enable-cache: true

- name: install dependencies
run: pdm install --no-default -dG doc
- name: Sync dependencies
run: rye sync

- name: build
run: pdm run mkdocs build -f docs/mkdocs.yml
run: rye run mkdocs build -f docs/mkdocs.yml

- name: deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
6 changes: 3 additions & 3 deletions esgpull/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def _update(self) -> None:
opts = {"version_table": "version"}
ctx = MigrationContext.configure(conn, opts=opts)
self.version = ctx.get_current_revision()
if self.version != head:
alembic.command.upgrade(alembic_config, __version__)
if head is not None and self.version != head:
alembic.command.upgrade(alembic_config, head)
self.version = head
if self.version != __version__:
if "+dev" not in __version__ and self.version != __version__:
alembic.command.revision(
alembic_config,
message="update tables",
Expand Down
2 changes: 1 addition & 1 deletion esgpull/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def has_files(self) -> bool:
return nb_files is not None and nb_files > 0

def files_count_size(self, *status: FileStatus) -> tuple[int, int]:
stmt: sa.Select[tuple[int, int | None]] = (
stmt: sa.Select[tuple[int, int]] = (
sa.select(sa.func.count("*"), sa.func.sum(File.size))
.join_from(query_file_proxy, File)
.where(query_file_proxy.c.query_sha == self.sha)
Expand Down
1 change: 1 addition & 0 deletions esgpull/models/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def __repr__(self) -> str:
"member_id",
"cmor_table",
"grid_label",
"nominal_resolution",
]


Expand Down
4 changes: 3 additions & 1 deletion esgpull/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = "0.6.5"
import importlib.metadata

__version__ = importlib.metadata.version(__package__ or __name__)
96 changes: 33 additions & 63 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "esgpull"
dynamic = ["version"]
version = "0.6.5"
classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
Expand Down Expand Up @@ -45,75 +45,31 @@ esgpull = "esgpull.cli:main"
Repository = "https://github.com/ESGF/esgf-download"
Documentation = "https://esgf.github.io/esgf-download/"

[tool.black]
line-length = 79
extend-exclude = "setup.py"

[tool.coverage.run]
branch = true
source = ["esgpull/"]

[tool.mypy]
ignore_missing_imports = true
[tool.hatch.build.targets.wheel]
packages = ["src/esgpull"]

[tool.pdm.build]
includes = ["esgpull/"]
excludes = [
"**/.mypy_cache/",
"**/.ruff_cache/"
]
[tool.hatch.metadata]
allow-direct-references = true

[tool.pdm.dev-dependencies]
doc = [
"mkdocs-material>=8.5.6"
]
test = [
"pytest>=7.1.3",
"pytest-cov>=5.0.0",
"pytest-xdist>=3.0.2"
]
lint = [
"black>=22.8.0",
"isort>=5.10.1",
"flake8>=5.0.4",
"mypy>=0.982,<1.1.1",
"types-pyopenssl>=22.1.0.1",
"types-aiofiles>=22.1.0",
"types-python-dateutil>=2.8.19.2",
"types-pymysql>=1.0.19.1",
"types-pyyaml>=6.0.12",
"types-cryptography>=3.3.23.1",
"types-setuptools>=65.5.0.1"
]
profile = [
"snakeviz>=2.1.1",
"vprof>=0.38",
"memray>=1.13.3",
"line-profiler>=4.1.3"
]
dev = [
"jupyter-console>=6.6.3"
]
[tool.isort]
profile = "black"
line_length = 79
src_paths = ["esgpull", "tests", "migrations", "examples"]

[tool.mypy]
ignore_missing_imports = true

[tool.pdm.scripts]
echo_gap = "echo"
echo_ruff = "echo [ruff]"
format_ruff = "ruff format"
fix_ruff = "ruff check --fix"
echo_mypy = "echo [mypy]"
lint_mypy = "mypy --disable-recursive-aliases esgpull tests"
lint = {composite = [
"echo_ruff",
"format_ruff",
"fix_ruff",
"echo_gap",
"echo_mypy",
"lint_mypy"
]}
test = "pytest"
test_coverage = "pytest -n auto --cov=esgpull --cov-report term-missing:skip-covered"
doc = {shell = "cd docs && mkdocs serve", help = "Start doc server"}

[tool.pdm.version]
source = "file"
path = "esgpull/version.py"

[tool.pytest.ini_options]
minversion = "6.2.4"
filterwarnings = [
Expand All @@ -122,7 +78,7 @@ filterwarnings = [
markers = [
"slow: mark test as slow to run"
]
addopts = "-r aR"
addopts = "-r aR -n auto --cov=esgpull --cov-config=pyproject.toml --cov-report term-missing:skip-covered --mypy"
testpaths = [
"tests/"
]
Expand All @@ -133,3 +89,17 @@ extend-exclude = ["output/*", "esgpull/migrations/*"]

[tool.ruff.lint]
extend-select = ["I"]

[tool.rye]
dev-dependencies = [
"jupyter-console>=6.6.3",
"typing-extensions>=4.12.2",
"pytest>=8.3.3",
"pytest-cov>=5.0.0",
"mkdocs-material>=9.5.34",
"mypy>=1.11.2",
"types-pyyaml>=6.0.12.20240808",
"types-aiofiles>=24.1.0.20240626",
"pytest-mypy>=0.10.3",
"pytest-xdist>=3.6.1"
]
Loading