-
Notifications
You must be signed in to change notification settings - Fork 0
Project initialization #1
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
Changes from all commits
0eb81ef
45c75ff
262923d
796ebfe
574ff26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <your-repo-url> | ||
| 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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| [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" }, | ||
| { name = "eyjafjallac" }, | ||
| ] | ||
| dependencies = [ | ||
| "qten", | ||
| ] | ||
| [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-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", | ||
| "qten-plots>=0.1.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 | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||||||||||||||||
| """qRG package.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| __all__ = ["__version__"] | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| __version__ = "0.1.0" | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| __version__ = "0.1.0" | |
| try: | |
| # Python 3.8+ | |
| from importlib.metadata import PackageNotFoundError, version | |
| except ImportError: # pragma: no cover | |
| # Python < 3.8 | |
| from importlib_metadata import PackageNotFoundError, version # type: ignore[import] | |
| try: | |
| # Use the top-level package name as the distribution name | |
| _distribution_name = __name__.split(".")[0] | |
| __version__ = version(_distribution_name) | |
| except PackageNotFoundError: # pragma: no cover | |
| # Fallback when the package is not installed with metadata available | |
| __version__ = "0.0.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import qrg | ||
|
|
||
|
|
||
| def test_package_imports() -> None: | ||
| assert qrg.__version__ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Comment on lines
+12
to
+18
|
||
|
|
||
| [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 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All backend extras (
cpu,cu126,cu128, etc.) declare identical dependencies (torch/torchvision), and the actual index selection is implemented only under[tool.uv.sources]. Installers other thanuv(e.g.,pip install .[cu128]) will ignore thetool.uvconfig and likely resolve the default (often CPU) wheels, making these extras misleading. Consider documenting thatuvis required for CUDA extras, or encode CUDA-specific requirements in a way that works with standard installers.