
    vj                        d dl Z d dlZd dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZmZmZmZ d d	lmZ  e            Z G d
 d          Zddeeef         deeef         fdZedk    rj e j                    Ze                    de           e                    ded           e                                Z eej         ej!                   dS dS )    N)ListUnion)HubApi)model_file_download)pipeline)Config)	ModelFile)call_pipeline_with_json$get_pipeline_information_by_pipelineget_task_input_examples(pipeline_output_to_service_base64_output)
get_loggerc                   "    e Zd Zd ZddefdZdS )DeployCheckerc                 ,    t                      | _        d S N)r   api)selfs    o/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/modelscope/utils/deploy_checker.py__init__zDeployChecker.__init__   s    88    Nmodel_idc                    |so| j                             |          }t                              d| d|            t	          |          r	|d         }nt                              | d           t          |t          j        |          }t          j
        |          }|                    d          }t          |||d          }t          |          }t          |          }	t          |||	          }
t!          ||
          }|S )	NzAll model_revisions of `z`: r   z has no revision.)r   	file_pathrevisiontaskT)r   modelmodel_revisionexternal_engine_for_llm)r   list_model_revisionsloggerinfolenerrorr   r	   CONFIGURATIONr   	from_filesafe_getr   r   r   r
   r   )r   r   r   model_revisionsconfiguration_filecfgr   pplpipeline_infodatainfer_resultresults               r   check_modelzDeployChecker.check_model   s,    	="h;;HEEOKKI8IIIIK K K?## =!0!3;;;<<<0-#% % % 122||F## )$(	* * *
 =SAA 't,,.}c4HH9$MMr   r   )__name__
__module____qualname__r   strr0    r   r   r   r      sC           C      r   r   models	revisionsc                    t          | t                    s| g} t          |t                    s|g|rdnt          |           z  }t          |           t          |          k    r;t                              dt          |           dt          |           d           t                      }t          | |          D ]\  }}	 |                    ||          }t                              | d| d| d           @# t          $ rA}t                              | d| d| d	t          j                     d           Y d }~d }~ww xY wd S )
N   zMThe number of models and revisions need to be equal: The number of models is z" while the number of revisions is . z: Deploy pre-check pass. 
z: Deploy pre-check failed: z. )
isinstancelistr#   r!   r$   r   zipr0   r"   BaseException	traceback	print_exc)r6   r7   r   r   checkerreses          r   check_deployrF   9   s   fd## i&& DK	#B11s6{{C	
6{{c)nn$$Ru::R RADXR R R	
 	
 	

 ooGvy11  x	%%eX66CKK5MM8MMcMMMNNNN 	 	 	KK^^8^^^^YEXEZEZ^^^       		 s   9C>>
E	7EE	__main__z
--model_id)typez
--revision)rH   defaultr   )"argparserA   typingr   r   modelscope.hub.apir   modelscope.hub.file_downloadr   modelscope.pipelinesr   modelscope.utils.configr   modelscope.utils.constantr	   modelscope.utils.input_outputr
   r   r   r   modelscope.utils.loggerr   r!   r   r4   rF   r1   ArgumentParserparseradd_argument
parse_argsargsr   r   r5   r   r   <module>rX      s                % % % % % % < < < < < < ) ) ) ) ) ) * * * * * * / / / / / /G G G G G G G G G G G G / . . . . .	$ $ $ $ $ $ $ $N sDy) eCI6F    . z$X$&&F
3///
3===DL..... r   