Skip to content

Commit

Permalink
added parameter entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
santacodes committed Jun 20, 2024
1 parent e85f0ba commit 5374988
Show file tree
Hide file tree
Showing 7 changed files with 537 additions and 27 deletions.
12 changes: 12 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import nox
from pathlib import Path
import os

# Options to modify nox behaviour
nox.options.default_venv_backend = "uv|virtualenv"
nox.options.reuse_existing_virtualenvs = True

VENV_DIR = Path("./venv").resolve()

@nox.session(name="docs")
def build_docs(session: nox.Session) -> None:
"""Build the documentation and load it in a browser tab, rebuilding on changes."""
Expand All @@ -26,3 +30,11 @@ def run_template_generation(session):
session.install("setuptools", silent=False)
session.install("-e", ".[dev]", silent=False)
session.run("pytest", "tests")

@nox.session(name="dev")
def set_dev(session):
"""Install pybamm-cookiecutter in editable mode"""
session.install("virtualenv")
session.run("virtualenv", os.fsdecode(VENV_DIR), silent=True)
python = os.fsdecode(VENV_DIR.joinpath("bin/python"))
session.run(python, "-m", "pip", "install", "-e", ".[dev]")
81 changes: 54 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Homepage = "https://github.com/pybamm-team/pybamm-cookiecutter"
Discussions = "https://github.com/pybamm-team/pybamm-cookiecutter/discussions"
Changelog = "https://github.com/pybamm-team/pybamm-cookiecutter/releases"

[project.entry-points."cookie_parameter_sets"]
Chen2020 = "pybamm_cookiecutter.parameters.input.Chen2020:get_parameter_values"

[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "src/pybamm_cookiecutter/_version.py"
Expand All @@ -73,8 +76,8 @@ packages = [
"src/pybamm_cookiecutter",
"tests"
]
python_version = "3.8"
strict = true
python_version = "3.11"
strict = false
warn_return_any = false
show_error_codes = true
enable_error_code = [
Expand All @@ -84,6 +87,9 @@ enable_error_code = [
]
disallow_untyped_defs = false
disallow_untyped_calls = false
ignore_missing_imports = true
allow_redefinition = true
disable_error_code = ["call-overload", "operator"]

[tool.coverage]
run.source = ["pybamm_cookiecutter"]
Expand All @@ -92,32 +98,53 @@ port.exclude_lines = [
]

[tool.ruff]
select = [
"E", "F", "W", # flake8
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
]
extend-include = ["*.ipynb"]
extend-exclude = ["__init__.py"]
src = ["src"]
exclude = []
isort.required-imports = ["from __future__ import annotations"]
flake8-unused-arguments.ignore-variadic-names = true


[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
# "I", # isort
# "ARG", # flake8-unused-arguments
# "C4", # flake8-comprehensions
# "ICN", # flake8-import-conventions
# "ISC", # flake8-implicit-str-concat
# "PGH", # pygrep-hooks
# "PIE", # flake8-pie
# "PL", # pylint
# "PT", # flake8-pytest-style
# "PTH", # flake8-use-pathlib
# "RET", # flake8-return
"RUF", # Ruff-specific
# "SIM", # flake8-simplify
# "T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"TID252", # relative-imports
]
ignore = [
"E741", # Ambiguous variable name
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"SIM108", # Use ternary operator
"ARG001", # Unused function argument:
"ARG002", # Unused method arguments
"PLR2004", # Magic value used in comparison
"PLR0915", # Too many statements
"PLR0913", # Too many arguments
"PLR0912", # Too many branches
"RET504", # Unnecessary assignment
"RET505", # Unnecessary `else`
"RET506", # Unnecessary `elif`
"B018", # Found useless expression
"RUF002", # Docstring contains ambiguous
"UP007", # For pyupgrade
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["T20"]
"docs/*" = ["T20"]
2 changes: 2 additions & 0 deletions src/pybamm_cookiecutter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import pybamm

from ._version import version as __version__
from .parameters.parameter_sets import parameter_sets

__all__ : list[str] = [
"__version__",
"pybamm",
"parameter_sets",
]
3 changes: 3 additions & 0 deletions src/pybamm_cookiecutter/parameters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from __future__ import annotations

__all__ = ["parameter_sets", ]
Loading

0 comments on commit 5374988

Please sign in to comment.