-
Notifications
You must be signed in to change notification settings - Fork 620
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
Introduce Poetry as Dependency Manager and Update Dockerfiles #557
Open
lukefx
wants to merge
4
commits into
Codium-ai:main
Choose a base branch
from
lukefx:poetry-as-dependency-manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,243
−123
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ pr_agent/settings/.secrets.toml | |
pics/ | ||
pr_agent.egg-info/ | ||
build/ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,12 +77,13 @@ codiumai/[email protected] | |
|
||
``` | ||
git clone https://github.com/Codium-ai/pr-agent.git | ||
cd pr-agent | ||
``` | ||
|
||
2. Install the requirements in your favorite virtual environment: | ||
|
||
``` | ||
pip install -r requirements.txt | ||
poetry install | ||
``` | ||
|
||
3. Copy the secrets template file and fill in your OpenAI key and your GitHub user token: | ||
|
@@ -96,14 +97,14 @@ chmod 600 pr_agent/settings/.secrets.toml | |
4. Add the pr_agent folder to your PYTHONPATH, then run the cli.py script: | ||
|
||
``` | ||
export PYTHONPATH=[$PYTHONPATH:]<PATH to pr_agent folder> | ||
python3 -m pr_agent.cli --pr_url <pr_url> review | ||
python3 -m pr_agent.cli --pr_url <pr_url> ask <your question> | ||
python3 -m pr_agent.cli --pr_url <pr_url> describe | ||
python3 -m pr_agent.cli --pr_url <pr_url> improve | ||
python3 -m pr_agent.cli --pr_url <pr_url> add_docs | ||
python3 -m pr_agent.cli --pr_url <pr_url> generate_labels | ||
python3 -m pr_agent.cli --issue_url <issue_url> similar_issue | ||
poetry shell | ||
python -m pr_agent.cli --pr_url <pr_url> review | ||
python -m pr_agent.cli --pr_url <pr_url> ask <your question> | ||
python -m pr_agent.cli --pr_url <pr_url> describe | ||
python -m pr_agent.cli --pr_url <pr_url> improve | ||
python -m pr_agent.cli --pr_url <pr_url> add_docs | ||
python -m pr_agent.cli --pr_url <pr_url> generate_labels | ||
python -m pr_agent.cli --issue_url <issue_url> similar_issue | ||
... | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,64 @@ | ||
FROM python:3.10 as base | ||
ARG PYTHON_VERSION=3.10 | ||
FROM python:$PYTHON_VERSION as builder | ||
|
||
WORKDIR /app | ||
ADD pyproject.toml . | ||
ADD requirements.txt . | ||
RUN pip install . && rm pyproject.toml requirements.txt | ||
ENV PYTHONPATH=/app | ||
# Configure Poetry | ||
ARG POETRY_VERSION=1.7.1 | ||
ENV POETRY_HOME=/opt/poetry | ||
ENV POETRY_VENV=/opt/poetry-venv | ||
ENV POETRY_CACHE_DIR=/opt/.cache | ||
ENV POETRY_VIRTUALENVS_IN_PROJECT=1 | ||
ENV POETRY_NO_INTERACTION=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Install poetry separated from system interpreter | ||
RUN python3 -m venv $POETRY_VENV \ | ||
&& $POETRY_VENV/bin/pip install -U pip setuptools \ | ||
&& $POETRY_VENV/bin/pip install poetry==$POETRY_VERSION | ||
|
||
# Add `poetry` to PATH | ||
ENV PATH="${PATH}:${POETRY_VENV}/bin" | ||
|
||
WORKDIR /usr/app | ||
COPY poetry.lock pyproject.toml ./ | ||
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR | ||
RUN poetry export -f requirements.txt -o requirements-dev.txt --only=dev | ||
|
||
FROM python:$PYTHON_VERSION as base | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
|
||
ENV PYTHONPATH=/usr/app/ | ||
ENV VIRTUAL_ENV=/usr/app/.venv | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
# Create and use non-root user | ||
RUN groupadd -g $GID -r pr_agent && useradd -m -g $GID -u $UID pr_agent | ||
|
||
WORKDIR /usr/app | ||
COPY --chown=pr_agent:pr_agent --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
COPY --chown=pr_agent:pr_agent pr_agent/ $PYTHONPATH/pr_agent/ | ||
USER pr_agent | ||
|
||
FROM base as github_app | ||
ADD pr_agent pr_agent | ||
CMD ["python", "pr_agent/servers/github_app.py"] | ||
|
||
FROM base as bitbucket_app | ||
ADD pr_agent pr_agent | ||
CMD ["python", "pr_agent/servers/bitbucket_app.py"] | ||
|
||
FROM base as bitbucket_server_webhook | ||
ADD pr_agent pr_agent | ||
CMD ["python", "pr_agent/servers/bitbucket_server_webhook.py"] | ||
|
||
FROM base as github_polling | ||
ADD pr_agent pr_agent | ||
CMD ["python", "pr_agent/servers/github_polling.py"] | ||
|
||
FROM base as gitlab_webhook | ||
ADD pr_agent pr_agent | ||
CMD ["python", "pr_agent/servers/gitlab_webhook.py"] | ||
|
||
FROM base as test | ||
ADD requirements-dev.txt . | ||
RUN pip install -r requirements-dev.txt && rm requirements-dev.txt | ||
ADD pr_agent pr_agent | ||
ADD tests tests | ||
COPY --chown=pr_agent:pr_agent --from=builder /usr/app/requirements-dev.txt /usr/app/requirements-dev.txt | ||
RUN python -m pip install -r requirements-dev.txt | ||
COPY tests/ ./tests/ | ||
|
||
FROM base as cli | ||
ADD pr_agent pr_agent | ||
ENTRYPOINT ["python", "pr_agent/cli.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,63 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "pr_agent" | ||
version = "0.0.1" | ||
|
||
authors = [ | ||
{name = "Itamar Friedman", email = "[email protected]"}, | ||
] | ||
[tool.poetry] | ||
name = "pr-agent" | ||
version = "0.11" | ||
description = "CodiumAI PR-Agent is an open-source tool to automatically analyze a pull request and provide several types of feedback" | ||
homepage = "https://github.com/Codium-ai/pr-agent" | ||
repository = "https://github.com/Codium-ai/pr-agent" | ||
authors = ["Itamar Friedman <[email protected]>"] | ||
maintainers = [ | ||
{name = "Ori Kotek", email = "[email protected]"}, | ||
{name = "Tal Ridnik", email = "[email protected]"}, | ||
{name = "Hussam Lawen", email = "[email protected]"}, | ||
{name = "Sagi Medina", email = "[email protected]"} | ||
"Ori Kotek <[email protected]>", | ||
"Tal Ridnik <[email protected]>", | ||
"Hussam Lawen <[email protected]>", | ||
"Sagi Medina <[email protected]>", | ||
] | ||
description = "CodiumAI PR-Agent is an open-source tool to automatically analyze a pull request and provide several types of feedback" | ||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
keywords = ["ai", "tool", "developer", "review", "agent"] | ||
license = {file = "LICENSE", name = "Apache 2.0 License"} | ||
license = "Apache 2.0 License" | ||
readme = "README.md" | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Intended Audience :: Developers", | ||
"Operating System :: Independent", | ||
"Programming Language :: Python :: 3", | ||
] | ||
dynamic = ["dependencies"] | ||
|
||
[tool.setuptools.dynamic] | ||
dependencies = {file = ["requirements.txt"]} | ||
|
||
[project.urls] | ||
"Homepage" = "https://github.com/Codium-ai/pr-agent" | ||
|
||
[tool.setuptools] | ||
include-package-data = false | ||
license-files = ["LICENSE"] | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["."] | ||
include = ["pr_agent"] | ||
|
||
[project.scripts] | ||
pr-agent = "pr_agent.cli:run" | ||
|
||
|
||
[tool.ruff] | ||
|
||
line-length = 120 | ||
|
||
select = [ | ||
"E", # Pyflakes | ||
"F", # Pyflakes | ||
"B", # flake8-bugbear | ||
"I001", # isort basic checks | ||
"I002", # isort missing-required-import | ||
] | ||
|
||
# First commit - only fixing isort | ||
fixable = [ | ||
"I001", # isort basic checks | ||
] | ||
|
||
unfixable = [ | ||
"B", # Avoid trying to fix flake8-bugbear (`B`) violations. | ||
] | ||
|
||
exclude = [ | ||
"api/code_completions", | ||
] | ||
include = ["CHANGELOG.md"] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
aiohttp = "3.9.1" | ||
atlassian-python-api = "3.39.0" | ||
azure-devops = "7.1.0b3" | ||
boto3 = "1.33.6" | ||
dynaconf = "3.2.4" | ||
fastapi = "0.99.0" | ||
gitpython = "3.1.32" | ||
google-cloud-aiplatform = "1.35.0" | ||
google-cloud-storage = "2.10.0" | ||
jinja2 = "3.1.2" | ||
litellm = "0.12.5" | ||
loguru = "0.7.2" | ||
msrest = "0.7.1" | ||
openai = "0.27.8" | ||
pygithub = "==1.59.*" | ||
pyyaml = "6.0.1" | ||
python-gitlab = "3.15.0" | ||
retry = "0.9.2" | ||
starlette-context = "0.3.6" | ||
tiktoken = "0.5.2" | ||
ujson = "5.8.0" | ||
uvicorn = "0.22.0" | ||
pinecone-client = "^2.2.4" | ||
pinecone-datasets = {git = "https://github.com/mrT23/pinecone-datasets.git", rev = "main"} | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^7.4.3" | ||
httpx = "^0.26.0" | ||
ruff = "^0.1.9" | ||
|
||
ignore = [ | ||
"E999", "B008" | ||
] | ||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.ruff.per-file-ignores] | ||
"__init__.py" = ["E402"] # Ignore `E402` (import violations) in all `__init__.py` files, and in `path/to/file.py`. | ||
# TODO: should decide if maybe not to ignore these. | ||
[tool.poetry.scripts] | ||
pr-agent = "python pr_agent.cli:run" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Suggestion: Add --no-cache-dir option to pip install to reduce Docker image size [Performance, importance: 7]
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.
take the suggestion.