46
46
from ads .config import (
47
47
AQUA_CONFIG_FOLDER ,
48
48
AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME ,
49
- AQUA_DEPLOYMENT_CONTAINER_OVERRIDE_FLAG_METADATA_NAME ,
50
49
AQUA_MODEL_DEPLOYMENT_CONFIG ,
51
50
AQUA_MODEL_DEPLOYMENT_CONFIG_DEFAULTS ,
52
51
COMPARTMENT_OCID ,
@@ -87,26 +86,26 @@ class AquaDeploymentApp(AquaApp):
87
86
88
87
@telemetry (entry_point = "plugin=deployment&action=create" , name = "aqua" )
89
88
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 ,
89
+ self ,
90
+ model_id : str ,
91
+ instance_shape : str ,
92
+ display_name : str ,
93
+ instance_count : int = None ,
94
+ log_group_id : str = None ,
95
+ access_log_id : str = None ,
96
+ predict_log_id : str = None ,
97
+ compartment_id : str = None ,
98
+ project_id : str = None ,
99
+ description : str = None ,
100
+ bandwidth_mbps : int = None ,
101
+ web_concurrency : int = None ,
102
+ server_port : int = None ,
103
+ health_check_port : int = None ,
104
+ env_var : Dict = None ,
105
+ container_family : str = None ,
106
+ memory_in_gbs : Optional [float ] = None ,
107
+ ocpus : Optional [float ] = None ,
108
+ model_file : Optional [str ] = None ,
110
109
) -> "AquaDeployment" :
111
110
"""
112
111
Creates a new Aqua deployment
@@ -175,6 +174,7 @@ def create(
175
174
tags [tag ] = aqua_model .freeform_tags [tag ]
176
175
177
176
tags .update ({Tags .AQUA_MODEL_NAME_TAG : aqua_model .display_name })
177
+ tags .update ({Tags .TASK : aqua_model .freeform_tags .get (Tags .TASK , None )})
178
178
179
179
# Set up info to get deployment config
180
180
config_source_id = model_id
@@ -231,8 +231,7 @@ def create(
231
231
env_var .update ({"FT_MODEL" : f"{ fine_tune_output_path } " })
232
232
233
233
container_type_key = self ._get_container_type_key (
234
- model = aqua_model ,
235
- container_family = container_family
234
+ model = aqua_model , container_family = container_family
236
235
)
237
236
238
237
# fetch image name from config
@@ -248,7 +247,11 @@ def create(
248
247
model_format = model_formats_str .split ("," )
249
248
250
249
# 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 :
250
+ if (
251
+ ModelFormat .GGUF .value in model_format
252
+ and container_type_key .lower ()
253
+ == InferenceContainerTypeFamily .AQUA_LLAMA_CPP_CONTAINER_FAMILY
254
+ ):
252
255
if model_file is not None :
253
256
logger .info (
254
257
f"Overriding { model_file } as model_file for model { aqua_model .id } ."
@@ -299,8 +302,8 @@ def create(
299
302
if user_params :
300
303
# todo: remove this check in the future version, logic to be moved to container_index
301
304
if (
302
- container_type_key .lower ()
303
- == InferenceContainerTypeFamily .AQUA_LLAMA_CPP_CONTAINER_FAMILY
305
+ container_type_key .lower ()
306
+ == InferenceContainerTypeFamily .AQUA_LLAMA_CPP_CONTAINER_FAMILY
304
307
):
305
308
# AQUA_LLAMA_CPP_CONTAINER_FAMILY container uses uvicorn that required model/server params
306
309
# to be set as env vars
@@ -422,9 +425,8 @@ def _get_container_type_key(model: DataScienceModel, container_family: str) -> s
422
425
f"for model { model .id } . For unverified Aqua models, { AQUA_DEPLOYMENT_CONTAINER_METADATA_NAME } should be"
423
426
f"set and value can be one of { ', ' .join (InferenceContainerTypeFamily .values ())} ."
424
427
) from err
425
-
428
+
426
429
return container_type_key
427
-
428
430
429
431
@telemetry (entry_point = "plugin=deployment&action=list" , name = "aqua" )
430
432
def list (self , ** kwargs ) -> List ["AquaDeployment" ]:
@@ -453,8 +455,8 @@ def list(self, **kwargs) -> List["AquaDeployment"]:
453
455
for model_deployment in model_deployments :
454
456
oci_aqua = (
455
457
(
456
- Tags .AQUA_TAG in model_deployment .freeform_tags
457
- or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
458
+ Tags .AQUA_TAG in model_deployment .freeform_tags
459
+ or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
458
460
)
459
461
if model_deployment .freeform_tags
460
462
else False
@@ -508,8 +510,8 @@ def get(self, model_deployment_id: str, **kwargs) -> "AquaDeploymentDetail":
508
510
509
511
oci_aqua = (
510
512
(
511
- Tags .AQUA_TAG in model_deployment .freeform_tags
512
- or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
513
+ Tags .AQUA_TAG in model_deployment .freeform_tags
514
+ or Tags .AQUA_TAG .lower () in model_deployment .freeform_tags
513
515
)
514
516
if model_deployment .freeform_tags
515
517
else False
@@ -526,8 +528,8 @@ def get(self, model_deployment_id: str, **kwargs) -> "AquaDeploymentDetail":
526
528
log_group_name = ""
527
529
528
530
logs = (
529
- model_deployment .category_log_details .access
530
- or model_deployment .category_log_details .predict
531
+ model_deployment .category_log_details .access
532
+ or model_deployment .category_log_details .predict
531
533
)
532
534
if logs :
533
535
log_id = logs .log_id
@@ -582,9 +584,9 @@ def get_deployment_config(self, model_id: str) -> Dict:
582
584
return config
583
585
584
586
def get_deployment_default_params (
585
- self ,
586
- model_id : str ,
587
- instance_shape : str ,
587
+ self ,
588
+ model_id : str ,
589
+ instance_shape : str ,
588
590
) -> List [str ]:
589
591
"""Gets the default params set in the deployment configs for the given model and instance shape.
590
592
@@ -616,8 +618,8 @@ def get_deployment_default_params(
616
618
)
617
619
618
620
if (
619
- container_type_key
620
- and container_type_key in InferenceContainerTypeFamily .values ()
621
+ container_type_key
622
+ and container_type_key in InferenceContainerTypeFamily .values ()
621
623
):
622
624
deployment_config = self .get_deployment_config (model_id )
623
625
config_params = (
@@ -640,10 +642,10 @@ def get_deployment_default_params(
640
642
return default_params
641
643
642
644
def validate_deployment_params (
643
- self ,
644
- model_id : str ,
645
- params : List [str ] = None ,
646
- container_family : str = None ,
645
+ self ,
646
+ model_id : str ,
647
+ params : List [str ] = None ,
648
+ container_family : str = None ,
647
649
) -> Dict :
648
650
"""Validate if the deployment parameters passed by the user can be overridden. Parameter values are not
649
651
validated, only param keys are validated.
@@ -666,8 +668,7 @@ def validate_deployment_params(
666
668
if params :
667
669
model = DataScienceModel .from_id (model_id )
668
670
container_type_key = self ._get_container_type_key (
669
- model = model ,
670
- container_family = container_family
671
+ model = model , container_family = container_family
671
672
)
672
673
673
674
container_config = get_container_config ()
@@ -689,9 +690,9 @@ def validate_deployment_params(
689
690
690
691
@staticmethod
691
692
def _find_restricted_params (
692
- default_params : Union [str , List [str ]],
693
- user_params : Union [str , List [str ]],
694
- container_family : str ,
693
+ default_params : Union [str , List [str ]],
694
+ user_params : Union [str , List [str ]],
695
+ container_family : str ,
695
696
) -> List [str ]:
696
697
"""Returns a list of restricted params that user chooses to override when creating an Aqua deployment.
697
698
The default parameters coming from the container index json file cannot be overridden.
0 commit comments