@@ -154,7 +154,7 @@ def update_processing_engines(
154
154
return
155
155
model_details = self .get_model_processing_details (model_id , version )
156
156
if model_details is not None : # This means the model with the id and version is now visible
157
- engines_ready = sum ([ engine [ " ready" ] for engine in model_details [ "engines" ]])
157
+ engines_ready = model_details [ ' ready' ]
158
158
if engines_ready >= min_engines :
159
159
self .logger .info (f"{ engines_ready } engines are ready." )
160
160
return
@@ -440,7 +440,7 @@ def deploy(
440
440
self , container_image , model_name , model_version , sample_input_file = None , architecture = "amd64" , credentials = None ,
441
441
model_id = None , run_timeout = None , status_timeout = None , short_description = None , tags = [],
442
442
gpu = False , long_description = None , technical_details = None , performance_summary = None ,
443
- performance_metrics = None , input_details = None , output_details = None
443
+ performance_metrics = None , input_details = None , output_details = None , model_picture = None
444
444
):
445
445
"""Deploys a new `Model` instance.
446
446
@@ -463,6 +463,7 @@ def deploy(
463
463
performance_metrics (List): List of arrays describing model performance statistics
464
464
input_details (List): List of dictionaries describing details of model inputs
465
465
output_details (List): List of dictionaries describing details of model outputs
466
+ model_picture (str): Filepath to image for model card page
466
467
467
468
Returns:
468
469
dict: Newly deployed model information including formatted URL to newly deployed model page.
@@ -507,7 +508,7 @@ def deploy(
507
508
508
509
# add model metadata
509
510
run_timeout_body = int (run_timeout )* 1000 if run_timeout else 60000
510
- status_timeout_body = int (status_timeout )* 1000 if status_timeout else 60000
511
+ status_timeout_body = int (status_timeout )* 1000 if status_timeout else 60000
511
512
512
513
if architecture in ["arm64" , "arm" ]:
513
514
# assign "ARM" hardware requirement to bypass validation tests
@@ -539,6 +540,12 @@ def deploy(
539
540
model_data = self ._api_client .http .patch (f"{ self ._base_route } /{ identifier } /versions/{ version } " , model_metadata_patch )
540
541
self .logger .info (f"Patched Model Data: { json .dumps (model_data )} " )
541
542
543
+ # upload model picture
544
+ if model_picture :
545
+ files = {'file' : open (model_picture , 'rb' )}
546
+ params = {'description' : "model card image" }
547
+ res = self ._api_client .http .post (f"/models/{ identifier } /image" , params = params , file_data = files )
548
+
542
549
# deploy model and skip tests (because model is compiled for arm64)
543
550
try :
544
551
deploy_model (self ._api_client , self .logger , identifier , version )
@@ -580,6 +587,20 @@ def deploy(
580
587
run_model (self ._api_client , self .logger , identifier , version )
581
588
except Exception as e :
582
589
raise ValueError ("Inference test failed. Make sure the provided input sample is valid and your model can process it for inference. \n \n See full error below:\n {}" .format (e ))
590
+ # make sure model metadata reflects user-specified fields
591
+ try :
592
+ model_data = self ._api_client .http .patch (f"{ self ._base_route } /{ identifier } /versions/{ version } " , model_metadata )
593
+ self .logger .info (f"Model Data: { json .dumps (model_data )} " )
594
+ except Exception as e :
595
+ raise ValueError ("Patching model metadata failed. See full error below:\n \n {}" .format (e ))
596
+ # upload model picture
597
+ try :
598
+ if model_picture :
599
+ files = {'file' : open (model_picture , 'rb' )}
600
+ params = {'description' : "model card image" }
601
+ res = self ._api_client .http .post (f"/models/{ identifier } /image" , params = params , file_data = files )
602
+ except Exception as e :
603
+ self .logger ("Uploading model image card failed. Continuing deployment" )
583
604
# deploy model pending all tests have passed
584
605
try :
585
606
deploy_model (self ._api_client , self .logger , identifier , version )
0 commit comments