Skip to content
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

Update project skeleton #20

Merged
merged 21 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ replace = release = '{new_version}'
[bumpversion:file:src/torch_max_mem/version.py]
search = VERSION = "{current_version}"
replace = VERSION = "{new_version}"

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"
31 changes: 0 additions & 31 deletions .flake8

This file was deleted.

70 changes: 45 additions & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,79 @@ jobs:
python-version: [ "3.8", "3.11" ]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install tox
- name: Check manifest
run: tox -e manifest
- name: Check code quality with flake8
run: tox -e flake8
- name: Check package metadata with Pyroma
run: tox -e pyroma
run: pip install tox tox-uv

- name: Check static typing with MyPy
run: tox -e mypy
docs:
name: Documentation

- name: Check code quality
run: tox -e lint

lint-single-version:
name: Package Meta & Documentation
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.11" ]
python-version: [ "3.11" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install tox
- name: Check RST conformity with doc8
run: tox -e doc8
- name: Check docstring coverage
run: tox -e docstr-coverage
- name: Check documentation build with Sphinx
run: tox -e docs-test
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install tox tox-uv

- name: Check package metadata with Pyroma
run: tox -e pyroma

- name: Check docstring coverage
run: tox -e docstr-coverage

- name: Check manifest
run: tox -e manifest

- name: Check RST conformity with doc8
run: tox -e doc8

- name: Check documentation build with Sphinx
run: tox -e docs-test

tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-14 ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.8", "3.11" ]
exclude:
# 3.8 is not available for M1 macOS
- os: macos-14
python-version: "3.8"
needs:
- lint
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install tox
run: pip install tox tox-uv
- name: Test with pytest and generate coverage file
run:
tox -e py


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,5 @@ $RECYCLE.BIN/

scratch/

.vscode
.vscode
.idea
12 changes: 4 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down Expand Up @@ -27,17 +26,17 @@
author = "Max Berrendorf"

# The full version, including alpha/beta/rc tags.
release = '0.1.4-dev'
release = "0.1.4-dev"

# The short X.Y version.
parsed_version = re.match(
"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+(?P<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?",
r"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+(?P<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?",
release,
)
version = parsed_version.expand("\g<major>.\g<minor>.\g<patch>")
version = parsed_version.expand(r"\g<major>.\g<minor>.\g<patch>")

if parsed_version.group("release"):
tags.add("prerelease")
tags.add("prerelease") # noqa:F821

# -- General configuration ---------------------------------------------------

Expand All @@ -63,11 +62,8 @@
"sphinx.ext.todo",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx_autodoc_typehints",
"sphinx_click.ext",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
# 'texext',
]

# generate autosummary pages
Expand Down
156 changes: 149 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,162 @@
# See https://setuptools.readthedocs.io/en/latest/build_meta.html
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
build-backend = "setuptools.build_meta"

[project]
name = "torch_max_mem"
version = "0.1.4-dev"
description = "Maximize memory utilization with PyTorch."
# Author information
authors = [{ name = "Max Berrendorf", email = "[email protected]" }]
maintainers = [{ name = "Max Berrendorf", email = "[email protected]" }]

# See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#classifiers
# Search tags using the controlled vocabulary at https://pypi.org/classifiers
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Framework :: Pytest",
"Framework :: tox",
"Framework :: Sphinx",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
# TODO add your topics from the Trove controlled vocabulary (see https://pypi.org/classifiers)
]
keywords = [
"snekpack", # please keep this keyword to credit the cookiecutter-snekpack template
"cookiecutter",
"torch",
]

# License Information. This can be any valid SPDX identifiers that can be resolved
# with URLs like https://spdx.org/licenses/MIT
# See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license
license = { file = "License" }

requires-python = ">=3.8"
dependencies = [
"torch>=2.0",
"torch<2.4; platform_system=='Windows'",
"typing_extensions",
]

[project.optional-dependencies]
tests = ["numpy", "numpy<2; platform_system=='Windows'", "pytest", "coverage"]
docs = [
# Sphinx >= 8.0 not supported by rtd theme, cf. https://github.com/readthedocs/sphinx_rtd_theme/issues/1582
"sphinx<8",
"sphinx-rtd-theme",
"sphinx_automodapi",
# To include LaTeX comments easily in your docs.
# If you uncomment this, don't forget to do the same in docs/conf.py
# texext
]

[project.urls]
Homepage = "https://github.com/mberr/torch-max-mem"
Download = "https://github.com/mberr/torch-max-mem/releases"
"Bug Tracker" = "https://github.com/mberr/torch-max-mem/issues"
"Source Code" = "https://github.com/mberr/torch-max-mem"

[project.readme]
file = "README.md"
content-type = "text/markdown"
# URLs associated with the project


[tool.setuptools]
# Where is my code
package-dir = { "" = "src" }

[tool.setuptools.packages.find]
# this implicitly sets `packages = ":find"`
where = ["src"] # list of folders that contain the packages (["."] by default)


# Doc8, see https://doc8.readthedocs.io/en/stable/readme.html#ini-file-usage
[tool.doc8]
max-line-length = 120

# Coverage, see https://coverage.readthedocs.io/en/latest/config.html
[tool.coverage.run]
branch = true
source = ["torch_max_mem"]
omit = ["tests/*", "docs/*"]

[tool.coverage.paths]
source = ["src/torch_max_mem", ".tox/*/lib/python*/site-packages/torch_max_mem"]

[tool.coverage.report]
show_missing = true
exclude_lines = [
"pragma: no cover",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"def __str__",
"def __repr__",
]

[tool.black]
line-length = 100
target-version = ["py37", "py38", "py39"]
line-length = 120
target-version = ["py38", "py39", "py310", "py311", "py312"]

[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 100
line_length = 120
include_trailing_comma = true
reverse_relative = true

[tool.ruff]
line-length = 120

[tool.ruff.lint]
# See https://docs.astral.sh/ruff/rules
extend-select = [
"F", # pyflakes
"E", # pycodestyle errors
"W", # pycodestyle warnings
"C90", # mccabe
"I", # isort
"N", # pep8 naming
"D", # pydocstyle
"UP", # pyupgrade
"S", # bandit
"B", # bugbear
"T20", # print
"PT", # pytest-style
"RSE", #raise
"SIM", # simplify
"ERA", # eradicate commented out code
"NPY", # numpy checks
"RUF", # ruff rules
]
ignore = []

# See https://docs.astral.sh/ruff/settings/#per-file-ignores
[tool.ruff.lint.per-file-ignores]
# asserts in tests
"tests/**/*.py" = ["S101"]
"docs/source/conf.py" = ["D100", "ERA001"]


[tool.ruff.lint.pydocstyle]
convention = "pep257"

[tool.ruff.lint.isort]
known-third-party = []
known-first-party = ["torch_max_mem", "tests"]
relative-imports-order = "closest-to-furthest"

# Pytest, see https://docs.pytest.org/en/stable/reference/customize.html#pyproject-toml
[tool.pytest.ini_options]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')"
]
addopts = "--strict-markers"
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
Loading
Loading