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

chore: start migration from poetry to uv #1444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 16 additions & 12 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ jobs:
python-version: ["3.10", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: |
# Ensure dependencies are installed without relying on a lock file.
poetry update
poetry install -E server
run: uv pip install ".[server]"

- name: Test with pytest
run: |
poetry run pytest -s -x -k test_
uv run pytest -s -x -k test_
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

- name: Minimize uv cache
run: uv cache prune --ci
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ ipython_config.py
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
Expand Down Expand Up @@ -235,3 +231,8 @@ misc/

# Ignore litellm_uuid.txt
litellm_uuid.txt


# test files
file.txt
numbers.txt
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
###########################################################################################

FROM python:3.11.8
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

# Set environment variables
# ENV OPENAI_API_KEY ...
Expand All @@ -15,13 +16,13 @@ ENV HOST 0.0.0.0
RUN mkdir -p interpreter scripts
COPY interpreter/ interpreter/
COPY scripts/ scripts/
COPY poetry.lock pyproject.toml README.md ./
COPY uv.lock pyproject.toml README.md ./

# Expose port 8000
EXPOSE 8000

# Install server dependencies
RUN pip install ".[server]"
RUN uv pip install ".[server]"

# Start the server
ENTRYPOINT ["interpreter", "--server"]
ENTRYPOINT ["uv", "run", "interpreter", "--server"]
19 changes: 9 additions & 10 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,31 @@ We will review PRs when possible and work with you to integrate your contributio

## Running Your Local Fork

**Note: for anyone testing the new `--local`, `--os`, and `--local --os` modes: When you run `poetry install` you aren't installing the optional dependencies and it'll throw errors. To test `--local` mode, run `poetry install -E local`. To test `--os` mode, run `poetry install -E os`. To test `--local --os` mode, run `poetry install -E local -E os`. You can edit the system messages for these modes in `interpreter/terminal_interface/profiles/defaults`.**
**Note: for anyone testing the new `--local`, `--os`, and `--local --os` modes: When you run `uv pip install` you aren't installing the optional dependencies and it'll throw errors. To test `--local` mode, run `uv pip install ".[local]"`. To test `--os` mode, run `uv pip install ".[os]"`. To test `--local --os` mode, run `uv pip install ".[local,os]"`. You can edit the system messages for these modes in `interpreter/terminal_interface/profiles/defaults`.**

Once you've forked the code and created a new branch for your work, you can run the fork in CLI mode by following these steps:

1. CD into the project folder by running `cd open-interpreter`.
2. Install `poetry` [according to their documentation](https://python-poetry.org/docs/#installing-with-pipx), which will create a virtual environment for development + handle dependencies.
3. Install dependencies by running `poetry install`.
4. Run the program with `poetry run interpreter`. Run tests with `poetry run pytest -s -x`.
1. Install `uv` [according to their documentation](https://docs.astral.sh/uv/#highlights), which will create a virtual environment for development + handle dependencies.
2. Install python if you don't have it already. `uv python install 3.11.8`
3. Run the program with `uv run interpreter`. Run tests with `uv run pytest -s -x -k test_`.

**Note**: This project uses [`black`](https://black.readthedocs.io/en/stable/index.html) and [`isort`](https://pypi.org/project/isort/) via a [`pre-commit`](https://pre-commit.com/) hook to ensure consistent code style. If you need to bypass it for some reason, you can `git commit` with the `--no-verify` flag.

### Installing New Dependencies

If you wish to install new dependencies into the project, please use `poetry add package-name`.
If you wish to install new dependencies into the project, please use `uv add package-name`.

### Installing Developer Dependencies

If you need to install dependencies specific to development, like testing tools, formatting tools, etc. please use `poetry add package-name --group dev`.
If you need to install dependencies specific to development, like testing tools, formatting tools, etc. please use `uv sync --dev`.

### Known Issues

For some, `poetry install` might hang on some dependencies. As a first step, try to run the following command in your terminal:
For some machines, `uv install` errors out with `OSError: [Errno 24] Too many open files`. As a first step, try to run the following command in your terminal:

`export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring`
`ulimit -n 16000`

Then run `poetry install` again. If this doesn't work, please join our [Discord community](https://discord.gg/6p3fD6rBVm) for help.
Then run `uv pip install` or `uv run interpreter` again. If this doesn't work, please join our [Discord community](https://discord.gg/6p3fD6rBVm) for help.

## Code Formatting and Linting

Expand Down
4 changes: 2 additions & 2 deletions interpreter/core/utils/system_debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def get_ram_info():
def get_package_mismatches(file_path="pyproject.toml"):
with open(file_path, "r") as file:
pyproject = toml.load(file)
dependencies = pyproject["tool"]["poetry"]["dependencies"]
dev_dependencies = pyproject["tool"]["poetry"]["group"]["dev"]["dependencies"]
dependencies = pyproject["dependencies"]
dev_dependencies = pyproject["project"]["optional-dependencies"]
dependencies.update(dev_dependencies)

installed_packages = {pkg.key: pkg.version for pkg in pkg_resources.working_set}
Expand Down
Loading