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

[RFC] move to PEP 621 compliant package manager for better extras #905

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 4 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,22 @@ repos:
hooks:
- id: isort
name: isort-local
entry: poetry run isort
entry: rye run isort
language: system
types: [python]
pass_filenames: true
- id: flake8
name: flake8-local
entry: poetry run flake8
entry: rye run flake8
language: system
types: [python]
pass_filenames: true
- id: mypy
name: mypy-local
entry: poetry run mypy
entry: rye run mypy
language: python
types: [python]
exclude: ^examples/|^truss/test.+/|model.py$|^truss-chains/.*
pass_filenames: true
- id: mypy
name: mypy-local (3.9)
entry: poetry run mypy
language: python
types: [python]
files: ^truss-chains/.*
exclude: ^examples/|^truss/test.+/|model.py$
args:
- --python-version=3.9
pass_filenames: true
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.11
3.10.13
2 changes: 0 additions & 2 deletions .tool-versions

This file was deleted.

6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true,
"source.sortMembers": true
"source.fixAll": "explicit",
"source.organizeImports": "explicit",
"source.sortMembers": "explicit"
}
}
}
33 changes: 15 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,34 @@ We use GitHub features for project management on Truss:
To get started contributing to the library, all you have to do is clone this repository!

### Setup
We use [`rye`](https://rye-up.com/) to manage Python environments, dependencies and packaging (via [`hatchiling`](https://hatch.pypa.io/latest/)).

**PLEASE NOTE:** the ML ecosystem in general is still not well supported on M1 Macs, and as such, we do not recommend or support local development on M1 for Truss. Truss is well-optimized for use with GitHub Codespaces and other container-based development environments.

We use `asdf` to manage Python binaries and `poetry` to manage Python dependencies.

For development in a macOS environment, we use `brew` to manage system packages.
For development:

```bash
# Install asdf (or use another method https://asdf-vm.com/)
brew install asdf

# Install `asdf` managed python and poetry
asdf plugin add python
asdf plugin add poetry
asdf install
# Install rye: https://rye-up.com/guide/installation/#installing-rye
curl -sSf https://rye-up.com/get | bash

# Install poetry dependencies
poetry install
# Add to shell
echo 'source "$HOME/.rye/env"' >> ~/.bashrc

# And finally precommit
poetry run pre-commit install
# Setup environment (includes python version and dependencies)
rye sync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pre-commit automatically installed by rye?

```

Then to run the entire test suite

```bash
poetry run pytest truss/tests
rye run pytest truss/tests
```
### Build Wheel for release
TODO: thils will automated in CI soon
```bash
rye build --wheel --pyproject ./pyproject.toml --clean --verbose
```

## Documentation

To learn about Truss see the [official documentation](https://truss.baseten.co).

Contributions to documentation are very welcome! Simply edit the appropriate markdown files in the `docs/` folder and make a pull request. For larger changes, tutorials, or any questions please contact [team@trussml.com](mailto:team@trussml.com).
Contributions to documentation are very welcome! Simply edit the appropriate markdown files in the `docs/` folder and make a pull request. For larger changes, tutorials, or any questions please contact [hi@baseten.co](mailto:hi@baseten.co).
19 changes: 9 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

202 changes: 107 additions & 95 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,122 +1,134 @@
[tool.poetry]
[project]
name = "truss"
version = "0.9.9"
dynamic = ["version"]
description = "A seamless bridge from model development to model delivery"
license = "MIT"
license = { text = "MIT" }
authors = [
{ name = "Pankaj Gupta", email = "pankaj@baseten.co" },
{ name = "Phil Howes", email = "phil@baseten.co" },
]
maintainers = [{ name = "Baseten Labs", email = "hi@baseten.co" }]
# Required dependencies. Includes everything for CLI
dependencies = [
# Core dependencies
"blake3<1.0.0,>=0.3.3",
"httpx<1.0.0,>=0.24.1",
"numpy>=1.23.5",
"packaging>=20.9",
"pathspec>=0.9.0",
"pydantic>=1.10.0",
"PyYAML>=6.0",
"tenacity<9.0.0,>=8.0.1",

# CLI Dependencies
"inquirerpy<1.0.0,>=0.3.4",
"watchfiles<1.0.0,>=0.19.0",
"rich<14.0.0,>=13.4.2",
"rich-click<2.0.0,>=1.6.1",

# Chains dependencies. Runs in CLI
"datamodel-code-generator<1.0.0,>=0.25.4",
"libcst<1.2.0",
"autoflake<=2.2",
]
readme = "README.md"
authors = ["Pankaj Gupta <pankaj@baseten.co>", "Phil Howes <phil@baseten.co>"]
include = ["*.txt", "*.Dockerfile", "*.md"]
repository = "https://github.com/basetenlabs/truss"
keywords = [
"MLOps",
"AI",
"Model Serving",
"Model Deployment",
"Machine Learning",
]
packages = [
{ include = "truss", from = "." },
{ include = "truss_chains", from = "./truss-chains" }
requires-python = "<3.12,>=3.9"

[project.optional-dependencies]
server = [
"aiocontextvars>=0.2.2",
"argparse>=1.4.0",
'cython>=3.0.5',
"fastapi>=0.109.1",
"python-json-logger>=2.0.2",
"msgpack-numpy>=0.4.8",
"msgpack>=1.0.2",
"psutil>=5.9.4",
"requests>=2.31.0",
"uvicorn>=0.24.0",
"uvloop>=0.17.0",
]
builder = [
"blake3<1.0.0,>=0.3.3",
"boto3<2.0.0,>=1.26.157",
"click<9.0.0,>=8.0.3",
"fastapi>=0.109.1",
"Jinja2<4.0.0,>=3.1.2",
"google-cloud-storage==2.10.0",
"httpx<1.0.0,>=0.24.1",
"huggingface-hub>=0.19.4",
"Jinja2<4.0.0,>=3.1.2",
"loguru>=0.7.2",
"packaging>=20.9",
"pathspec>=0.9.0",
"psutil>=5.9.4",
"python<3.12,>=3.8",
"python-json-logger>=2.0.2",
"PyYAML>=6.0",
"requests>=2.31",
"tenacity<9.0.0,>=8.0.1",
"uvicorn<1.0.0,>=0.24.0",
"python-on-whales<1.0.0,>=0.68.0",
]
cache-warmer = [
"boto3<2.0.0,>=1.26.157",
"google-cloud-storage>=2.10.0",
"huggingface-hub>=0.19.4",
"hf-transfer>=0.1.3",
]


[tool.poetry.urls]
"Homepage" = "https://truss.baseten.co"
[project.urls]
Homepage = "https://truss.baseten.co"
"Bug Reports" = "https://github.com/basetenlabs/truss/issues"
"Documentation" = "https://truss.baseten.co"
"Baseten" = "https://baseten.co"

[tool.poetry.dependencies]
blake3 = "^0.3.3"
boto3 = "^1.26.157"
fastapi = ">=0.109.1"
google-cloud-storage = "2.10.0"
httpx = "^0.24.1"
huggingface_hub = ">=0.19.4"
inquirerpy = "^0.3.4"
Jinja2 = "^3.1.2"
loguru = ">=0.7.2"
msgpack = ">=1.0.2"
msgpack-numpy = ">=0.4.8"
numpy = ">=1.23.5"
packaging = ">=20.9"
pathspec = ">=0.9.0"
psutil = ">=5.9.4"
pydantic = ">=1.10.0"
python = ">=3.8,<3.12"
python-json-logger = ">=2.0.2"
python-on-whales = "^0.68.0"
PyYAML = ">=6.0"
rich = "^13.4.2"
rich-click = "^1.6.1"
single-source = "^0.3.0"
tenacity = "^8.0.1"
watchfiles = "^0.19.0"

[tool.poetry.group.builder.dependencies]
blake3 = "^0.3.3"
boto3 = "^1.26.157"
click = "^8.0.3"
fastapi = ">=0.109.1"
google-cloud-storage = "2.10.0"
httpx = "^0.24.1"
huggingface_hub = ">=0.19.4"
Jinja2 = "^3.1.2"
loguru = ">=0.7.2"
packaging = ">=20.9"
pathspec = ">=0.9.0"
psutil = ">=5.9.4"
python = ">=3.8,<3.12"
python-json-logger = ">=2.0.2"
PyYAML = ">=6.0"
requests = ">=2.31"
single-source = "^0.3.0"
tenacity = "^8.0.1"
uvicorn = "^0.24.0"
Documentation = "https://truss.baseten.co"
Baseten = "https://baseten.co"
repository = "https://github.com/basetenlabs/truss"

[tool.poetry.dev-dependencies]
black = "^22.6.0"
coverage = "^6.4.1"
dockerfile = "^3.2.0"
flake8 = "^4.0.1"
ipdb = "^0.13.9"
ipykernel = "^6.16.0"
ipython = "^7.16"
isort = "^5.10.1"
nbconvert = "^7.2.1"
pre-commit = "^2.18.1"
pytest = "7.2.0"
pytest-cov = "^3.0.0"
types-PyYAML = "^6.0.12.12"
types-setuptools = "^69.0.0.0"
[project.scripts]
truss = "truss.cli:truss_cli"

[tool.poetry.scripts]
truss = 'truss.cli:truss_cli'
[tool.rye]
managed = true
dev-dependencies = [
"flask<3.0.0,>=2.3.3",
"httpx[cli]<1.0.0,>=0.24.1",
"mypy<2.0.0,>=1.0.0",
"pytest-split<1.0.0,>=0.8.1",
"requests-mock>=1.11.0",
"types-requests>=2.31.0.2",
"uvicorn>=0.24.0",
"uvloop>=0.17.0",
"flake8>=7.0.0",
]

[tool.poetry.group.dev.dependencies]
flask = "^2.3.3"
httpx = { extras = ["cli"], version = "^0.24.1" }
mypy = "^1.0.0"
pytest-split = "^0.8.1"
requests-mock = ">=1.11.0"
types-requests = ">=2.31.0.2"
uvicorn = ">=0.24.0"
uvloop = ">=0.17.0"
## Package Build
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.version]
path = "truss/__init__.py"

[tool.poetry.group.truss-chains.dependencies]
datamodel-code-generator = "^0.25.4"
libcst = "<1.2.0"
autoflake = "<=2.2"
[tool.hatch.metadata]
allow-direct-references = true

[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.2.1"]
[tool.hatch.build.targets.wheel]
only-packages = true
packages = ["src/truss"]

## Lint Tools
bolasim marked this conversation as resolved.
Show resolved Hide resolved
[tool.isort]
profile = "black"
src_paths = ["isort", "test"]

[tool.mypy]
ignore_missing_imports = true
python_version = "3.8"
python_version = "3.9"
Loading