14
14
15
15
from __future__ import absolute_import
16
16
17
- from functools import lru_cache
17
+ from functools import cached_property
18
18
from typing import Dict , List , Optional , Union , Any
19
19
import pandas as pd
20
20
from botocore .exceptions import ClientError
@@ -293,17 +293,6 @@ def __init__(
293
293
ValueError: If the model ID is not recognized by JumpStart.
294
294
"""
295
295
296
- metadata_configs = get_jumpstart_configs (
297
- region = region ,
298
- model_id = model_id ,
299
- model_version = model_version ,
300
- sagemaker_session = sagemaker_session ,
301
- )
302
- self ._deployment_configs = self ._deployment_configs = [
303
- self ._convert_to_deployment_config_metadata (config_name , config )
304
- for config_name , config in metadata_configs .items ()
305
- ]
306
-
307
296
def _validate_model_id_and_type ():
308
297
return validate_model_id_and_get_type (
309
298
model_id = model_id ,
@@ -372,6 +361,17 @@ def _validate_model_id_and_type():
372
361
self .model_package_arn = model_init_kwargs .model_package_arn
373
362
self .init_kwargs = model_init_kwargs .to_kwargs_dict (False )
374
363
364
+ metadata_configs = get_jumpstart_configs (
365
+ region = region ,
366
+ model_id = model_id ,
367
+ model_version = model_version ,
368
+ sagemaker_session = sagemaker_session ,
369
+ )
370
+ self ._deployment_configs = [
371
+ self ._convert_to_deployment_config_metadata (config_name , config )
372
+ for config_name , config in metadata_configs .items ()
373
+ ]
374
+
375
375
def log_subscription_warning (self ) -> None :
376
376
"""Log message prompting the customer to subscribe to the proprietary model."""
377
377
subscription_link = verify_model_region_and_return_specs (
@@ -828,8 +828,7 @@ def register_deploy_wrapper(*args, **kwargs):
828
828
829
829
return model_package
830
830
831
- @lru_cache
832
- @property
831
+ @cached_property
833
832
def benchmark_metrics (self ) -> pd .DataFrame :
834
833
"""Pandas DataFrame object of Benchmark Metrics for deployment configs"""
835
834
data = extract_metrics_from_deployment_configs (
@@ -844,16 +843,17 @@ def display_benchmark_metrics(self, *args, **kwargs):
844
843
845
844
def list_deployment_configs (self ) -> List [Dict [str , Any ]]:
846
845
"""List deployment configs for ``This`` model in the current region.
846
+
847
847
Returns:
848
- A list of deployment configs ( List[Dict[str, Any]]) .
848
+ List[Dict[str, Any]]: A list of deployment configs .
849
849
"""
850
850
return self ._deployment_configs
851
851
852
- @lru_cache
853
852
def _convert_to_deployment_config_metadata (
854
853
self , config_name : str , metadata_config : JumpStartMetadataConfig
855
854
) -> Dict [str , Any ]:
856
855
"""Retrieve deployment config for config name.
856
+
857
857
Args:
858
858
config_name (str): Name of deployment config.
859
859
metadata_config (JumpStartMetadataConfig): Metadata config for deployment config.
0 commit comments