23
23
get_params_list ,
24
24
get_resource_name ,
25
25
get_restricted_params_by_container ,
26
- load_config ,
27
26
)
28
27
from ads .aqua .constants import (
29
28
AQUA_MODEL_ARTIFACT_FILE ,
44
43
from ads .common .object_storage_details import ObjectStorageDetails
45
44
from ads .common .utils import get_log_links
46
45
from ads .config import (
47
- AQUA_CONFIG_FOLDER ,
48
46
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME ,
49
- AQUA_DEPLOYMENT_CONTAINER_OVERRIDE_FLAG_METADATA_NAME ,
50
47
AQUA_MODEL_DEPLOYMENT_CONFIG ,
51
- AQUA_MODEL_DEPLOYMENT_CONFIG_DEFAULTS ,
52
48
COMPARTMENT_OCID ,
53
49
)
54
50
from ads .model .datascience_model import DataScienceModel
@@ -87,26 +83,26 @@ class AquaDeploymentApp(AquaApp):
87
83
88
84
@telemetry (entry_point = "plugin=deployment&action=create" , name = "aqua" )
89
85
def create (
90
- self ,
91
- model_id : str ,
92
- instance_shape : str ,
93
- display_name : str ,
94
- instance_count : int = None ,
95
- log_group_id : str = None ,
96
- access_log_id : str = None ,
97
- predict_log_id : str = None ,
98
- compartment_id : str = None ,
99
- project_id : str = None ,
100
- description : str = None ,
101
- bandwidth_mbps : int = None ,
102
- web_concurrency : int = None ,
103
- server_port : int = None ,
104
- health_check_port : int = None ,
105
- env_var : Dict = None ,
106
- container_family : str = None ,
107
- memory_in_gbs : Optional [float ] = None ,
108
- ocpus : Optional [float ] = None ,
109
- model_file : Optional [str ] = None ,
86
+ self ,
87
+ model_id : str ,
88
+ instance_shape : str ,
89
+ display_name : str ,
90
+ instance_count : int = None ,
91
+ log_group_id : str = None ,
92
+ access_log_id : str = None ,
93
+ predict_log_id : str = None ,
94
+ compartment_id : str = None ,
95
+ project_id : str = None ,
96
+ description : str = None ,
97
+ bandwidth_mbps : int = None ,
98
+ web_concurrency : int = None ,
99
+ server_port : int = None ,
100
+ health_check_port : int = None ,
101
+ env_var : Dict = None ,
102
+ container_family : str = None ,
103
+ memory_in_gbs : Optional [float ] = None ,
104
+ ocpus : Optional [float ] = None ,
105
+ model_file : Optional [str ] = None ,
110
106
) -> "AquaDeployment" :
111
107
"""
112
108
Creates a new Aqua deployment
@@ -231,8 +227,7 @@ def create(
231
227
env_var .update ({"FT_MODEL" : f"{ fine_tune_output_path } " })
232
228
233
229
container_type_key = self ._get_container_type_key (
234
- model = aqua_model ,
235
- container_family = container_family
230
+ model = aqua_model , container_family = container_family
236
231
)
237
232
238
233
# fetch image name from config
@@ -248,7 +243,11 @@ def create(
248
243
model_format = model_formats_str .split ("," )
249
244
250
245
# Figure out a better way to handle this in future release
251
- if ModelFormat .GGUF .value in model_format and container_type_key .lower () == InferenceContainerTypeFamily .AQUA_LLAMA_CPP_CONTAINER_FAMILY :
246
+ if (
247
+ ModelFormat .GGUF .value in model_format
248
+ and container_type_key .lower ()
249
+ == InferenceContainerTypeFamily .AQUA_LLAMA_CPP_CONTAINER_FAMILY
250
+ ):
252
251
if model_file is not None :
253
252
logger .info (
254
253
f"Overriding { model_file } as model_file for model { aqua_model .id } ."
@@ -299,8 +298,8 @@ def create(
299
298
if user_params :
300
299
# todo: remove this check in the future version, logic to be moved to container_index
301
300
if (
302
- container_type_key .lower ()
303
- == InferenceContainerTypeFamily .AQUA_LLAMA_CPP_CONTAINER_FAMILY
301
+ container_type_key .lower ()
302
+ == InferenceContainerTypeFamily .AQUA_LLAMA_CPP_CONTAINER_FAMILY
304
303
):
305
304
# AQUA_LLAMA_CPP_CONTAINER_FAMILY container uses uvicorn that required model/server params
306
305
# to be set as env vars
@@ -422,9 +421,8 @@ def _get_container_type_key(model: DataScienceModel, container_family: str) -> s
422
421
f"for model { model .id } . For unverified Aqua models, { AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME } should be"
423
422
f"set and value can be one of { ', ' .join (InferenceContainerTypeFamily .values ())} ."
424
423
) from err
425
-
424
+
426
425
return container_type_key
427
-
428
426
429
427
@telemetry (entry_point = "plugin=deployment&action=list" , name = "aqua" )
430
428
def list (self , ** kwargs ) -> List ["AquaDeployment" ]:
@@ -453,8 +451,8 @@ def list(self, **kwargs) -> List["AquaDeployment"]:
453
451
for model_deployment in model_deployments :
454
452
oci_aqua = (
455
453
(
456
- Tags .AQUA_TAG in model_deployment .freeform_tags
457
- or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
454
+ Tags .AQUA_TAG in model_deployment .freeform_tags
455
+ or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
458
456
)
459
457
if model_deployment .freeform_tags
460
458
else False
@@ -508,8 +506,8 @@ def get(self, model_deployment_id: str, **kwargs) -> "AquaDeploymentDetail":
508
506
509
507
oci_aqua = (
510
508
(
511
- Tags .AQUA_TAG in model_deployment .freeform_tags
512
- or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
509
+ Tags .AQUA_TAG in model_deployment .freeform_tags
510
+ or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
513
511
)
514
512
if model_deployment .freeform_tags
515
513
else False
@@ -526,8 +524,8 @@ def get(self, model_deployment_id: str, **kwargs) -> "AquaDeploymentDetail":
526
524
log_group_name = ""
527
525
528
526
logs = (
529
- model_deployment .category_log_details .access
530
- or model_deployment .category_log_details .predict
527
+ model_deployment .category_log_details .access
528
+ or model_deployment .category_log_details .predict
531
529
)
532
530
if logs :
533
531
log_id = logs .log_id
@@ -578,9 +576,9 @@ def get_deployment_config(self, model_id: str) -> Dict:
578
576
return config
579
577
580
578
def get_deployment_default_params (
581
- self ,
582
- model_id : str ,
583
- instance_shape : str ,
579
+ self ,
580
+ model_id : str ,
581
+ instance_shape : str ,
584
582
) -> List [str ]:
585
583
"""Gets the default params set in the deployment configs for the given model and instance shape.
586
584
@@ -612,8 +610,8 @@ def get_deployment_default_params(
612
610
)
613
611
614
612
if (
615
- container_type_key
616
- and container_type_key in InferenceContainerTypeFamily .values ()
613
+ container_type_key
614
+ and container_type_key in InferenceContainerTypeFamily .values ()
617
615
):
618
616
deployment_config = self .get_deployment_config (model_id )
619
617
config_params = (
@@ -636,10 +634,10 @@ def get_deployment_default_params(
636
634
return default_params
637
635
638
636
def validate_deployment_params (
639
- self ,
640
- model_id : str ,
641
- params : List [str ] = None ,
642
- container_family : str = None ,
637
+ self ,
638
+ model_id : str ,
639
+ params : List [str ] = None ,
640
+ container_family : str = None ,
643
641
) -> Dict :
644
642
"""Validate if the deployment parameters passed by the user can be overridden. Parameter values are not
645
643
validated, only param keys are validated.
@@ -662,8 +660,7 @@ def validate_deployment_params(
662
660
if params :
663
661
model = DataScienceModel .from_id (model_id )
664
662
container_type_key = self ._get_container_type_key (
665
- model = model ,
666
- container_family = container_family
663
+ model = model , container_family = container_family
667
664
)
668
665
669
666
container_config = get_container_config ()
@@ -685,9 +682,9 @@ def validate_deployment_params(
685
682
686
683
@staticmethod
687
684
def _find_restricted_params (
688
- default_params : Union [str , List [str ]],
689
- user_params : Union [str , List [str ]],
690
- container_family : str ,
685
+ default_params : Union [str , List [str ]],
686
+ user_params : Union [str , List [str ]],
687
+ container_family : str ,
691
688
) -> List [str ]:
692
689
"""Returns a list of restricted params that user chooses to override when creating an Aqua deployment.
693
690
The default parameters coming from the container index json file cannot be overridden.
0 commit comments