Skip to content

feat(genai): migrate Vertex AI env var to Enterprise 02#14229

Open
msampathkumar wants to merge 1 commit into
mainfrom
sampathm-migrate-enterprise-02
Open

feat(genai): migrate Vertex AI env var to Enterprise 02#14229
msampathkumar wants to merge 1 commit into
mainfrom
sampathm-migrate-enterprise-02

Conversation

@msampathkumar
Copy link
Copy Markdown
Member

Description

Updating Vertex AI environmental variable for GenAI SDK.

Checklist

  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • Please merge this PR for me once it is approved

@msampathkumar msampathkumar requested review from a team as code owners May 25, 2026 16:04
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label May 25, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the environment variable GOOGLE_GENAI_USE_VERTEXAI to GOOGLE_GENAI_USE_ENTERPRISE across several test files. Feedback suggests avoiding module-level environment variable settings to prevent global state mutation and potential initialization issues, recommending the use of pytest fixtures with monkeypatch instead. Additionally, it was noted that the Enterprise setting typically requires a regional location rather than 'global' for compatibility.

import ctrlgen_with_resp_schema

os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
os.environ["GOOGLE_GENAI_USE_ENTERPRISE"] = "True"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting environment variables at the module level, especially after imports, can lead to issues if any imported modules initialize clients at the module level. It also causes global state mutation that can affect other tests in the suite. Consider using a pytest fixture with monkeypatch for better isolation. Additionally, note that Vertex AI (Enterprise) typically requires a regional location (e.g., us-central1) rather than global; you may need to update GOOGLE_CLOUD_LOCATION to ensure compatibility.

import counttoken_with_txt_vid

os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
os.environ["GOOGLE_GENAI_USE_ENTERPRISE"] = "True"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting environment variables at the module level, especially after imports, can lead to issues if any imported modules initialize clients at the module level. It also causes global state mutation that can affect other tests in the suite. Consider using a pytest fixture with monkeypatch for better isolation. Additionally, note that Vertex AI (Enterprise) typically requires a regional location (e.g., us-central1) rather than global; you may need to update GOOGLE_CLOUD_LOCATION to ensure compatibility.



os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
os.environ["GOOGLE_GENAI_USE_ENTERPRISE"] = "True"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting environment variables at the module level, especially after imports, can lead to issues if any imported modules initialize clients at the module level. It also causes global state mutation that can affect other tests in the suite. Consider using a pytest fixture with monkeypatch for better isolation. Additionally, note that Vertex AI (Enterprise) typically requires a regional location (e.g., us-central1) rather than global; you may need to update GOOGLE_CLOUD_LOCATION to ensure compatibility.

import thinking_textgen_with_txt

os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
os.environ["GOOGLE_GENAI_USE_ENTERPRISE"] = "True"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting environment variables at the module level, especially after imports, can lead to issues if any imported modules initialize clients at the module level. It also causes global state mutation that can affect other tests in the suite. Consider using a pytest fixture with monkeypatch for better isolation. Additionally, note that Vertex AI (Enterprise) typically requires a regional location (e.g., us-central1) rather than global; you may need to update GOOGLE_CLOUD_LOCATION to ensure compatibility.

import thinking_with_txt

os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
os.environ["GOOGLE_GENAI_USE_ENTERPRISE"] = "True"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting environment variables at the module level, especially after imports, can lead to issues if any imported modules initialize clients at the module level. It also causes global state mutation that can affect other tests in the suite. Consider using a pytest fixture with monkeypatch for better isolation. Additionally, note that Vertex AI (Enterprise) typically requires a regional location (e.g., us-central1) rather than global; you may need to update GOOGLE_CLOUD_LOCATION to ensure compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants