
    eTh                         S SK Jr  SSKJrJrJrJr  SSKJr  SSK	J
r
  \R                  " \5      rS\4S jrS	 r " S
 S\
5      rg)    )ArgumentParser   )PipelinePipelineDataFormatget_supported_taskspipeline)logging   )BaseTransformersCLICommandpathc                     U (       d  g[         R                   H  nU R                  U5      (       d  M  Us  $    [        SU  S[         R                   35      e)Npipez4Unable to determine file format from file extension z-. Please provide the format through --format )r   SUPPORTED_FORMATSendswith	Exception)r   exts     Q/var/www/auris/envauris/lib/python3.13/site-packages/transformers/commands/run.pytry_infer_format_from_extr      sZ    !33==J 4 
>tf E66H6Z6Z5[	]     c                    [        U R                  U R                  (       a  U R                  OS U R                  U R                  U R
                  S9nU R                  S:X  a  [        U R                  5      OU R                  n[        R                  " UU R                  U R                  U R                  (       a  U R                  OUR                  U R                  S9n[        X5      $ )N)taskmodelconfig	tokenizerdeviceinfer)formatoutput_path
input_pathcolumn	overwrite)r   r   r   r   r   r   r   r   inputr   from_stroutputr    default_input_namesr!   
RunCommand)argsnlpr   readers       r   run_command_factoryr*   '   s    
YY JJdjjD{{..{{C 7;kkW6L&tzz2RVR]R]F((KK::"kkt{{s/F/F..F c""r   c                   D    \ rS rSrS\S\4S jr\S\4S j5       r	S r
Srg	)
r&   :   r(   r)   c                     Xl         X l        g )N_nlp_reader)selfr(   r)   s      r   __init__RunCommand.__init__;   s    	r   parserc                    U R                  SSS9nUR                  S[        5       SS9  UR                  S[        SS	9  UR                  S
[        SS	9  UR                  S[        SS	9  UR                  S[        SS	9  UR                  S[        SS	9  UR                  S[        SS	9  UR                  S[        S[        R
                  SS9  UR                  S[        SSS9  UR                  SSSS9  UR                  [        S 9  g )!NrunzRun a pipeline through the CLI)helpz--taskzTask to run)choicesr7   z--inputz%Path to the file to use for inference)typer7   z--outputz9Path to the file that will be used post to write results.z--modelz)Name or path to the model to instantiate.z--configz2Name or path to the model's config to instantiate.z--tokenizerz?Name of the tokenizer to use. (default: same as the model name)z--columnzXName of the column to use as input. (For multi columns input as QA use column1,columns2)z--formatr   zInput format to read from)r9   defaultr8   r7   z--devicezSIndicate the device to run onto, -1 indicates CPU, >= 0 indicates GPU (default: -1))r9   r:   r7   z--overwrite
store_truez"Allow overwriting the output file.)actionr7   )func)	
add_parseradd_argumentr   strr   r   intset_defaultsr*   )r4   
run_parsers     r   register_subcommandRunCommand.register_subcommand?   s7   &&u3S&T
2E2Gm\	:ab
;vw	:ef
;op*k 	  	
 	k 	  	

 	&88, 	  	
 	f	 	  	
 	lImn%89r   c                    U R                   / p!U R                   HZ  nU R                  R                  (       a  U" S0 UD6OU" U5      n[        U[        5      (       a  UR                  U5        MV  X$-  nM\     U R                   R                  (       a4  U R                  R                  U5      n[        R                  SU 35        g U R                  R                  U5        g )NzCCurrent pipeline requires output to be in binary format, saving at  )r/   r0   is_multi_columns
isinstancedictappendbinary_outputsave_binaryloggerwarningsave)r1   r(   outputsentryr$   binary_paths         r   r6   RunCommand.run_   s    yy"W\\E%)\\%B%BS\5\E
F&$''v&! " 99"",,227;KNN`al`mnoLLg&r   r.   N)__name__
__module____qualname____firstlineno__r   r   r2   staticmethodr   rE   r6   __static_attributes__rH   r   r   r&   r&   :   s6    H .@  :N : :>'r   r&   N)argparser   	pipelinesr   r   r   r   utilsr	    r   
get_loggerrV   rO   rA   r   r*   r&   rH   r   r   <module>ra      sF    $ S S  ( 
		H	%C #&4'+ 4'r   