Skip to content

Commit

Permalink
chore: use poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Mah Neh committed Sep 20, 2024
1 parent 44e8582 commit c2dcba8
Show file tree
Hide file tree
Showing 105 changed files with 1,168 additions and 17,767 deletions.
41 changes: 41 additions & 0 deletions PACKAGING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
1. Deactivate any env, and [install `pipx`](https://pipx.pypa.io/stable/installation/)

- Linux

```bash
sudo apt update
sudo apt install pipx
pipx ensurepath
```

- MacOS

```bash
brew install pipx
pipx ensurepath
```

2. Install `poetry`

There are other managers like `uv`, or just plain `pip` but `pip` alone does not nicely manage the versions in the `pyproject.toml`.

```bash
pipx install poetry
pipx upgrade poetry
# pipx uninstall poetry
```

Tab completions:

```bash
poetry completions bash >> ~/.bash_completion
```

You can add an alias `alias sve=source .venv/bin/activate/`; then open or re-open a terminal and do, in your project folder:

```bash
python3.11 -m venv .venv
sve
```

and should be it.
170 changes: 170 additions & 0 deletions old_pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#================={PROJECT CONFIGURATION===================
[project]
name = "keras-tuner"
description = "A Hyperparameter Tuning Library for Keras"
readme = "README.md"
license = { file = "LICENSE" }
dynamic = ["version"]
requires-python = ">=3.11"
authors = [
{ name = "The KerasTuner authors" },
{ name = "Mah Neh", email = "[email protected]" },
]
keywords = ["Hyperparameters", "Tuning", "Machine Learning"]
dependencies = [
"keras>=3.1",
"requests",
"numpy<2",
"protobuf~=4.25",
"grpcio-tools",
]

classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache 2.0 License",
"Programming Language :: Python",
]


[project.optional-dependencies]

dev = [
"build",
"pyright",
"ruff",
"pre-commit",
"ipython",
"pandas",
"portpicker",
"pytest",
"pytest-cov",
"pytest-xdist",
"scikit-learn",
"scipy",
]
backends = [
"tensorflow>=2.17",
"jax[cpu]",
"torch@https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.4.1%2Bcpu.cxx11.abi-cp311-cp311-linux_x86_64.whl",
]
bayesian = ["scikit-learn", "scipy"]

# [tool.setuptools.packages.find]

[tool.setuptools.dynamic]
# The version number will be read from __version__ in src/pkgsample/__init__.py
version.attr = "keras_tuner.__version__"

[tool.setuptools.packages.find]
where = ["src"]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project.urls]
"Issue tracker" = "https://github.com/ghsanti/keras-tuner/issues"
github = "https://github.com/ghsanti/keras-tuner"
changelog = "https://github.com/ghsanti/keras-tuner/blob/master/CHANGELOG.md"

#================={TOOLS CONFIGURATION===================
# ruff, pyright, ruff.lint, ruff.format, pytest, codecov.
[tool.ruff]
include = ["./src"]
exclude = [
"shell",
"logs",
".eggs",
".git",
".ipynb_checkpoints",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".vscode",
"__pypackages__",
"_build",
"build",
"dist",
"node_modules",
"site-packages",
".venv",
"*_pb2.py",
"*_pb2_grpc.py",
"src/**/protos/**",
]

line-length = 80
indent-width = 4
target-version = "py311"

[tool.pyright]
include = ["src"]
exclude = ["src/**/protos/**"]
defineConstant = { DEBUG = true }
stubPath = "src/stubs"

reportMissingImports = "error"
reportMissingTypeStubs = false

pythonVersion = "3.11"

[tool.ruff.lint] # for code best practices.

dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

select = ['ALL']
ignore = [
"E226",
"E24",
# Function name should be lowercase
"N802",
# Argument name should be lowercase
"N803",
# First argument of a method should be named
"N805",
# Argument name should be lowercase
"N806",
# lowercase ... imported as non lowercase
# Useful to ignore for "import keras.backend as K"
"N812",
# do not use bare 'except'
"E722",
# Escape characters check.
# Conflict with pytest error message regex.
"W605",
"T201",
"D203",
"D211", # no blank line before class (ignoring)
"D213", # multi line summary second line (ignore)
"COM812",
"ISC001",
"T201", # allow print statements.
]


# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402", "F401", "EXE002"]
"**/{tests,docs,tools}/*" = ["E402"]
"**/*_test.py" = ["D103", "ANN201"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
docstring-code-format = true
docstring-code-line-length = "dynamic"

[tool.pytest.ini_options]
addopts = "-vv -p no:warnings --log-cli-level=CRITICAL --durations=10"
# norecursedirs = "build"

[tool.coverage.report]
exclude_lines = ["pragma: no cover", "@abstract", "raise NotImplementedError"]
omit = ["*test*", "src/**/protos/*", "src/**/distribute/file_utils.py"]
Loading

0 comments on commit c2dcba8

Please sign in to comment.