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

chore: add new nox sessions to deal with requirements and venvs #13

Merged
merged 10 commits into from
Jun 17, 2024
Prev Previous commit
Next Next commit
Updates from new config
egparedes committed Jun 12, 2024
commit 03d6d081ca814f56298170997ddef5063c8f4745
51 changes: 27 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -2,41 +2,47 @@ default_language_version:
python: python3.10

ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_commit_msg: 'chore: update pre-commit hooks'
autofix_commit_msg: 'style: pre-commit fixes'

repos:
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.6.0
rev: v2.13.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- id: pretty-format-toml
args: [--autofix]
args: [--autofix, --indent, '2', --trailing-commas]
additional_dependencies:
- setuptools>=69.2.0
- id: pretty-format-yaml
args: [--autofix, --preserve-quotes, --indent, "2"]
args: [--autofix, --indent, '2', --line-width, '100']
additional_dependencies:
- setuptools>=69.2.0

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: prettier
types_or: [markdown, html, css, scss, javascript, json]
args: [--prose-wrap=preserve]
- id: mdformat
args: [--number]
additional_dependencies:
- mdformat-gfm
- mdformat-black

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.9
rev: v1.5.5
hooks:
- id: insert-license
exclude: ^\..*$
exclude: |
(?x)^(
^\..*$ |
noxfile.py
)$
types: [python]
args: [--comment-style, "|#|", --license-filepath, ./LICENSE_HEADER.txt]
args: [--comment-style, '|#|', --license-filepath, ./LICENSE_HEADER.txt]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
@@ -46,15 +52,13 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
hooks:
- id: ruff
args: ["--fix", "--show-fixes", "--preview"]
args: [--fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
@@ -67,15 +71,14 @@ repos:
- dace==0.15.1
- jax[cpu]==0.4.28
- numpy==1.26.4
- pytest==8.2.2
- typing-extensions==4.12.2
- pytest==8.2.1
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: v2.3.0
hooks:
- id: codespell

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.10.0.1"
rev: v0.10.0.1
hooks:
- id: shellcheck

@@ -88,13 +91,13 @@ repos:
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.16"
rev: v0.18
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]
additional_dependencies: ['validate-pyproject-schema-store[all]']

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.28.1"
rev: 0.28.5
hooks:
- id: check-dependabot
- id: check-github-workflows
156 changes: 120 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61"]
requires = [
"setuptools>=61",
]

[project]
authors = [{name = "ETH Zurich", email = "gridtools@cscs.ch"}]
authors = [
{name = "ETH Zurich", email = "gridtools@cscs.ch"},
]
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
@@ -17,9 +21,13 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Typing :: Typed"
"Typing :: Typed",
]
dependencies = [
"dace>=0.15",
"jax[cpu]>=0.4.24",
"numpy>=1.26.0",
]
dependencies = ["dace>=0.15", "jax[cpu]>=0.4.24", "numpy>=1.26.0"]
description = "JAX jit using DaCe (Data Centric Parallel Programming)"
name = "JaCe"
readme = "README.md"
@@ -28,17 +36,44 @@ version = "0.1.0"
license.file = "LICENSE"

[project.optional-dependencies]
cuda12 = ["cupy-cuda12x>=12.1.0", "jax[cuda12]>=0.4.24", "optuna>=3.4.0"]
cuda12 = [
"cupy-cuda12x>=12.1.0",
"jax[cuda12]>=0.4.24",
"optuna>=3.4.0",
]

[project.urls]
"Bug Tracker" = "https://github.com/GridTools/JaCe/issues"
Changelog = "https://github.com/GridTools/JaCe/releases"
Discussions = "https://github.com/GridTools/JaCe/discussions"
Homepage = "https://github.com/GridTools/JaCe"

# -- coverage --
[tool.coverage]
report.exclude_also = ['\.\.\.', 'if typing.TYPE_CHECKING:']
run.source = ["jace"]

[tool.coverage.html]
show_contexts = true

[tool.coverage.report]
exclude_also = [
'\.\.\.',
'if TYPE_CHECKING:',
'if typing.TYPE_CHECKING:',
'def __repr__',
'@overload',
'raise AssertionError',
'raise NotImplementedError',
'if 0:',
'if __name__ == .__main__.:',
'@(abc\\.)?abstractmethod',
'@(abc\\.)?abstract',
'class .*\bProtocol\):',
]

[tool.coverage.run]
branch = true
dynamic_context = "test_function"
source = ["jace"]

