diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aafc1a9..ab5dbf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 9ec3113..c3b10c8 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -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 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/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", ] 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..b35125d 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", @@ -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 = [ @@ -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/" ] @@ -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" +]