-
Notifications
You must be signed in to change notification settings - Fork 9
feat: migrate to uv #53
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
Conversation
Ref: #52 Signed-off-by: Tomas Dvorak <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @Tomas2D, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request transitions the project's Python dependency management and build processes from Poetry to uv. This change is intended to enhance the efficiency of dependency installation and project execution by leveraging uv's speed, with corresponding updates to documentation and configuration files to reflect the new tooling.
Highlights
- Package Manager Migration: The project has migrated its Python package management from Poetry to uv, a fast Python package installer and resolver, aiming for improved performance and streamlined workflows.
- Build System Update: The pyproject.toml configuration has been updated to use hatchling as the build backend, aligning with uv's ecosystem and standard Python packaging practices.
- Documentation Alignment: Both README.md and DEVELOP.md have been revised to reflect the new uv-based commands and setup instructions, ensuring consistency and ease of use for developers.
- Python Version Specification: A new .python-version file has been added to explicitly declare Python 3.11 as the required version for the project.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Signed-off-by: Tomas Dvorak <[email protected]> # Conflicts: # poetry.lock # pyproject.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request migrates the project's dependency management and build system from Poetry to uv
and hatch
. The changes primarily involve updating pyproject.toml
to the standard format, replacing poetry
commands with uv
commands in the documentation (README.md
, DEVELOP.md
), and adding a .python-version
file. My review focuses on the documentation changes to ensure clarity and reproducibility. I've suggested pinning the Docker image version in README.md
for better reproducibility and pointed out a potentially unintentional removal of the (Optional)
keyword in an instruction.
Ref: #52 Signed-off-by: Tomas Dvorak <[email protected]>
timeout-minutes: 10 | ||
name: Lint & Build & Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
cache: "poetry" | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v6 | ||
|
||
- name: Set up Python | ||
run: uv python install | ||
|
||
- name: Install dependencies | ||
run: poetry install --no-interaction | ||
run: uv sync --all-extras --locked --dev | ||
|
||
- name: Code Lint | ||
run: poetry run poe lint | ||
run: uv run poe lint | ||
|
||
- name: Type check task with mypy | ||
run: poetry run poe type-check -- -- --show-error-context --pretty | ||
run: uv run poe type-check -- --show-error-context --pretty | ||
|
||
- name: Code Format | ||
run: poetry run poe format | ||
run: uv run poe format | ||
|
||
- name: Build | ||
run: poetry build | ||
run: uv build |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 18 hours ago
The best practice for GitHub Actions workflows is to explicitly specify the permissions
key at either the workflow (root) level or at the job level. For this workflow, adding permissions: { contents: read }
at the top level will ensure that all jobs default to the minimal required permissions, adhering to the principle of least privilege.
To fix the issue, add the following block on a new line after the workflow name
declaration (after line 1 and before on:
at line 3):
permissions:
contents: read
No changes are required elsewhere, as the workflow otherwise appears standard.
-
Copy modified lines R2-R3
@@ -1,4 +1,6 @@ | ||
name: Lint, Build | ||
permissions: | ||
contents: read | ||
|
||
on: | ||
push: |
uses: astral-sh/setup-uv@v6 | ||
|
||
- name: Set up Python | ||
run: uv python install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be necessary AFAIK, uv sync
downloads the correct Python when creating venv
@@ -35,9 +35,9 @@ With the githooks installed the following will run automatically on a commit: | |||
* [mypy](https://github.com/python/mypy) is used to check for type errors | |||
* a simple format check is applied to the commit message to verify for use of [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) | |||
|
|||
Additional tools are integrated into poetry via the [poetry plugin](https://poethepoet.natn.io/poetry_plugin.html) | |||
Additional tools are provided via [Poe the Poet](https://github.com/nat-n/poethepoet) tasks and can be run with uv. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also possible to ditch Poe and use project scripts:
...just mind the caveat that if the project is a library, these scripts get installed alongside it. So it's only usable for apps.
(Or we could unify and use Mise, but I'm probably overthinking this.)
|
||
Tools can also be run directly via the command line (run within `poetry shell` or prefix with `poetry run`): | ||
Tools can be run directly via the command line (activate the venv or prefix commands with `uv run`): | ||
|
||
* `poe lint` - lints and formats your code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should write these as prefixed (uv run poe lint
etc.) so people skimming this could just copy the command
requires = ["poetry-core>=2.0.0,<3.0.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
requires = ["hatchling>=1.18"] | ||
build-backend = "hatchling.build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the uv native build backend (example: https://github.com/i-am-bee/beeai-platform/blob/a5911f59be15fc9685144ac791575aaebc0687b7/apps/beeai-cli/pyproject.toml#L43-L49)
@@ -24,13 +24,13 @@ This starter template helps you **quickly** get started with the [BeeAI framewor | |||
## 📋 Requirements | |||
|
|||
- **Python Version 3.11+** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically you don't need this anymore, uv
will download correct Python if not present when creating the venv
|
||
You have two options: | ||
|
||
**Option 1:** Interactive mode | ||
```sh | ||
python beeai_framework_starter/agent.py | ||
uv run python beeai_framework_starter/agent.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv run python beeai_framework_starter/agent.py | |
uv run beeai_framework_starter/agent.py |
``` | ||
|
||
**Option 2:** Define your prompt up front | ||
```sh | ||
python beeai_framework_starter/agent.py <<< "I am going out tomorrow morning to walk around Boston. What should I plan to wear?" | ||
uv run python beeai_framework_starter/agent.py <<< "I am going out tomorrow morning to walk around Boston. What should I plan to wear?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv run python beeai_framework_starter/agent.py <<< "I am going out tomorrow morning to walk around Boston. What should I plan to wear?" | |
uv run beeai_framework_starter/agent.py <<< "I am going out tomorrow morning to walk around Boston. What should I plan to wear?" |
```sh | ||
python beeai_framework_starter/agent_code_interpreter.py <<< "Calculate 534*342?" | ||
uv run python beeai_framework_starter/agent_code_interpreter.py <<< "Calculate 534*342?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv run python beeai_framework_starter/agent_code_interpreter.py <<< "Calculate 534*342?" | |
uv run beeai_framework_starter/agent_code_interpreter.py <<< "Calculate 534*342?" |
```sh | ||
python beeai_framework_starter/agent_code_interpreter.py <<< "Generate a riddle" | ||
uv run python beeai_framework_starter/agent_code_interpreter.py <<< "Generate a riddle" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv run python beeai_framework_starter/agent_code_interpreter.py <<< "Generate a riddle" | |
uv run beeai_framework_starter/agent_code_interpreter.py <<< "Generate a riddle" |
```sh | ||
python beeai_framework_starter/agent_workflow.py | ||
uv run python beeai_framework_starter/agent_workflow.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv run python beeai_framework_starter/agent_workflow.py | |
uv run beeai_framework_starter/agent_workflow.py |
Ref: #52