Skip to content
Closed
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
59 changes: 15 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,49 +35,16 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.11"
# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: cache poetry install
uses: actions/cache@v3
# Install uv for fast Python package management
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
path: ~/.local
key: poetry-1.7.1
# Install Poetry. You could do this manually, or there are several actions that do this.
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# Poetry's default install script, which feels correct. I pin the Poetry version here
# because Poetry does occasionally change APIs between versions and I don't want my
# actions to break if it does.
#
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
# venv as a `.venv` in your testing directory, which allows the next step to easily
# cache it.
- uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: cache deps
id: cache-deps
uses: actions/cache@v3
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
# Now install _your_ project. This isn't necessary for many types of projects -- particularly
# things like Django apps don't need this. But it's a good idea since it fully-exercises the
# pyproject.toml and makes that if you add things like console-scripts at some point that
# they'll be installed and working.
- run: poetry install --no-interaction
enable-cache: true
# Create virtual environment and install dependencies
- name: Create virtual environment and install dependencies
run: |
uv venv
uv pip install -e .[dev]
# Finally, run pre-commit.
- name: Run all pre-commit hooks
uses: pre-commit/[email protected]
Expand All @@ -102,14 +69,18 @@ jobs:
AZURE_GPT4O_MINI_API_VERSION: "dummy"
AWS_REGION: "us-east-1"
ENABLE_BEDROCK: "true"
run: poetry run ./run_alembic_check.sh
run: |
source .venv/bin/activate
./run_alembic_check.sh
- name: trigger tests
env:
ENABLE_OPENAI: "true"
OPENAI_API_KEY: "sk-dummy"
AWS_ACCESS_KEY_ID: "dummy"
AWS_SECRET_ACCESS_KEY: "dummy"
run: poetry run pytest
run: |
source .venv/bin/activate
pytest
fe-lint-build:
name: Frontend Lint and Build
runs-on: ubuntu-latest
Expand Down
57 changes: 13 additions & 44 deletions .github/workflows/sdk-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,24 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.11"
# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: cache poetry install
uses: actions/cache@v3
# Install uv for fast Python package management
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
path: ~/.local
key: poetry-1.7.1
# Install Poetry. You could do this manually, or there are several actions that do this.
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# Poetry's default install script, which feels correct. I pin the Poetry version here
# because Poetry does occasionally change APIs between versions and I don't want my
# actions to break if it does.
#
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
# venv as a `.venv` in your testing directory, which allows the next step to easily
# cache it.
- uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: cache deps
id: cache-deps
uses: actions/cache@v3
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
# Now install _your_ project. This isn't necessary for many types of projects -- particularly
# things like Django apps don't need this. But it's a good idea since it fully-exercises the
# pyproject.toml and makes that if you add things like console-scripts at some point that
# they'll be installed and working.
- run: poetry install --no-interaction
enable-cache: true
# Create virtual environment and install dependencies
- name: Create virtual environment and install dependencies
run: |
uv venv
uv pip install -e .[dev]
- name: Clean dist directory
run: rm -rf dist
- name: Build Package
run: poetry build
run: uv build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: poetry run twine upload --repository pypi dist/*
run: |
source .venv/bin/activate
twine upload --repository pypi dist/*
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ FROM python:3.11 AS requirements-stage
# Run `skyvern init llm` before building to generate the .env file

WORKDIR /tmp
RUN pip install poetry
RUN poetry self add poetry-plugin-export
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
Copy link
Contributor

Choose a reason for hiding this comment

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

Pin the uv version instead of using 'latest' to ensure reproducible Docker builds.

Suggested change
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
COPY --from=ghcr.io/astral-sh/uv:v0.1.23 /uv /bin/uv

COPY ./pyproject.toml /tmp/pyproject.toml
COPY ./poetry.lock /tmp/poetry.lock
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
RUN uv export --format requirements-txt --no-hashes --no-dev --output-file requirements.txt

FROM python:3.11-slim-bookworm
WORKDIR /app
Expand Down
136 changes: 136 additions & 0 deletions MIGRATION_FROM_POETRY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Migration from Poetry to uv

This document outlines the migration from Poetry to uv for dependency management in the Skyvern project.

## What Changed

### 1. Project Configuration
- **pyproject.toml**: Updated from Poetry format to standard PEP 621 format with uv/hatchling
- **Build system**: Switched from `poetry.core.masonry.api` to `hatchling.build`
- **Dependencies**: Converted from Poetry's caret notation (`^1.0.0`) to standard version specifiers (`>=1.0.0`)

### 2. CI/CD Workflows
- **GitHub Actions**: Replaced `snok/install-poetry` with `astral-sh/setup-uv`
- **Dependency installation**: Changed from `poetry install` to `uv pip install -e .[dev]`
- **Build commands**: Updated from `poetry build` to `uv build`

### 3. Docker
- **Multi-stage build**: Updated to use uv for requirements export instead of Poetry
- **Dependency installation**: Now uses `uv export` instead of `poetry export`

### 4. Development Scripts
- **run_skyvern.sh**: Updated to use uv for virtual environment management
- **Virtual environment**: Now uses `.venv` directory created by uv

## Benefits of uv

1. **Speed**: uv is significantly faster than Poetry for dependency resolution and installation
2. **Standards compliance**: Better adherence to Python packaging standards (PEP 621, PEP 517)
3. **Simpler toolchain**: Reduced complexity with fewer moving parts
4. **Better caching**: More efficient dependency caching in CI/CD

## Developer Migration Guide

### Prerequisites
Install uv if you haven't already:
```bash
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

# pip
pip install uv
```

### Local Development Setup

1. **Remove existing Poetry environment** (optional):
```bash
rm -rf .venv
```

2. **Create new virtual environment with uv**:
```bash
uv venv
```

3. **Install dependencies**:
```bash
# Install all dependencies including dev dependencies
uv pip install -e .[dev]

# Or just main dependencies
uv pip install -e .
```

4. **Activate virtual environment**:
```bash
source .venv/bin/activate # Linux/macOS
# or
.venv\\Scripts\\activate # Windows
```

### Common Commands

| Poetry Command | uv Equivalent |
|----------------|---------------|
| `poetry install` | `uv pip install -e .[dev]` |
| `poetry add package` | `uv add package` |
| `poetry remove package` | `uv remove package` |
| `poetry build` | `uv build` |
| `poetry run command` | `command` (after activating venv) |
| `poetry shell` | `source .venv/bin/activate` |
| `poetry export -f requirements.txt` | `uv export --format requirements-txt` |

### Integration Packages

The integration packages (`integrations/langchain` and `integrations/llama_index`) have also been migrated:

```bash
# For langchain integration
cd integrations/langchain
uv pip install -e .[dev]

# For llama_index integration
cd integrations/llama_index
uv pip install -e .[dev]
```

## Troubleshooting

### Virtual Environment Issues
If you encounter issues with the virtual environment:
```bash
# Remove and recreate
rm -rf .venv
uv venv
uv pip install -e .[dev]
```

### Dependency Resolution Issues
If you encounter dependency conflicts:
```bash
# Clear uv cache
uv cache clean

# Try installing with verbose output
uv pip install -e .[dev] --verbose
```

### CI/CD Issues
The CI/CD workflows have been updated to use uv. If you encounter issues:
1. Check that the `astral-sh/setup-uv@v4` action is being used
2. Ensure virtual environment activation with `source .venv/bin/activate`
3. Use `uv pip install -e .[dev]` for dependency installation

## Rollback Plan

If you need to rollback to Poetry temporarily:

1. Restore the previous `pyproject.toml` format
2. Run `poetry install` to recreate the Poetry environment
3. Update CI/CD workflows to use Poetry actions

However, the migration to uv provides significant benefits and is recommended for long-term maintenance.
Loading
Loading