Skip to content

Commit

Permalink
Use rye for package management (#284)
Browse files Browse the repository at this point in the history
Alternative to #283

---------

Signed-off-by: Mattt Zmuda <mattt@replicate.com>
  • Loading branch information
mattt authored Jun 28, 2024
1 parent 59f19a9 commit ec459ed
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 162 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: eifinger/setup-rye@v2
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
enable-cache: true

- name: Setup
run: ./script/setup
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.2
20 changes: 11 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ dependencies = [
"pydantic>1.10.7",
"typing_extensions>=4.5.0",
]
optional-dependencies = { dev = [
"pylint",
"pyright",
"pytest",
"pytest-asyncio",
"pytest-recording",
"respx",
"ruff>=0.3.3",
] }

[project.urls]
homepage = "https://replicate.com"
repository = "https://github.com/replicate/replicate-python"

[tool]
rye = { dev-dependencies = [
"pytest>=8.1.1",
"pylint>=3.1.0",
"pyright>=1.1.358",
"pytest-asyncio>=0.23.6",
"pytest-recording>=0.13.1",
"respx>=0.21.1",
"ruff>=0.3.7",
] }

[tool.pytest.ini_options]
testpaths = "tests/"

Expand Down
2 changes: 1 addition & 1 deletion replicate/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from importlib.metadata import version

__version__ = version(__package__)
__version__ = version(__package__ if __package__ is not None else "replicate")
3 changes: 1 addition & 2 deletions replicate/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ def output_iterator(self) -> Iterator[Any]:

output = self.output or []
new_output = output[len(previous_output) :]
for output in new_output:
yield output
yield from new_output

async def async_output_iterator(self) -> AsyncIterator[Any]:
"""
Expand Down
81 changes: 81 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:.
annotated-types==0.6.0
# via pydantic
anyio==4.3.0
# via httpx
astroid==3.1.0
# via pylint
certifi==2024.2.2
# via httpcore
# via httpx
dill==0.3.8
# via pylint
h11==0.14.0
# via httpcore
httpcore==1.0.5
# via httpx
httpx==0.27.0
# via replicate
# via respx
idna==3.7
# via anyio
# via httpx
# via yarl
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via pylint
mccabe==0.7.0
# via pylint
multidict==6.0.5
# via yarl
nodeenv==1.8.0
# via pyright
packaging==24.0
# via pytest
# via replicate
platformdirs==4.2.0
# via pylint
pluggy==1.4.0
# via pytest
pydantic==2.7.0
# via replicate
pydantic-core==2.18.1
# via pydantic
pylint==3.1.0
pyright==1.1.358
pytest==8.1.1
# via pytest-asyncio
# via pytest-recording
pytest-asyncio==0.23.6
pytest-recording==0.13.1
pyyaml==6.0.1
# via vcrpy
respx==0.21.1
ruff==0.3.7
setuptools==69.2.0
# via nodeenv
sniffio==1.3.1
# via anyio
# via httpx
tomlkit==0.12.4
# via pylint
typing-extensions==4.11.0
# via pydantic
# via pydantic-core
# via replicate
vcrpy==6.0.1
# via pytest-recording
wrapt==1.16.0
# via vcrpy
yarl==1.9.4
# via vcrpy
93 changes: 0 additions & 93 deletions requirements-dev.txt

This file was deleted.

39 changes: 39 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:.
annotated-types==0.6.0
# via pydantic
anyio==4.3.0
# via httpx
certifi==2024.2.2
# via httpcore
# via httpx
h11==0.14.0
# via httpcore
httpcore==1.0.5
# via httpx
httpx==0.27.0
# via replicate
idna==3.7
# via anyio
# via httpx
packaging==24.0
# via replicate
pydantic==2.7.0
# via replicate
pydantic-core==2.18.1
# via pydantic
sniffio==1.3.1
# via anyio
# via httpx
typing-extensions==4.11.0
# via pydantic
# via pydantic-core
# via replicate
40 changes: 0 additions & 40 deletions requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions script/format
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#!/bin/sh

set -e

python -m ruff format .
exec rye fmt .
12 changes: 6 additions & 6 deletions script/lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ set -e
STATUS=0

echo "Running pyright"
python -m pyright replicate || STATUS=$?
rye run pyright replicate || STATUS=$?
echo ""

echo "Running pylint"
python -m pylint --exit-zero replicate || STATUS=$?
rye run pylint --exit-zero replicate || STATUS=$?
echo ""

echo "Running ruff check"
python -m ruff check . || STATUS=$?
echo "Running rye lint"
rye lint . || STATUS=$?
echo ""

echo "Running ruff format check"
python -m ruff format --check . || STATUS=$?
echo "Running rye fmt --check"
rye fmt --check || STATUS=$?
echo ""

exit $STATUS
29 changes: 26 additions & 3 deletions script/setup
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
#!/bin/bash
#!/bin/sh

set -e
set -eu

python -m pip install -r requirements.txt -r requirements-dev.txt .
: "${RYE_INSTALL_OPTION:='--yes'}"
: "${RYE_VERSION:='latest'}"

if ! command -v rye > /dev/null 2>&1
then
echo "rye is not installed."
printf "Do you want to install rye? (y/n) "
read -r REPLY
echo # move to a new line
case "$REPLY" in
[yY])
echo "Installing rye..."
curl -sSf https://rye-up.com/get | sh
echo "rye has been successfully installed."
;;
*)
exit 1
;;
esac
else
echo "rye is already installed."
fi

exec rye sync
4 changes: 2 additions & 2 deletions script/test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#!/bin/sh

set -e

python -m pytest -v
exec rye test -v

0 comments on commit ec459ed

Please sign in to comment.