-
Notifications
You must be signed in to change notification settings - Fork 1
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
DEV-5295 | Replace poetry with uv #1638
DEV-5295 | Replace poetry with uv #1638
Conversation
…t-for-poetry-pyenv' of github.com:newsrevenuehub/rev-engine into DEV-5295-5-project-proof-of-concept-of-uv-as-replacement-for-poetry-pyenv
- name: Run tests | ||
run: | | ||
source .venv/bin/activate | ||
touch .env |
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 doesn't seem to have been needed.
" \ | ||
&& seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \ |
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 step does not appear to be required for our setup.
…-replacement-for-poetry-pyenv
@@ -23,3 +23,4 @@ export MAILCHIMP_CLIENT_SECRET= | |||
export REACT_APP_HUB_GOOGLE_MAPS_API_KEY= | |||
export REACT_APP_NRE_MAILCHIMP_CLIENT_ID=$MAILCHIMP_CLIENT_ID | |||
export RP_MAILCHIMP_LIST_CONFIGURATION_COMPLETE_TOPIC=rp-mailchimp-list-configuration-complete | |||
export VIRTUAL_ENV=".venv" |
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.
Maybe a comment as to what this is used by? [I don't see VIRTUAL_ENV referenced anywhere else]
|
||
##### Initial installation | ||
|
||
Ensure you have a system version of Python and uv installed. |
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.
nm, it's clear from general uv link above
Consider adding description or link to how to install uv
@@ -1,4 +1,6 @@ | |||
|
|||
VENV_DIR="./.venv" |
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.
Prepending superfluous "./" is weird.
|
||
setup: | ||
@echo 'Setting up the environment...' | ||
@test -d $(VENV_DIR) || uv venv $(VENV_DIR) && echo "Virtual environment created at $(VENV_DIR)" | ||
source $(VENV_DIR)/bin/activate |
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.
source is bash built in (for me under ubuntu) and make is using sh. Thus
source "./.venv"/bin/activate
/bin/sh: 1: source: not found
Setting default shell wfm, copied from
https://stackoverflow.com/questions/7507810/how-to-source-a-script-in-a-makefile
Makefile default shell is /bin/sh which does not implement source.
Changing shell to /bin/bash makes it possible:# Makefile SHELL := /bin/bash
``` | ||
|
||
Adding or removing dependencies will automatically update the `pyproject.toml` file and the `poetry.lock` file. | ||
Note that unlike Poetry, uv does not automatically update the `pyproject.toml` file and `uv.lock` files after adding/removing dependencies. You'll want to manually add/remove from `pyproject.toml` and you'll want to run `uv lock` to update the lockfile. |
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 would cut "unlike Poetry, "
Also consider moving this to top of section, under ### How to... [reckon it's harder to miss there].
|
||
install_requirements: | ||
@echo 'Installing project requirements...' | ||
poetry install --no-root | ||
uv sync --frozen | ||
|
||
setup: |
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 believe the method to "start work" is source $(VENV_DIR)/bin/activate
. It would be nice to have make entry for this
activate:
source $(VENV_DIR)/bin/activate
python --version
I miss poetry shell (or rather vex) there's workarounds astral-sh/uv#1910
|
||
- name: Set up Python and dependencies | ||
run: | | ||
uv venv create --python=python3.10 |
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.
Do we have "upgrade python docs"? If so should add mention to look here and in Dockerfile to update python versions.
@@ -48,15 +48,31 @@ repos: | |||
hooks: | |||
- id: ruff | |||
args: [ --fix ] | |||
- repo: https://github.com/astral-sh/uv-pre-commit | |||
# uv version. | |||
rev: 0.4.18 |
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.
The installer gave me version 0.4.20.
Leo and I have this problem with ruff. They upgrade it so frequently, often occurs between dev and review.
# We need to recreate the /usr/share/man/man{1..8} directories first because | ||
# they were clobbered by a parent image. | ||
# Copy uv tool | ||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/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.
latest is probably easier than updating specific version all the time?
"responses>=0.25.3", | ||
"ruff>=0.6.8", | ||
] | ||
|
||
# TODO @njh: reduce complexity to 10 or less |
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 comment should go with [tool.ruff.lint.mccabe]
section
[tool.uv]
was inserted in-between
Closing this PR because it's served purpose as PoC and we've decided not to move forward with uv in revengine just yet. |
Please fill out each section even if it's just with "N/A"
Plan? (if this draft/incomplete indicate what you intend to do and how)
What's this PR do?
This PR replaces poetry with uv which is a Python package and project manager written in Rust that is very fast and well documented.
This PR makes the following changes:
poetry install step
that do not appear to be needed.Why are we doing this? How does it help us?
uv is very fast, improves dev experience, and reduces complexity around virtual env management.
Are there detailed, specific, step-by-step testing instructions in the associated ticket?
Yes
Did this PR make changes to the user interface that may require changes to the user-facing docs?
No
Have automated unit tests been added? If not, why?
No. Not appropriate for this kind of change.
How should this change be communicated to end users?
N/A
Are there any smells or added technical debt to note?
No
Has this been documented? If so, where?
I created a confluence page to document the performance improvements vs. poetry
I also have drafted an updated version of our confluence page on updating revengine dependencies
What are the relevant tickets? Add a link to any relevant ones.
DEV-5295
Do any changes need to be made before deployment to production (adding environment variables, for example)? If so, open a ticket and link it to the ticket for this PR and list it here:
No
Are there next steps? If so, what? Have tickets been opened for them? List next-step tickets here:
No