File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,17 +54,8 @@ def __getattr__(name): # type: ignore[no-untyped-def]
5454 global _genai_types
5555 if _genai_types is None :
5656 _genai_types = importlib .import_module ("._genai.types" , __name__ )
57- # `types` is an alias for `._genai.types` rather than a real submodule,
58- # so register it to keep
59- # `from agentplatform.types import TypeName`
60- # working without a prior attribute access. Spell it the google3 way:
61- # Copybara rewrites that prefix in both directions, and the external
62- # spelling fails its reversibility check. This key was `vertexai.types`,
63- # which both misnamed this package's own alias and shadowed the real
64- # `vertexai.types` module.
65- types_module_name = f"{ __name__ } .types"
66- if types_module_name not in sys .modules :
67- sys .modules [types_module_name ] = _genai_types
57+ if "vertexai.types" not in sys .modules :
58+ sys .modules ["vertexai.types" ] = _genai_types
6859 return _genai_types
6960
7061 raise AttributeError (f"module '{ __name__ } ' has no attribute '{ name } '" )
Original file line number Diff line number Diff line change @@ -160,14 +160,6 @@ def setup_method(self):
160160 vertexai .init (
161161 project = _TEST_PROJECT ,
162162 location = _TEST_LOCATION ,
163- # Set explicitly rather than inherited. `init` leaves an already
164- # configured credential in place, and test_extensions installs a
165- # `Mock(spec=AnonymousCredentials)` globally that it never resets;
166- # `_upload_string_to_gcs` then hands `global_config.credentials`
167- # to `storage.Client`, which rejects the Mock's `universe_domain`.
168- # Whether that leak reaches this module depends on how
169- # `--dist=loadscope` happens to assign modules to xdist workers.
170- credentials = auth_credentials .AnonymousCredentials (),
171163 )
172164
173165 def teardown_method (self ):
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1515"""The vertexai module."""
1616
1717import importlib
18+ import sys
1819
1920from google .cloud .aiplatform import version as aiplatform_version
2021
2324from google .cloud .aiplatform import init
2425
2526_genai_client = None
27+ _genai_types = None
2628
2729
2830def __getattr__ (name ): # type: ignore[no-untyped-def]
@@ -43,10 +45,12 @@ def __getattr__(name): # type: ignore[no-untyped-def]
4345 return getattr (_genai_client , name )
4446
4547 if name == "types" :
46- # `types` is a real submodule that resolves against
47- # `agentplatform.types`, so importing it also binds it as an attribute
48- # here and this runs only once.
49- return importlib .import_module (".types" , __name__ )
48+ global _genai_types
49+ if _genai_types is None :
50+ _genai_types = importlib .import_module ("._genai.types" , __name__ )
51+ if "vertexai.types" not in sys .modules :
52+ sys .modules ["vertexai.types" ] = _genai_types
53+ return _genai_types
5054
5155 raise AttributeError (f"module '{ __name__ } ' has no attribute '{ name } '" )
5256
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments