Skip to content

[BUG]: Deployment of Data Science agent to Agent Engine fails  #399

@macyjmzr

Description

@macyjmzr

Name of sample affected

https://github.com/google/adk-samples/tree/main/python/agents/data-science)

Description of issue

I am following the exact steps to deploy Data Science agent as described here - https://github.com/google/adk-samples/tree/main/python/agents/data-science. I am able to successfully run the agent in CLI using 'uv run adk run data_science' . However the below command to deploy to Agent Engine fails with below error, citing missing BQ_DATASET_ID variable. The variable is defined in .env file and enabled data set to be successfully created in previous step.

cd deployment/
python3 deploy.py --create

File "/home/admin_/adk-samples/python/agents/data-science/data_science/utils/utils.py", line 42, in get_env_var

    value = os.environ[var_name]

            ~~~~~~~~~~^^^^^^^^^^

  File "", line 685, in getitem

KeyError: 'BQ_DATASET_ID'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/admin_/adk-samples/python/agents/data-science/deployment/deploy.py", line 22, in

    from data_science.agent import root_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/init.py", line 17, in

    from . import agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/agent.py", line 29, in

    from .sub_agents import bqml_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/init.py", line 15, in

    from .bqml.agent import root_agent as bqml_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/bqml/agent.py", line 32, in

    from data_science.sub_agents.bigquery.agent import database_agent as bq_db_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/bigquery/agent.py", line 28, in

    from . import tools

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/bigquery/tools.py", line 33, in

    dataset_id=get_env_var("BQ_DATASET_ID")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/utils/utils.py", line 45, in get_env_var

    raise ValueError(f'Missing environment variable: {var_name}')

ValueError: Missing environment variable: BQ_DATASET_ID

Environment

Running in Google Cloud Shell, with Python 3.12.3 installed, following exact instructions in the adk-samples page

Reproduction steps or code

Ran all previous steps in https://github.com/google/adk-samples/tree/main/python/agents/data-science to set env variables in .env, create BQ data set, and set up and test agent locally, followed by attempted agent engine creation:

cd deployment/
python3 deploy.py --create

File "/home/admin_/adk-samples/python/agents/data-science/data_science/utils/utils.py", line 42, in get_env_var

    value = os.environ[var_name]

            ~~~~~~~~~~^^^^^^^^^^

  File "", line 685, in getitem

KeyError: 'BQ_DATASET_ID'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/admin_/adk-samples/python/agents/data-science/deployment/deploy.py", line 22, in

    from data_science.agent import root_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/init.py", line 17, in

    from . import agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/agent.py", line 29, in

    from .sub_agents import bqml_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/init.py", line 15, in

    from .bqml.agent import root_agent as bqml_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/bqml/agent.py", line 32, in

    from data_science.sub_agents.bigquery.agent import database_agent as bq_db_agent

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/bigquery/agent.py", line 28, in

    from . import tools

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/sub_agents/bigquery/tools.py", line 33, in

    dataset_id=get_env_var("BQ_DATASET_ID")

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/admin_/adk-samples/python/agents/data-science/data_science/utils/utils.py", line 45, in get_env_var

    raise ValueError(f'Missing environment variable: {var_name}')

ValueError: Missing environment variable: BQ_DATASET_ID

Error log

(Paste your error log here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions