@@ -154,7 +154,7 @@ def update_processing_engines(
154154 return
155155 model_details = self .get_model_processing_details (model_id , version )
156156 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' ]
158158 if engines_ready >= min_engines :
159159 self .logger .info (f"{ engines_ready } engines are ready." )
160160 return
@@ -440,7 +440,7 @@ def deploy(
440440 self , container_image , model_name , model_version , sample_input_file = None , architecture = "amd64" , credentials = None ,
441441 model_id = None , run_timeout = None , status_timeout = None , short_description = None , tags = [],
442442 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
444444 ):
445445 """Deploys a new `Model` instance.
446446
@@ -463,6 +463,7 @@ def deploy(
463463 performance_metrics (List): List of arrays describing model performance statistics
464464 input_details (List): List of dictionaries describing details of model inputs
465465 output_details (List): List of dictionaries describing details of model outputs
466+ model_picture (str): Filepath to image for model card page
466467
467468 Returns:
468469 dict: Newly deployed model information including formatted URL to newly deployed model page.
@@ -507,7 +508,7 @@ def deploy(
507508
508509 # add model metadata
509510 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
511512
512513 if architecture in ["arm64" , "arm" ]:
513514 # assign "ARM" hardware requirement to bypass validation tests
@@ -539,6 +540,12 @@ def deploy(
539540 model_data = self ._api_client .http .patch (f"{ self ._base_route } /{ identifier } /versions/{ version } " , model_metadata_patch )
540541 self .logger .info (f"Patched Model Data: { json .dumps (model_data )} " )
541542
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+
542549 # deploy model and skip tests (because model is compiled for arm64)
543550 try :
544551 deploy_model (self ._api_client , self .logger , identifier , version )
@@ -580,6 +587,20 @@ def deploy(
580587 run_model (self ._api_client , self .logger , identifier , version )
581588 except Exception as e :
582589 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" )
583604 # deploy model pending all tests have passed
584605 try :
585606 deploy_model (self ._api_client , self .logger , identifier , version )
0 commit comments