From 0eb81efcb0d89ba463a3ea5a6dd0d7ad81a4e986 Mon Sep 17 00:00:00 2001 From: Alphaharrius Date: Tue, 31 Mar 2026 17:07:59 +0800 Subject: [PATCH 1/5] Added project setup files --- .github/workflows/ci.yml | 25 ++++++++ .gitignore | 14 ++++- .pre-commit-config.yaml | 24 +++++++ pyproject.toml | 133 +++++++++++++++++++++++++++++++++++++++ src/qrg/__init__.py | 5 ++ tests/test_smoke.py | 5 ++ tox.ini | 35 +++++++++++ 7 files changed, 238 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .pre-commit-config.yaml create mode 100644 pyproject.toml create mode 100644 src/qrg/__init__.py create mode 100644 tests/test_smoke.py create mode 100644 tox.ini diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e2821b9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + checks: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up uv + uses: astral-sh/setup-uv@v6 + with: + python-version: "3.11" + + - name: Sync dependencies + run: uv sync --group dev + + - name: Tox + run: uv run tox diff --git a/.gitignore b/.gitignore index b7faf40..4d3f601 100644 --- a/.gitignore +++ b/.gitignore @@ -98,7 +98,7 @@ ipython_config.py # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. # This is especially recommended for binary packages to ensure reproducibility, and is more # commonly ignored for libraries. -#uv.lock +uv.lock # poetry # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. @@ -182,9 +182,9 @@ cython_debug/ .abstra/ # Visual Studio Code -# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore +# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore -# and can be added to the global gitignore or merged into this file. However, if you prefer, +# and can be added to the global gitignore or merged into this file. However, if you prefer, # you could uncomment the following to ignore the entire vscode folder # .vscode/ @@ -201,6 +201,14 @@ cython_debug/ .cursorignore .cursorindexingignore +# macOS +.DS_Store + +# PyTorch artifacts +*.pt +*.pth +*.safetensors + # Marimo marimo/_static/ marimo/_lsp/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..70ae16f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-yaml + - repo: local + hooks: + - id: ruff-check + name: ruff check + entry: uv run ruff check src tests + language: system + pass_filenames: false + - id: ruff-format-check + name: ruff format --check + entry: uv run ruff format --check src tests + language: system + pass_filenames: false + - id: mypy + name: mypy + entry: uv run mypy --no-incremental src tests + language: system + pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0f8ce3a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,133 @@ +[build-system] +requires = ["setuptools>=69", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "qRG" +version = "0.1.0" +description = "A torch based package for renormalization group computation." +readme = "README.md" +requires-python = ">=3.11" +license = { file = "LICENSE" } +authors = [ + { name = "alphaharrius" }, +] +[project.optional-dependencies] +cpu = [ + "torch>=2.7.0", + "torchvision>=0.22.0", +] +cu126 = [ + "torch>=2.7.0", + "torchvision>=0.22.0", +] +cu128 = [ + "torch>=2.7.0", + "torchvision>=0.22.0", +] +cu129 = [ + "torch>=2.7.0", + "torchvision>=0.22.0", +] +cu130 = [ + "torch>=2.7.0", + "torchvision>=0.22.0", +] + +[tool.setuptools] +package-dir = { "" = "src" } + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.uv] +package = true +conflicts = [ + [{ extra = "cpu" }, { extra = "cu126" }, { extra = "cu128" }, { extra = "cu129" }, { extra = "cu130" }], +] + +[tool.uv.sources] +torch = [ + { index = "pytorch-cu126", extra = "cu126" }, + { index = "pytorch-cu128", extra = "cu128" }, + { index = "pytorch-cu129", extra = "cu129" }, + { index = "pytorch-cu130", extra = "cu130" }, + { index = "pytorch-cpu", extra = "cpu", marker = "sys_platform == 'linux'" }, + { index = "pypi", extra = "cpu", marker = "sys_platform != 'linux'" }, +] +torchvision = [ + { index = "pytorch-cu126", extra = "cu126" }, + { index = "pytorch-cu128", extra = "cu128" }, + { index = "pytorch-cu129", extra = "cu129" }, + { index = "pytorch-cu130", extra = "cu130" }, + { index = "pytorch-cpu", extra = "cpu", marker = "sys_platform == 'linux'" }, + { index = "pypi", extra = "cpu", marker = "sys_platform != 'linux'" }, +] + +[[tool.uv.index]] +name = "pytorch-cu126" +url = "https://download.pytorch.org/whl/cu126" +explicit = true + +[[tool.uv.index]] +name = "pytorch-cu128" +url = "https://download.pytorch.org/whl/cu128" +explicit = true + +[[tool.uv.index]] +name = "pytorch-cu129" +url = "https://download.pytorch.org/whl/cu129" +explicit = true + +[[tool.uv.index]] +name = "pytorch-cu130" +url = "https://download.pytorch.org/whl/cu130" +explicit = true + +[[tool.uv.index]] +name = "pytorch-cpu" +url = "https://download.pytorch.org/whl/cpu" +explicit = true + +[[tool.uv.index]] +name = "pypi" +url = "https://pypi.org/simple" + +[dependency-groups] +dev = [ + "build>=1.2.2", + "mypy>=1.10", + "pre-commit>=3.7", + "pytest>=8.2", + "pytest-cov>=4.0.0", + "ruff>=0.5", + "tox>=4.0.0", + "tox-uv>=1.0.0", + "twine>=5.1.1", +] +nb = [ + "ipykernel>=6.29.0", + "jupyterlab>=4.2.0", + "notebook>=7.2.0", +] + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.ruff] +target-version = "py311" +line-length = 100 + +[tool.ruff.lint] +select = ["E", "F", "I", "UP", "B"] + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" + +[tool.mypy] +python_version = "3.11" +files = ["src", "tests"] +strict = true +warn_unused_ignores = true +disallow_any_generics = true diff --git a/src/qrg/__init__.py b/src/qrg/__init__.py new file mode 100644 index 0000000..00695fa --- /dev/null +++ b/src/qrg/__init__.py @@ -0,0 +1,5 @@ +"""qRG package.""" + +__all__ = ["__version__"] + +__version__ = "0.1.0" diff --git a/tests/test_smoke.py b/tests/test_smoke.py new file mode 100644 index 0000000..c674d14 --- /dev/null +++ b/tests/test_smoke.py @@ -0,0 +1,5 @@ +import qrg + + +def test_package_imports() -> None: + assert qrg.__version__ diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ff351d1 --- /dev/null +++ b/tox.ini @@ -0,0 +1,35 @@ +[tox] +requires = + tox>=4.0.0 + tox-uv>=1.0.0 +env_list = + py311 + lint + type + +[testenv] +description = Run the test suite with coverage. +package = wheel +extras = + cpu +dependency_groups = + dev +commands = + pytest --cov=qrg --cov-report=term-missing tests + +[testenv:lint] +description = Run Ruff checks. +package = skip +dependency_groups = + dev +commands = + ruff check src tests + ruff format --check src tests + +[testenv:type] +description = Run mypy checks. +package = skip +dependency_groups = + dev +commands = + mypy --no-incremental src tests From 45c75ffaa50eeef6db0a877af576c95a47496136 Mon Sep 17 00:00:00 2001 From: Alphaharrius Date: Tue, 31 Mar 2026 17:11:56 +0800 Subject: [PATCH 2/5] Added `qten` dependencies --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 0f8ce3a..cb55a66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,9 @@ license = { file = "LICENSE" } authors = [ { name = "alphaharrius" }, ] +dependencies = [ + "qten", +] [project.optional-dependencies] cpu = [ "torch>=2.7.0", @@ -109,6 +112,7 @@ nb = [ "ipykernel>=6.29.0", "jupyterlab>=4.2.0", "notebook>=7.2.0", + "qten-plots>=0.1.0", ] [tool.pytest.ini_options] From 262923dd7247e8c25c02accde08374fc6a30a46e Mon Sep 17 00:00:00 2001 From: Alphaharrius Date: Tue, 31 Mar 2026 17:23:46 +0800 Subject: [PATCH 3/5] Added dev tutorial to README.md --- README.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/README.md b/README.md index 61711ad..94a0b06 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,94 @@ # qRG A torch based toolkit for renormalization group computations. + +## Developer Setup + +This repository uses `uv` for environment management, `tox` for checks, and `pre-commit` for local hooks. + +### Requirements + +- Python 3.11 +- `uv` + +Install `uv` if needed: + +```bash +curl -LsSf https://astral.sh/uv/install.sh | sh +``` + +### Quick Start + +Clone the repo and choose one PyTorch backend extra: + +- `cpu` +- `cu126` +- `cu128` +- `cu129` +- `cu130` + +Standard development setup with CPU PyTorch: + +```bash +git clone +cd qRG +uv sync --group dev --extra cpu +uv run pre-commit install +``` + +If you want a CUDA backend instead, replace `cpu` with one of the CUDA extras, for example: + +```bash +uv sync --group dev --extra cu128 +``` + +Only one backend extra can be installed at a time. + +### Common Commands + +Run all checks: + +```bash +uv run tox +``` + +Run pre-commit on all files: + +```bash +uv run pre-commit run --all-files +``` + +Build the package: + +```bash +uv run python -m build +``` + +### Minimal Install + +If you only want the base package without dev tools or PyTorch extras: + +```bash +uv sync +``` + +This installs the package and its base dependency `qten`, but not `dev` or any torch backend. + +### Reinstall + +Clean reinstall: + +```bash +rm -rf .venv uv.lock +uv sync --group dev --extra cpu +``` + +Force reinstall in the existing environment: + +```bash +uv sync --reinstall --group dev --extra cpu +``` + +### Notes + +- `uv.lock` is ignored in this repository. +- Common Torch checkpoint files are ignored in git. From 796ebfe78f4b5f24d48c2f40e55adcf84ed46a9a Mon Sep 17 00:00:00 2001 From: eyjafjallac Date: Thu, 2 Apr 2026 16:21:23 +0800 Subject: [PATCH 4/5] Added new author "eyjafjallac" to pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index cb55a66..9de0066 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ requires-python = ">=3.11" license = { file = "LICENSE" } authors = [ { name = "alphaharrius" }, + { name = "eyjafjallac" }, ] dependencies = [ "qten", From 574ff265cf775357e2e13ff78d57cb987c668cee Mon Sep 17 00:00:00 2001 From: eyjafjallac Date: Thu, 2 Apr 2026 16:47:42 +0800 Subject: [PATCH 5/5] Removed deprecated `pytorch-cu130` dependency from pyproject.toml --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9de0066..923300c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,6 @@ torchvision = [ { index = "pytorch-cu126", extra = "cu126" }, { index = "pytorch-cu128", extra = "cu128" }, { index = "pytorch-cu129", extra = "cu129" }, - { index = "pytorch-cu130", extra = "cu130" }, { index = "pytorch-cpu", extra = "cpu", marker = "sys_platform == 'linux'" }, { index = "pypi", extra = "cpu", marker = "sys_platform != 'linux'" }, ]