From c8f26f9c6f519eebe4b68a91ced5bee3fd49edaf Mon Sep 17 00:00:00 2001 From: svenrdz Date: Thu, 12 Sep 2024 11:33:44 +0200 Subject: [PATCH 1/7] chore: fmt, add facet nominal_resolution --- esgpull/models/selection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/esgpull/models/selection.py b/esgpull/models/selection.py index e72424a..8c22ff3 100644 --- a/esgpull/models/selection.py +++ b/esgpull/models/selection.py @@ -199,6 +199,7 @@ def __repr__(self) -> str: "member_id", "cmor_table", "grid_label", + "nominal_resolution", ] From 97d0938bd86c0fcdf0d3ad3f9a54754e3035f578 Mon Sep 17 00:00:00 2001 From: svenrdz Date: Thu, 12 Sep 2024 11:29:49 +0200 Subject: [PATCH 2/7] feat(dev): switch pdm for rye --- esgpull/database.py | 6 +-- esgpull/models/query.py | 2 +- esgpull/version.py | 4 +- pyproject.toml | 96 ++++++++++++++--------------------------- 4 files changed, 40 insertions(+), 68 deletions(-) diff --git a/esgpull/database.py b/esgpull/database.py index 1830f34..13a2b81 100644 --- a/esgpull/database.py +++ b/esgpull/database.py @@ -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", diff --git a/esgpull/models/query.py b/esgpull/models/query.py index 51057b6..b202ea8 100644 --- a/esgpull/models/query.py +++ b/esgpull/models/query.py @@ -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) diff --git a/esgpull/version.py b/esgpull/version.py index 7bbb2ef..2c02b64 100644 --- a/esgpull/version.py +++ b/esgpull/version.py @@ -1 +1,3 @@ -__version__ = "0.6.5" +import importlib.metadata + +__version__ = importlib.metadata.version(__package__ or __name__) diff --git a/pyproject.toml b/pyproject.toml index 4df2de3..a077f2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -49,71 +49,27 @@ Documentation = "https://esgf.github.io/esgf-download/" branch = true source = ["esgpull/"] -[tool.mypy] -ignore_missing_imports = true +[tool.black] +line-length = 79 +extend-exclude = "setup.py" -[tool.pdm.build] -includes = ["esgpull/"] -excludes = [ - "**/.mypy_cache/", - "**/.ruff_cache/" -] +[tool.hatch.build.targets.wheel] +packages = ["src/esgpull"] -[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.hatch.metadata] +allow-direct-references = true + +[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 = [ @@ -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=setup.cfg --cov-report term-missing:skip-covered --mypy" testpaths = [ "tests/" ] @@ -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" +] From a0f036ef6edd07e690acdc9efa8b6d6d1704519e Mon Sep 17 00:00:00 2001 From: svenrdz Date: Thu, 12 Sep 2024 13:55:08 +0200 Subject: [PATCH 3/7] feat(dev): uv in the CI --- .github/workflows/ci.yml | 30 ++++++++++++++++++------------ .github/workflows/doc.yml | 21 +++++++++------------ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aafc1a9..072cbf0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,20 +20,26 @@ on: jobs: tests: + strategy: + matrix: + python-version: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: pdm-project/setup-pdm@v3 - name: setup pdm - 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 + - name: Install uv + uses: astral-sh/setup-uv@v2 - - name: install dependencies - run: pdm install -G test + - name: Set up Python + run: uv python install - - name: run tests - run: pdm run test_coverage + - name: Install the project + run: uv sync --all-extras --dev + + - name: Run tests + run: uv run pytest tests diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 9ec3113..d2f82c3 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -13,22 +13,19 @@ jobs: documentation: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: pdm-project/setup-pdm@main - name: setup pdm - 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 + - name: Install uv + uses: astral-sh/setup-uv@v2 + + - name: Set up Python + run: uv python install - - name: install dependencies - run: pdm install --no-default -dG doc + - name: Install the project + run: uv sync --all-extras --dev - name: build - run: pdm run mkdocs build -f docs/mkdocs.yml + run: uv run mkdocs build -f docs/mkdocs.yml - name: deploy uses: peaceiris/actions-gh-pages@v3 From c548030a0dc25305ab4ae6164d547fc7fbcfd401 Mon Sep 17 00:00:00 2001 From: svenrdz Date: Thu, 12 Sep 2024 15:51:42 +0200 Subject: [PATCH 4/7] fix(rye): remove uv, not yet compatible with rye dev deps --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/doc.yml | 15 +++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 072cbf0..6b6451f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,16 +30,16 @@ jobs: - "3.12" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout the repository + uses: actions/checkout@v4 - - name: Install uv - uses: astral-sh/setup-uv@v2 + - name: Install the latest version of rye + uses: eifinger/setup-rye@v4 + with: + enable-cache: true - - name: Set up Python - run: uv python install - - - name: Install the project - run: uv sync --all-extras --dev + - name: Sync dependencies + run: rye sync - name: Run tests - run: uv run pytest tests + run: rye test diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index d2f82c3..c3b10c8 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -15,17 +15,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install uv - uses: astral-sh/setup-uv@v2 - - - name: Set up Python - run: uv python install + - name: Install the latest version of rye + uses: eifinger/setup-rye@v4 + with: + enable-cache: true - - name: Install the project - run: uv sync --all-extras --dev + - name: Sync dependencies + run: rye sync - name: build - run: uv run mkdocs build -f docs/mkdocs.yml + run: rye run mkdocs build -f docs/mkdocs.yml - name: deploy uses: peaceiris/actions-gh-pages@v3 From f714dd0f050ba81631eb3afb5b3ea44524f403bb Mon Sep 17 00:00:00 2001 From: svenrdz Date: Thu, 12 Sep 2024 15:56:30 +0200 Subject: [PATCH 5/7] fix(ci): pin python version for rye --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b6451f..40c15e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,10 @@ jobs: uses: eifinger/setup-rye@v4 with: enable-cache: true + cache-prefix: ${{ matrix.python-version }} + + - name: Pin python-version ${{ matrix.python-version }} + run: rye pin ${{ matrix.python-version }} - name: Sync dependencies run: rye sync From 3b986aab5465c606d3d455a10c12baacf0695e6d Mon Sep 17 00:00:00 2001 From: svenrdz Date: Thu, 12 Sep 2024 16:00:53 +0200 Subject: [PATCH 6/7] fix: wrong config file --- pyproject.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a077f2f..b35125d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,14 +45,14 @@ esgpull = "esgpull.cli:main" Repository = "https://github.com/ESGF/esgf-download" Documentation = "https://esgf.github.io/esgf-download/" -[tool.coverage.run] -branch = true -source = ["esgpull/"] - [tool.black] line-length = 79 extend-exclude = "setup.py" +[tool.coverage.run] +branch = true +source = ["esgpull/"] + [tool.hatch.build.targets.wheel] packages = ["src/esgpull"] @@ -78,7 +78,7 @@ filterwarnings = [ markers = [ "slow: mark test as slow to run" ] -addopts = "-r aR -n auto --cov=esgpull --cov-config=setup.cfg --cov-report term-missing:skip-covered --mypy" +addopts = "-r aR -n auto --cov=esgpull --cov-config=pyproject.toml --cov-report term-missing:skip-covered --mypy" testpaths = [ "tests/" ] From 4a58216e8975e03fd2e76b418516a69661bb2e9e Mon Sep 17 00:00:00 2001 From: svenrdz Date: Thu, 12 Sep 2024 16:03:08 +0200 Subject: [PATCH 7/7] fix(ci): python >= 3.10 --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40c15e3..ab5dbf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,6 @@ jobs: strategy: matrix: python-version: - - "3.8" - - "3.9" - "3.10" - "3.11" - "3.12"