diff --git a/.github/workflows/action_python.yaml b/.github/workflows/action_python.yaml index 53fb41ad..73bdb81d 100644 --- a/.github/workflows/action_python.yaml +++ b/.github/workflows/action_python.yaml @@ -1,9 +1,9 @@ name: Python package on: - push: - paths: - - 'src/**' + push: +# paths: +# - 'src/**' jobs: build: @@ -25,19 +25,18 @@ jobs: shell: bash env: WANDB_API_KEY: ${{secrets.WANDB_API_KEY}} - - name: Install poetry - run: pipx install poetry - - name: Set up Python and install dependencies - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v4 with: - python-version: '3.10' - cache: 'poetry' - - name: install poetry - run: poetry install + enable-cache: true + - name: Set up Python + run: uv python install + - name: Install the project + run: uv sync --all-extras --dev - name: Test with pytest run: | - poetry run pytest --cov=src tests/ --doctest-modules --junitxml=cover/xunit-result.xml --cov-report xml:cover/coverage.xml - poetry run coverage json -o cover/coverage.json + uv run pytest --cov=src tests/ --doctest-modules --junitxml=cover/xunit-result.xml --cov-report xml:cover/coverage.xml + uv run coverage json -o cover/coverage.json - name: "Extract numbers from cov report" run: | export TOTAL=$(python -c "import json;print(json.load(open('cover/coverage.json'))['totals']['percent_covered_display'])") diff --git a/.gitignore b/.gitignore index 493d0c58..3d78f6d6 100644 --- a/.gitignore +++ b/.gitignore @@ -68,9 +68,6 @@ target/ # Pycharm .idea -# VS Code -.vscode/ - # Spyder .spyproject/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..c66166b1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,21 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.testing.autoTestDiscoverOnSaveEnabled": true, + "[python]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.codeActionsOnSave": { + "source.fixAll": "explicit", + "source.organizeImports": "explicit" + } + }, + "notebook.formatOnSave.enabled": true, + "notebook.codeActionsOnSave": { + "notebook.source.fixAll": "explicit", + "notebook.source.organizeImports": "explicit" + } +} diff --git a/pyproject.toml b/pyproject.toml index 5ca59833..5ce2b28d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,5 +129,49 @@ dev-dependencies = [ "pytest>=7.4.3", "pytest-cov>=4.1.0", "ruff>=0.8.1", - "tox>=4.11.3", + "tox>=4.23", + "tox-uv", ] + +[tool.tox] +env_list = ["format", "lint", "pre-commit"] +min_version = "4.23" + +[tool.tox.env_run_base] +runner = "uv-venv-lock-runner" +allowlist_externals = ["/bin/sh"] +skip_install = true +with_dev = true + +[tool.tox.env.clean] +description = "cleanup tasks (remove build artifacts and cache)" +commands = [ + ["coverage", "erase"], + ["sh", "-c", "rm -rf .mypy_cache .pytest_cache .ruff_cache dist mlruns reports"] +] + +[tool.tox.env.format] +description = "code formatting using ruff" +commands = [ + ["ruff", "format", { replace = "posargs", default = ["src", "tests", "notebooks"], extend = true }] +] + +[tool.tox.env.lint] +description = "linting and syntax checks" +commands = [ + ["ruff", "check", { replace = "posargs", default = ["src", "tests", "notebooks"], extend = true} ], + ["ruff", "format", "--check", { replace = "posargs", default = ["src", "tests", "notebooks"], extend = true} ], + ["mypy", { replace = "posargs", default = ["src"], extend = true} ] +] + +[tool.tox.env.pre-commit] +description = "pre-commit hooks" +commands = [["pre-commit", "run", "--all-files", "--show-diff-on-failure"]] + +[tool.tox.env.test] +description = "tests" +commands = [["pytest"]] + +[tool.tox.env.build] +description = "build the project" +commands = [["uv", "build"]] diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 946b2edf..00000000 --- a/tox.ini +++ /dev/null @@ -1,41 +0,0 @@ -[tox] -envlist = format,lint,test,pre-commit -isolated_build = True - -[testenv] -skip_install = true -setenv = - PYTHONUNBUFFERED=yes -allowlist_externals = - poetry - /bin/sh -commands_pre = - poetry install - -# Cleanup tasks -[testenv:clean] -commands = - poetry run coverage erase - sh -c "rm -rf build cover dist .hypothesis .mypy_cache .pytest_cache site" - -# Auto Formatting -[testenv:format] -commands = - poetry run ruff src tests --fix - poetry run ruff format src tests - -# Syntax Checks -[testenv:lint] -commands = - poetry run mypy src - poetry run ruff src tests - poetry run ruff format src tests --check - -# Pre-Commit -[testenv:pre-commit] -commands = - poetry run pre-commit run --all-files --show-diff-on-failure - -[testenv:test] -commands = - poetry run pytest -m "not slow" diff --git a/uv.lock b/uv.lock index 7093fc7b..01d4ff00 100644 --- a/uv.lock +++ b/uv.lock @@ -2159,6 +2159,7 @@ dev = [ { name = "pytest-cov" }, { name = "ruff" }, { name = "tox" }, + { name = "tox-uv" }, ] [package.metadata] @@ -2193,7 +2194,8 @@ dev = [ { name = "pytest", specifier = ">=7.4.3" }, { name = "pytest-cov", specifier = ">=4.1.0" }, { name = "ruff", specifier = ">=0.8.1" }, - { name = "tox", specifier = ">=4.11.3" }, + { name = "tox", specifier = ">=4.23" }, + { name = "tox-uv" }, ] [[package]] @@ -3381,6 +3383,22 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/af/c0/124b73d01c120e917383bc6c53ebc34efdf7243faa9fca64d105c94cf2ab/tox-4.23.2-py3-none-any.whl", hash = "sha256:452bc32bb031f2282881a2118923176445bac783ab97c874b8770ab4c3b76c38", size = 166758 }, ] +[[package]] +name = "tox-uv" +version = "1.13.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "importlib-resources", marker = "python_full_version < '3.9'" }, + { name = "packaging" }, + { name = "tox" }, + { name = "typing-extensions", marker = "python_full_version < '3.10'" }, + { name = "uv" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a8/93/1f06c3cbfd4c1aa23859d49a76c7e65b51e60715bc22b2dd16cbff9c1e71/tox_uv-1.13.1.tar.gz", hash = "sha256:a8504b8db4bf6c81cba7cd3518851a3f1e0f6991d22272a4cc08ebe1b7f38cca", size = 15645 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/8e/94afb25547f5e4987801e8f6aa11e357190f72f31eb363267a3cb2fa6a88/tox_uv-1.13.1-py3-none-any.whl", hash = "sha256:b163dd28ca37a9f4c6d8cbac11153be27c2e929b58bcae62e323ffa8f71c327d", size = 13383 }, +] + [[package]] name = "tqdm" version = "4.67.1" @@ -3398,7 +3416,7 @@ name = "triton" version = "3.1.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "filelock" }, + { name = "filelock", marker = "python_full_version < '3.13'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/98/29/69aa56dc0b2eb2602b553881e34243475ea2afd9699be042316842788ff5/triton-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b0dd10a925263abbe9fa37dcde67a5e9b2383fc269fdf59f5657cac38c5d1d8", size = 209460013 }, @@ -3450,6 +3468,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ce/d9/5f4c13cecde62396b0d3fe530a50ccea91e7dfc1ccf0e09c228841bb5ba8/urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac", size = 126338 }, ] +[[package]] +name = "uv" +version = "0.5.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/46/95/ba000f161640015c9f2ecc2681f38eb161b8edac600a0451b36e4ad15aa4/uv-0.5.5.tar.gz", hash = "sha256:7f8db4bdf7eaef6be271457c4b2a167f41ad115434944a09f5034018a29b4093", size = 2324705 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/91/ac61feea1b11e4dc342a4fd174f311b628a04ec3b4614a24676c4d214bd1/uv-0.5.5-py3-none-linux_armv6l.whl", hash = "sha256:d091e88a9c2c830169c3ccf95fd972759e0ab629dacc2d5eff525e5ba3583904", size = 13887911 }, + { url = "https://files.pythonhosted.org/packages/84/18/461af22fd1f80f86548013639ab345810dbf35aa44dff1732c6faf311a48/uv-0.5.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:f0bfc7ced2fe0c85b3070dfa219072a1406133e18aab2f2fe10b6455ede0f8b2", size = 13900075 }, + { url = "https://files.pythonhosted.org/packages/68/5f/7a236ad48f81c580691f9e5f28dd47289a9819f18410f12ee3c621791efd/uv-0.5.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:553901e95cb5a4da1da19e288c29c5f886793f981750400e5cef48e3031b970b", size = 12869530 }, + { url = "https://files.pythonhosted.org/packages/94/d6/d6f441fd041fb4883332b999481896e28502b51681bcb786a001fb1e4a50/uv-0.5.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:a4f0c7647187044056dc6f6f5d31b01f445d8695eb7d2f442b29fd5c9216a56f", size = 13158009 }, + { url = "https://files.pythonhosted.org/packages/9b/3d/cc1e44e14266bbdb71eb020d14454f4f24f72fcc2eb84a52bf809e030918/uv-0.5.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:34e894c922ba29a59bbe812a458a7095a575f76b87dfc362e0c3f4f650d6f631", size = 13676515 }, + { url = "https://files.pythonhosted.org/packages/10/5f/b81ed7ab715687a790b9b06a6f4e2781d7f7222840eead0392c3ef6f80ea/uv-0.5.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f5569798fc8eaad58fbb4fb70ced8f09ebe607fbbfb95fa42c559f57bbe0cabd", size = 14245499 }, + { url = "https://files.pythonhosted.org/packages/f7/e1/ce5a88bc5ed61ee310a8e0acc3fa3032280bb2d49514fd48b801bb36f96f/uv-0.5.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:59d53cce11718ce5d5367afc8c93ebcfc5e1cddfa4a44aedbf08d08d9b738381", size = 14920230 }, + { url = "https://files.pythonhosted.org/packages/03/84/6fa2deb5bed9dab815cb7f57e14885ecf8de22249b992f9c4ea5dd042c28/uv-0.5.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3dee9517ebba13d07d8f139c439c5ff63e438d31ebda4d7eb0af8d0f0cc6a181", size = 14701845 }, + { url = "https://files.pythonhosted.org/packages/59/b2/7078d52a73c1e13d984c22fae1888993e5cd3f40cea029ab2666d79d92a7/uv-0.5.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:29286cd6b9f8e040d02894a67c6b6304811ea393ca9dfade109e93cf4b3b842c", size = 18963098 }, + { url = "https://files.pythonhosted.org/packages/b9/89/a91d927574ce2103d22b7beab319468d915a1d04757cf82b6eaf79b56a10/uv-0.5.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f7f04ae5a5430873d8610d8ea0a5d35df92e60bf701f80b3cf24857e0ac5e72", size = 14442788 }, + { url = "https://files.pythonhosted.org/packages/46/3d/2c5a9d362771aeef13c2ba1c9b1267b469e11331b874486f03f6c6fc5eb1/uv-0.5.5-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:5a47345ccafc0105b2f0cc22fcb0bb05be4d0e60df67f5beea28069b0bb372c8", size = 13394955 }, + { url = "https://files.pythonhosted.org/packages/cf/92/8d646385401472e7358cdf0fc86015edc9bf9132c9b79d7e2a11c300dd84/uv-0.5.5-py3-none-musllinux_1_1_armv7l.whl", hash = "sha256:b55d507bfe2bd2330c41680e4b0077972381f40975a59b53007254196abc4477", size = 13639522 }, + { url = "https://files.pythonhosted.org/packages/da/23/5e00b71f9c8b9c16f0947bf84b71265bafdf24947d2e271a657da00a0c6a/uv-0.5.5-py3-none-musllinux_1_1_i686.whl", hash = "sha256:365715e7247c2cd8ef661e8f96927b181248f689c07e48b076c9dbc78a4a0877", size = 13957451 }, + { url = "https://files.pythonhosted.org/packages/02/38/0c624a8d89416fa6c849c6670066c74f420aa898eafdf7cefd3adf77d686/uv-0.5.5-py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:0314a4b9a25bf00afe4e5472c338c8c6bd34688c23d63ce1ad35462cf087b492", size = 15840287 }, + { url = "https://files.pythonhosted.org/packages/a8/bd/1a81700d2555be504f0b1ff82f86d666384805e354c8eec2fdf7558d0cf9/uv-0.5.5-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:f4e9ddcffc29f009f692cda699912b02f6a12089d741b71d2fcd0b181eb71c5d", size = 14560282 }, + { url = "https://files.pythonhosted.org/packages/cd/71/c0b137c62a5a8ab5ecc0a8f505b77e5a05d5b94fd9da7560a247dac000f3/uv-0.5.5-py3-none-win32.whl", hash = "sha256:9af7018430da1f0960eee1592c820c343e2619f2d71f66c3be62da330826c537", size = 13810875 }, + { url = "https://files.pythonhosted.org/packages/e3/d8/56dbbe07aba3cf561fff52b8ed75ce7b694a0710ab676fae4cd7fbf1bdae/uv-0.5.5-py3-none-win_amd64.whl", hash = "sha256:69e15f24493d86c3a2da3764891e35a033ceda09404c1f9b386671d509db95f3", size = 15604848 }, +] + [[package]] name = "virtualenv" version = "20.28.0"