
    h                     F   S r SSKJrJrJrJrJrJrJr  SSK	J
r
  SSKrSSKrSSKJrJr  SSKJr  SSKJrJrJr  SS	KJrJr  SSSS
S\" 5       S4S\\   S\\   S\\   S\S\\\\4      S\\   S\\\      S\4S jjrSSSS
S\" 5       4S\\   S\\   S\\   S\S\\\\4      S\\   S\4S jjrS\
4S jrSSSS
S\" 5       4S\
S\S\\   S\\   S\\   S\S\\\\4      S\\   4S jjrS\
S\\\\4      4S jrS\
4S jrS\
S\\\\4      S\\/\4   4S jr g)z1
A logger that logs training activity to MLflow.
    )DictAnyTupleCallableListOptionalIO)
ModuleTypeN)Languageload)SimpleFrozenList   )dict_to_dotdot_to_dictmatcher_for_regex_patterns)setup_default_console_loggerLoggerTFrun_idexperiment_idrun_namenestedtagsremove_config_valueslog_custom_statsreturnc                 
  ^ ^^^^^^^ [        5       m[        R                  [        R                  4S[        S[
        S[
        S[        [        [        [        [        4   /S4   [        / S4   4   4UUUUUU UU4S jjjnU$ )aU  Creates a logger that interoperates with the MLflow framework.

Args:
    run_id (Optional[str]):
        Unique ID of an existing MLflow run to which parameters and metrics are logged. Can be omitted if `experiment_id` and `run_id` are provided. Defaults to None.
    experiment_id (Optional[str]):
        ID of an existing experiment under which to create the current run. Only applicable when `run_id` is `None`. Defaults to None.
    run_name (Optional[str]):
        Name of new run. Only applicable when `run_id` is `None`. Defaults to None.
    nested (bool):
        Controls whether run is nested in parent run. `True` creates a nested run. Defaults to False.
    tags (Optional[Dict[str, Any]]):
        A dictionary of string keys and values to set as tags on the run. If a run is being resumed, these tags are set on the resumed run. If a new run is being created, these tags are set on the new run. Defaults to None.
    remove_config_values (List[str]):
        A list of values to exclude from the config before it is uploaded to MLflow. Defaults to an empty list.
    log_custom_stats (Optional[List[str]]):
        A list of regular expressions that will be applied to the info dictionary passed to the logger. Statistics and metrics that match these regexps will be automatically logged. Defaults to None.

Returns:
    LoggerT: Logger instance.
nlpstdoutstderrr   Nc           
         >^ [        T5      m[        TU TTTT	TT
5        S[        [        [        [
        4      4UU4S jjnSU4S jjnX44$ )Ninfoc                 8   > [        TU 5        [        TU T5        g N)_log_step_mlflow_log_custom_stats)r!   
match_statmlflows    N/home/james-whalen/.local/lib/python3.13/site-packages/spacy_loggers/mlflow.pylog_step8mlflow_logger_v2.<locals>.setup_logger.<locals>.log_step@   s    VT*fdJ7    c                     > [        T 5        g r#   _finalize_mlflowr'   s   r(   finalize8mlflow_logger_v2.<locals>.setup_logger.<locals>.finalizeD   s    V$r+   r   N)r   _setup_mlflowr   r   strr   )r   r   r   r)   r0   r&   r   r   r'   r   r   r   r   r   s        @r(   setup_logger&mlflow_logger_v2.<locals>.setup_logger1   s^     00@A
 		
	88DcN3 	8 	8	% !!r+   _import_mlflowsysr   r   r   r	   r   r   r   r4   r   )	r   r   r   r   r   r   r   r5   r'   s	   ``````` @r(   mlflow_logger_v2r:      sv    < F %(JJSZZ""!"8:"	xc3h($./"d(1CC	D" "0 r+   c                   ^ ^^^^^^ [        5       m[        R                  [        R                  4S[        S[
        S[
        S[        [        [        [        [        4   /S4   [        / S4   4   4UUUUU UU4S jjjnU$ )aa  Creates a logger that interoperates with the MLflow framework.

Args:
    run_id (Optional[str]):
        Unique ID of an existing MLflow run to which parameters and metrics are logged. Can be omitted if `experiment_id` and `run_id` are provided. Defaults to None.
    experiment_id (Optional[str]):
        ID of an existing experiment under which to create the current run. Only applicable when `run_id` is `None`. Defaults to None.
    run_name (Optional[str]):
        Name of new run. Only applicable when `run_id` is `None`. Defaults to None.
    nested (bool):
        Controls whether run is nested in parent run. `True` creates a nested run. Defaults to False.
    tags (Optional[Dict[str, Any]]):
        A dictionary of string keys and values to set as tags on the run. If a run is being resumed, these tags are set on the resumed run. If a new run is being created, these tags are set on the new run. Defaults to None.
    remove_config_values (List[str]):
        A list of values to exclude from the config before it is uploaded to MLflow. Defaults to an empty list.

Returns:
    LoggerT: Logger instance.
r   r   r   r   Nc           
         >^^ [        XU5      u  mm[        TU TTTT	TT
5        S[        [        [        [
        4      4UU4S jjnSUU4S jjnX44$ )Nr!   c                 .   > T" U 5        [        TU 5        g r#   )r$   )r!   console_log_stepr'   s    r(   r)   8mlflow_logger_v1.<locals>.setup_logger.<locals>.log_step{   s    T"VT*r+   c                  *   > T " 5         [        T5        g r#   r-   )console_finalizer'   s   r(   r0   8mlflow_logger_v1.<locals>.setup_logger.<locals>.finalize   s    V$r+   r2   )r   r3   r   r   r4   r   )r   r   r   r)   r0   rA   r>   r   r'   r   r   r   r   r   s        @@r(   r5   &mlflow_logger_v1.<locals>.setup_loggerj   sq     .J.
** 	 		
	+8DcN3 	+ 	+	% 	% !!r+   r7   )r   r   r   r   r   r   r5   r'   s   `````` @r(   mlflow_logger_v1rD   M   sv    6 F %(JJSZZ""!"8:"	xc3h($./"d(1CC	D" "6 r+   c                  ^     SS K n SSK JnJnJnJnJn  U $ ! [         a    [        S5      ef = f)Nr   )	start_run
log_metriclog_metricslog_artifactend_runzThe 'mlflow' library could not be found - did you install it? Alternatively, specify the 'ConsoleLogger' in the 'training.logger' config section, instead of the 'MLflowLogger'.)r'   rF   rG   rH   rI   rJ   ImportError)r'   rF   rG   rH   rI   rJ   s         r(   r8   r8      s?    
	
 	
 M  
O
 	

s    ,r'   r   c                    UR                   R                  5       n[        U5      n	U H  n
X	 M     [        U	5      nU R	                  UUUUUS9  [        U	R                  5       5      n[        S[        U5      S5       Vs/ s H	  oXS-    PM     nnU H;  nU R                  U VVs0 s H  u  nnUR                  SS5      U_M     snn5        M=     g s  snf s  snnf )N)r   r   r   r   r   r   d   @ )configinterpolater   r   rF   listitemsrangelen
log_paramsreplace)r'   r   r   r   r   r   r   r   rP   
config_dotfieldconfig_dot_itemsiconfig_dot_batchesbatchkvs                    r(   r3   r3      s     ZZ##%FV$J% &$F
#   J,,.//4Q<L8Ms/S/S!W%/S   $UCUTQ199S"-q0UCD $ Ds    C' Cr!   c           
         Uc  g US   nUS   nUS   nUR                  SS 5      nUb  U R                  SU5        U(       a8  U R                  UR                  5        VVs0 s H  u  pgSU 3U_M     snn5        [	        U[
        5      (       ai  U R                  [        U5      R                  5        VVs0 s H3  u  pg[	        U[        5      (       d  [	        U[        5      (       d  M1  Xg_M5     snn5        U(       a>  U[        US   5      S   :X  a(  [        U5      nU R                  R                  US5        g g g s  snnf s  snnf )	Nscoreother_scoreslossesoutput_pathloss_checkpointsr   best)getrG   rH   rS   
isinstancedictr   floatintmaxr   spacy	log_model)	r'   r!   ra   rb   rc   rd   r^   r_   r   s	            r(   r$   r$      s-    |ME'L(^F((=$/K'5)v||~F~tqeA3KN~FG,%% (5;;==DAa'':a+= =	
 uD$7 8 ;;;sF+ <{ Gs    D>
60E
*E
c                 $    U R                  5         g r#   )rJ   r/   s    r(   r.   r.      s     NNr+   matcherc                     UbV  UR                  5        VVs0 s H  u  p4U" U5      (       d  M  X4_M     nnn[        U5      (       a  U R                  U5        g g g s  snnf r#   )rS   rU   rH   )r'   r!   rq   r^   r_   matcheds         r(   r%   r%      sT     $(JJL?LDAGAJ414L?w<<w'  ?s
   AA)!__doc__typingr   r   r   r   r   r   r	   typesr
   osr9   rn   r   r   
spacy.utilr   utilr   r   r   r   r   r4   boolr:   rD   r8   r3   r$   r.   r%    r+   r(   <module>r|      s<   B A A  	 
   ' F F 7
 !#'"%)&6&8,08SM8C=8 sm8 	8
 4S>
"8 s)8 tCy)8 8z !#'"%)&6&88SM8C=8 sm8 	8
 4S>
"8 s)8 8v
 0 !#'"%)&6&8EE	E SME C=	E
 smE E 4S>
"E s)E@,,
4S>
",8((&tCH~6(AI3%QU+AV(r+   