
    6pj                        S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  \
" \R                  S9r\R                  R                  \R                  R                  \5      5      r\R                  R%                  \S5      r " S	 S
\5      rg)uG   ``modelscope pipeline`` — scaffold a custom pipeline from a template.    N)ArgumentParser)Template)
CLICommand)
get_logger)	log_leveltemplatec                   @    \ rS rSrSr\S\SS4S j5       rS rS r	S	r
g)
PipelineCMD   pipeline
subparsersreturnNc           	         U R                  [        R                  SS9nUR                  SS[        SS/SS9  UR                  S	S
[        SSS9  UR                  SS[        SSS9  UR                  SS[        SSS9  UR                  SS[        SSS9  UR                  SS[        SSS9  UR                  SS[        S S!S9  UR                  S"S#[        S$S%S9  UR                  S&S'[        SS(S9  UR                  [        S)9  g )*Nz+Scaffold a custom pipeline from a template.)helpz-actz--actionTcreatez'the action of command  pipeline[create])typerequiredchoicesr   z-tplz--tpl_file_pathztemplate.tplz5the template be selected for ModelScope[template.tpl])r   defaultr   z-sz--save_file_path./z3the name of custom template be saved for ModelScopez-fz
--filenamezms_wrapper.pyz8the init name of custom template be saved for ModelScopez-tz--task_namez#the unique task_name for ModelScope)r   r   r   z-mz--model_nameMyCustomModelz&the class of model name for ModelScopez-pz--preprocessor_nameMyCustomPreprocessorz-the class of preprocessor name for ModelScopez-ppz--pipeline_nameMyCustomPipelinez)the class of pipeline name for ModelScopez-configz--configuration_pathz-the path of configuration.json for ModelScope)_command)
add_parserr
   nameadd_argumentstrset_defaults)r   parsers     S/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/modelscope/cli/pipeline.pyregisterPipelineCMD.register   s   &&> ' @ 	J: 	 	< 	"H 	 	J 	F 	 	H 	#K 	 	M 	6 	 	8 	#9 	 	; 	!*@ 	 	B 	&< 	 	> 	"@ 	 	B 	[1    c           
         U R                   R                  [        R                  " [        5      ;  a  U R                   R                  nO8[        R
                  R                  [        U R                   R                  5      n[        R
                  R                  U5      (       d  [        SU-  5      eU R                   R                  S:w  a  U R                   R                  O[        R                  " 5       n[        R                  " USS9  U R                   R                  R                  S5      (       d  [        S5      eU R                   R                  n[        R
                  R                  X#5      nU R                   R                  R                  S5      (       d(  U R                   R                  S-   U R                   l        / n[        U5       n[!        UR#                  5       5      nUR%                  UR&                  " S0 [)        U R                   5      D65        S S S 5        [        US5       nUR+                  U5        S S S 5        [,        R/                  S	U R                   R                  < SS
< 35        [,        R/                  SU R                   R0                  < SU< 35        [,        R/                  SU-  5        g ! , (       d  f       N= f! , (       d  f       N= f)Nz%s not exists!r   T)exist_okz.pyzthe FILENAME must end with .py /wz>>> Configuration be saved in zconfiguration.jsonz>>> Task_name: z, Created in z(Open the file < %s >, update and run it. )argstpl_file_pathoslistdirtemplate_pathpathjoinexists
ValueErrorsave_file_pathgetcwdmakedirsfilenameendswithconfiguration_pathopenr   readappend
substitutevars
writelinesloggerinfo	task_name)	selfr+   r3   save_file_namesave_pkl_pathlinestpl_filetpl	save_files	            r!   create_templatePipelineCMD.create_templateT   s   99"""**]*CC II33MGGLL)-)@)@BMww~~m,,-=>>59YY5M5MQU5U11[][d[d \

NT2yy!!**511>??++^Dyy++44S99+/99+G+G#+MDII(- H8==?+CLL:$tyy/:; ! -%  ' & 	YY113GI 	JYY((-9 	:>NO !  &%s   AK9K
K
K-c                 n    U R                   R                  S:X  a  U R                  5         g [        S5      e)Nr   z+The parameter of action must be in [create])r*   actionrI   r2   )rB   s    r!   executePipelineCMD.executev   s,    99x'  "JKKr$   r)   )__name__
__module____qualname____firstlineno__r   staticmethodr   r"   rI   rM   __static_attributes__r)   r$   r!   r
   r
      s5    D;2^ ;2 ;2 ;2z PDLr$   r
   )__doc__loggingr,   argparser   stringr   modelscope_hub.cli.baser   modelscope.utils.loggerr   WARNINGr?   r/   dirnameabspath__file__current_pathr0   r.   r
   r)   r$   r!   <module>r`      sk    M  	 #  . .	goo	.wwrwwx89\:6gL* gLr$   