Skip to content

gemini examples fail if gcloud is configured #2167

@stevenh

Description

@stevenh

Initial Checks

Description

Newly added examples for gemini which use gcloud config, cause tests to fail if gcloud is locally configured, but not in a way which enables gemini. This means that make targets like testcov can't be run.

Because this isn't an environment variable, it's a configuration file which is shared for all user actions, it's not something that can fixed without impacting the users global environment.

One option to fix might be to make these tests CI only, but as they are examples this might need an additional tag added to te examples.

WARNING  google_genai._api_client:_api_client.py:105 Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.
WARNING  google.auth.compute_engine._metadata:_metadata.py:142 Compute Engine Metadata server unavailable on attempt 1 of 3. Reason: timed out
WARNING  google.auth.compute_engine._metadata:_metadata.py:142 Compute Engine Metadata server unavailable on attempt 2 of 3. Reason: timed out
WARNING  google.auth.compute_engine._metadata:_metadata.py:142 Compute Engine Metadata server unavailable on attempt 3 of 3. Reason: [Errno 64] Host is down
WARNING  google.auth._default:_default.py:362 Authentication failed using Compute Engine authentication due to unavailable metadata server.
                                                                    Summary of Failures                                                                    
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃  File                    ┃  Function                                                       ┃  Function Line  ┃  Error Line  ┃  Error                    ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│  tests/test_examples.py  │  test_docs_examples[docs/graph.md:355:genai_email_feedback.py]  │  111            │  219         │  DefaultCredentialsError  │
│  tests/test_examples.py  │  test_docs_examples[docs/models/google.md:61]                   │  111            │  219         │  DefaultCredentialsError  │
└──────────────────────────┴─────────────────────────────────────────────────────────────────┴─────────────────┴──────────────┴───────────────────────────┘

Example Code

make testcov

Python, Pydantic AI & LLM client version

Python 3.12.9
Development: 1dee6c8dcc314144beaaf386ccc1aa710ea6e626 but any version after the tests were added will do.

Metadata

Metadata

Assignees

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