How to install python package from GCP Artifact Registry or private PyPI during adk deploy agent_engine? #4880
Replies: 2 comments 1 reply
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The Hello! Thank you for your detailed question. It highlights an important aspect of deploying agents with private dependencies. The issue you're facing stems from the fact that To resolve this, we recommend deploying your agent to Cloud Run using the Here’s how you can solve this with Option 1: Using GCP Artifact RegistryYou can create a # Use a Python base image
FROM python:3.10-slim
# Set up the working directory
WORKDIR /app
# Install the Artifact Registry keyring for authentication
RUN pip install keyrings.google-artifactregistry-auth
# Copy your requirements.txt file
COPY requirements.txt requirements.txt
# Install the Python dependencies
# The --extra-index-url should be in your requirements.txt file
RUN pip install -r requirements.txt
# Copy the rest of your agent's code
COPY . .
# Command to run your agent
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]In your Option 2: Using a Private GitLab PyPITo avoid exposing your token in the Your # Use a Python base image
FROM python:3.10-slim
# Set up the working directory
WORKDIR /app
# Argument for the GitLab token
ARG GITLAB_TOKEN
# Copy your requirements.txt file
COPY requirements.txt requirements.txt
# Install the Python dependencies using the token
RUN pip install --extra-index-url=https://<token-name>:${GITLAB_TOKEN}@gitlab.com/api/v4/projects/<gitlab_project_id>/packages/pypi/simple -r requirements.txt
# Copy the rest of your agent's code
COPY . .
# Command to run your agent
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]You would then build and deploy using the gcloud run deploy your-agent-service \
--source . \
--build-arg GITLAB_TOKEN=<your-gitlab-token> \
--project <your-project-id> \
--region <your-region> \
--allow-unauthenticatedBy using We hope this helps you and your team move forward with your project! |
Beta Was this translation helpful? Give feedback.
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The Hi there! Thanks for the detailed breakdown of the issue and the solutions you've already tried. The core of the issue you're facing stems from the specific deployment mechanism used by Unlike This explains why your attempts didn't work as expected:
Recommended Workaround: Vendor the DependencyThe most effective way to resolve this is to include the private package's source code directly within your agent project. This way, the code is part of the source tarball uploaded during deployment, and Here’s how you can do it:
By following this approach, you can deploy your agent to Agent Engine with all its dependencies, without needing to solve the authentication challenge in the managed deployment environment. Hope this helps! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
My team is working on AI agent deployed to agent_engine, which will be accessible from Gemini Enterprise.
We need to install one python dependency which is a private package. It's stored in gitlab private PyPI, we can also deploy it to GCP Artifact Registry PyPI. This package is provided in requirements.txt file, the same as other packages.
Is there a way to install such a package during building of a docker image via
adk deploy agent_engine? I tried multiple solutions, but no success.What I've tried:
--extra-index-url=https://europe-west2-python.pkg.dev/<project_name>/<pypi-name>/simple/to requirements.txtWhat I expect here is google uses default credentials provided by keyring (we need a python package
keyrings.google-artifactregistry-authto be installed).It looks like it's not installed in the build env or maybe I'm still missing some IAM permission.
--extra-index-url=https://<token-name>:<token>@gitlab.com/api/v4/projects/<gitlab_project_id>/packages/pypi/simplePIP_EXTRA_INDEX_URL, but it looks like it's not passed to the container building processIt looks like env variabled are not passed to the building process.
Is there a way to solve this either with option 1 or 2?
Thanks for any help.
Beta Was this translation helpful? Give feedback.
All reactions