Issues with Private Python Package Installation on LangGraph - dynamic package installation #2436
-
I am continuing my investigations regarding the installation of a private Python package which I am forced to do because LangGraph platform does not allow me to inject an env variable in the container build process which would solve my issues. I have been experimenting with a dynamic private Python package installation which is working locally (Python code + pytest + LangGraph Studio) but not on the LangGraph cloud platform. This is despite configuring the required environment variables for the runtime execution of the graphs in the LangGraph Platform UI. As I am unable to inject an environment variable to authenticate our private code artifact repository inside the Docker build process on the LangGraph platform, I have been attempting to install our package dynamically. This is because it's the only way I can have control over the environment variables that are available. I have developed a Python script that is working locally and in LangGraph Studio (Docker). The script provides utility functions to install the Lizy common package dynamically. Below is the code: import os
import subprocess
from enum import StrEnum
class CredentialType(StrEnum):
"""Enum for the credential type (either the shared one to install common dynamically or app for the runtime)."""
APP = "APP"
SHARED = "SHARED"
def _configure_credentials(credential_type: CredentialType) -> None:
# Configure command
aws_access_key_id = os.environ[f"AWS_ACCESS_KEY_ID_{credential_type}"]
aws_secret_access_key = os.environ[f"AWS_SECRET_ACCESS_KEY_{credential_type}"]
aws_configure_command = f"aws configure set aws_access_key_id {aws_access_key_id}"
subprocess.check_output(aws_configure_command, shell=True).decode("utf-8")
aws_configure_command = f"aws configure set aws_secret_access_key {aws_secret_access_key}"
subprocess.check_output(aws_configure_command, shell=True).decode("utf-8")
def install_common_package(version: str) -> None:
"""Install the lizy common package dynamically."""
# We need to configure the credentials for the common package installation (in lizy-shared AWS account)
_configure_credentials(CredentialType.SHARED)
# Construct the AWS CLI command
aws_command = (
"aws codeartifact login"
" --tool pip "
" --domain lizy-packages-domain"
" --domain-owner 570466319168"
" --repository lizy-packages-repository"
)
# Run the AWS CLI command and capture its output
output = subprocess.check_output(aws_command, shell=True).decode("utf-8")
print(f"Subcommand:\n {output}")
pip_command = f"pip install common=={version}"
print(f"Pip command:\n {pip_command}")
result = subprocess.check_call(pip_command, shell=True)
print(f"Finish installing common=={version}: {result}")
# We need to reconfigure the credentials for the runtime execution of the app (either dev / staging / prod account)
_configure_credentials(CredentialType.APP) I have input all the required variables in the LangGraph platform, and the Docker build phase passes. However, the "Deploy" phase does not. The error message is as follows:
Unfortunately, I have zero visibility over what is going wrong since the logs do not provide sufficient information. Moreover, the deploy times out after 300 seconds. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
In the end, this was caused by previous AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY defined in LangGraph Cloud's UI which were interfering with |
Beta Was this translation helpful? Give feedback.
In the end, this was caused by previous AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY defined in LangGraph Cloud's UI which were interfering with
aws configure
's behaviour.