# -- mypy --
[tool.mypy]
@@ -63,7 +98,12 @@ warn_unused_ignores = true
disallow_incomplete_defs = false
disallow_untyped_defs = false
ignore_missing_imports = true
module = ["tests.*", "dace.*", "jax.*", "jaxlib.*"]
module = [
"tests.*",
"dace.*",
"jax.*",
"jaxlib.*",
]

# -- pytest --
[tool.pytest]
@@ -79,6 +119,7 @@ xfail_strict = true
# -- ruff --
[tool.ruff]
line-length = 100
preview = true
respect-gitignore = true
show-fixes = true
src = ["src"]
@@ -87,72 +128,115 @@ src = ["src"]
docstring-code-format = true

[tool.ruff.lint]
extend-safe-fixes = ["D", "TCH"]
extend-select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"I", # isort
"G", # flake8-logging-format
"N", # pep8-naming
"W", # pycodestyle-warning
"C4", # flake8-comprehensions
"C90", # mccabe
"D", # pydocstyle
"D213", # multi-line-summary-second-line (off by default in pydocstyle "google' convention)
"PT", # flake8-pytest-style
"UP", # pyupgrade # TODO: in evaluation
"TD", # flake8-todo
"UP", # pyupgrade
"ARG", # flake8-unused-arguments
"ERA", # eradicate
"FLY", # flynt
"ICN", # flake8-import-conventions
"NPY", # NumPy specific rules
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PTH", # flake8-use-pathlib
"RET", # flake8-return # TODO: in evaluation
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify # TODO: in evaluation
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"T10", # flake8-debugger
"T20", # flake8-print # TODO: in evaluation
"TCH", # flake8-type-checking # TODO: in evaluation
"NPY" # NumPy specific rules
"T20", # flake8-print
"TCH", # flake8-type-checking
"TRY", # tryceratops
]
ignore = [
'B905', # [zip-without-explicit-strict]
'E501', # [line-too-long]
'TCH003', # [typing-only-standard-library-import]
'UP038' # [non-pep604-isinstance]
"B905", # [zip-without-explicit-strict]
"D105", # [undocumented-magic-method]
"D107", # [undocumented-public-init]
"D212", # [multi-line-summary-first-line]
"D402", # [no-signature]
"E501", # [line-too-long]
"TCH003", # [typing-only-standard-library-import]
"TD003", # [missing-todo-link]
"TRY003", # [raise-vanilla-args] # TODO(egparedes): reevaluate if it should be activated
"UP038", # [non-pep604-isinstance]
]
task-tags = ["TODO"]
# ignore-init-module-imports = true # deprecated in preview mode
unfixable = []

[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = ['jace']
known-first-party = ["jace"]
known-third-party = [
'cupy',
'dace',
'jax',
'numpy',
'pytest',
'typing_extensions'
"cupy",
"dace",
"jax",
"numpy",
"pytest",
"typing_extensions",
]
lines-after-imports = 2
order-by-type = true
required-imports = ["from __future__ import annotations"]
section-order = [
'future',
'standard-library',
'third-party',
'first-party',
'tests',
'local-folder'
"future",
"standard-library",
"third-party",
"first-party",
"tests",
"local-folder",
]

[tool.ruff.lint.isort.sections]
tests = ["tests", "unit_tests", "integration_tests"]
tests = [
"tests",
"unit_tests",
"integration_tests",
]

[tool.ruff.lint.mccabe]
max-complexity = 12

[tool.ruff.lint.per-file-ignores]
"!tests/**.py" = ["PT"] # Ignore `flake8-pytest-style` everywhere except in `tests/`
"noxfile.py" = ["T20"] # Ignore `flake8-print`
"tests/**" = ["T10", "T20"] # Ignore `flake8-debugger` and `flake8-print`
"!tests/**.py" = ["PT"] # Ignore flake8-pytest-style outside 'tests/'
"docs/**" = [
"D", # pydocstyle
"T10", # flake8-debugger
"T20", # flake8-print
]
"noxfile.py" = [
"D", # pydocstyle
"T20", # flake8-print
]
"tests/**" = [
"D", # pydocstyle
"N", # TODO(egparedes): remove ignore as soon as all tests are properly named
"PLR2004", # [magic-value-comparison]
"T10", # flake8-debugger
"T20", # flake8-print
]

[tool.ruff.lint.pycodestyle]
max-doc-length = 85
ignore-overlong-task-comments = true
max-doc-length = 88

[tool.ruff.lint.pydocstyle]
convention = "google"
ignore-decorators = ["typing.overload"]

[tool.ruff.lint.pylint]
max-positional-args = 6