File tree Expand file tree Collapse file tree 3 files changed +23
-14
lines changed
Expand file tree Collapse file tree 3 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,15 @@ def test_vertexai_import():
100100 assert "pandas" not in modules_after_genai_client_import
101101 assert "pydantic" in modules_after_genai_client_import
102102
103+ # The types module should not import _evals_metric_loaders until
104+ # PrebuiltMetric or RubricMetric are accessed.
105+ from vertexai ._genai import types # noqa: F401
106+
107+ assert (
108+ "google.cloud.aiplatform.vertexai._genai._evals_metric_loaders"
109+ not in sys .modules
110+ )
111+
103112 # Tests the evals module is lazy loaded.
104113 from vertexai ._genai import evals as _ # noqa: F401,F811
105114
Original file line number Diff line number Diff line change 1616# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
1717# flake8: noqa: F401
1818
19+ import importlib
20+ import typing
21+
1922from . import agent_engines
2023from . import evals
2124from .common import _AppendAgentEngineSessionEventRequestParameters
756759from .common import RubricGroup
757760from .common import RubricGroupDict
758761from .common import RubricGroupOrDict
759- from .common import RubricMetric
760762from .common import RubricOrDict
761763from .common import RubricVerdict
762764from .common import RubricVerdictDict
18131815 "PromptDataDict" ,
18141816 "PromptDataOrDict" ,
18151817 "LLMMetric" ,
1816- "RubricMetric" ,
18171818 "MetricPromptBuilder" ,
18181819 "_CreateEvaluationItemParameters" ,
18191820 "_CreateEvaluationRunParameters" ,
18781879 "_UpdateDatasetParameters" ,
18791880 "evals" ,
18801881 "agent_engines" ,
1882+ "PrebuiltMetric" ,
1883+ "RubricMetric" ,
18811884]
1885+
1886+
1887+ def __getattr__ (name : str ) -> typing .Any :
1888+ if name == "PrebuiltMetric" or name == "RubricMetric" :
1889+ module = importlib .import_module (".._evals_metric_loaders" , __package__ )
1890+ prebuilt_metric_obj = getattr (module , name )
1891+ globals ()[name ] = prebuilt_metric_obj
1892+ return prebuilt_metric_obj
1893+ raise AttributeError (f"module '{ __name__ } ' has no attribute '{ name } '" )
Original file line number Diff line number Diff line change 1616# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
1717
1818import datetime
19- import importlib
2019import json
2120import logging
2221import os
4746from typing_extensions import TypedDict
4847from . import evals as evals_types
4948
50- __all__ = ["PrebuiltMetric" , "RubricMetric" ] # noqa: F822
51-
52-
53- def __getattr__ (name : str ) -> typing .Any :
54- if name == "PrebuiltMetric" or name == "RubricMetric" :
55- module = importlib .import_module (".._evals_metric_loaders" , __package__ )
56- prebuilt_metric_obj = getattr (module , name )
57- globals ()[name ] = prebuilt_metric_obj
58- return prebuilt_metric_obj
59- raise AttributeError (f"module '{ __name__ } ' has no attribute '{ name } '" )
60-
6149
6250def _camel_to_snake (camel_case_string : str ) -> str :
6351 snake_case_string = re .sub (r"(?<!^)([A-Z])" , r"_\1" , camel_case_string )
You can’t perform that action at this time.
0 commit comments