Skip to content

Commit

Permalink
Migrate to UV (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Dec 11, 2024
1 parent 3d841b1 commit 9fa3200
Show file tree
Hide file tree
Showing 11 changed files with 28,105 additions and 2,593 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/eval.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will run integration tests for the current project once per day

name: Evaluation

on:
schedule:
- cron: "37 14 * * *" # Run at 7:37 AM Pacific Time (14:37 UTC) every day
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI

# If another scheduled run starts while this workflow is still running,
# cancel the earlier run in favor of the next run.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
integration-tests:
name: Evaluation
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --all-extras --dev
uv pip install -U pytest-asyncio vcrpy
- name: Run integration tests
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
LANGSMITH_TRACING: true
run: |
make evals
32 changes: 10 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,34 @@ name: Unit Tests
on:
push:
branches: [main]
paths:
- "python/**"
pull_request:
paths:
- "python/**"
- "trustcall/**"
workflow_dispatch:

env:
POETRY_VERSION: "1.4.2"
UV_SYSTEM_PYTHON: 1

jobs:
build_and_test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
name: Setup python ${{ matrix.python-version }}
id: setup-python
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install poetry
shell: bash
env:
PYTHON_VERSION: ${{ matrix.python-version }}
# Install poetry using the python version installed by setup-python step.
run: pipx install "poetry==$POETRY_VERSION" --python '${{ steps.setup-python.outputs.python-path }}' --verbose
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
poetry install --with dev
uv sync --all-extras --dev
- name: Build ${{ matrix.python-version }}
run: poetry build
run: uv build
- name: Lint ${{ matrix.python-version }}
run: make lint
- name: Run Unit tests ${{ matrix.python-version }}
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
.PHONY: tests lint format doctest integration_tests_fast evals

tests:
poetry run python -m pytest --disable-socket --allow-unix-socket -n auto --durations=10 tests/unit_tests
uv run python -m pytest --disable-socket --allow-unix-socket -vv --durations=10 tests/unit_tests

tests_watch:
poetry run ptw --now . -- -vv -x tests/unit_tests
uv run ptw --now . -- -vv -x tests/unit_tests

integration_tests:
poetry run python -m pytest -v --durations=10 --cov=trustcall --cov-report=term-missing --cov-report=html --cov-config=.coveragerc tests/integration_tests
uv run python -m pytest -v --durations=10 --cov=trustcall --cov-report=term-missing --cov-report=html --cov-config=.coveragerc tests/integration_tests

integration_tests_fast:
poetry run python -m pytest -n auto --durations=10 -v --cov=trustcall --cov-report=term-missing --cov-report=html --cov-config=.coveragerc tests/integration_tests
uv run python -m pytest -n auto --durations=10 -v --cov=trustcall --cov-report=term-missing --cov-report=html --cov-config=.coveragerc tests/integration_tests

evals:
LANGCHAIN_TEST_CACHE=tests/evals/cassettes poetry run python -m pytest -p no:asyncio --max-asyncio-tasks 4 tests/evals/test_evals.py
LANGCHAIN_TEST_CACHE=tests/evals/cassettes uv run python -m pytest tests/evals/test_evals.py

lint:
poetry run ruff check .
poetry run mypy .
uv run ruff check .
uv run mypy .

doctest:
poetry run python -m pytest -n auto --durations=10 --doctest-modules trustcall
uv run python -m pytest -n auto --durations=10 --doctest-modules trustcall

format:
ruff check --select I --fix
poetry run ruff format .
poetry run ruff check . --fix
uv run ruff format .
uv run ruff check . --fix

build:
poetry build
uv build

publish:
poetry publish --dry-run
uv publish --dry-run
Loading

0 comments on commit 9fa3200

Please sign in to comment.