
    h>                     `   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Jr  SSKJr  SSKJrJrJr  SS	KJrJr  \" 5       SSSSSSS4S
\S\\   S\\   S\\   S\\   S\\   S\\   S\\   S\\\      S\4S jjr\" 5       SSSSSS4S
\S\\   S\\   S\\   S\\   S\\   S\\   S\\   S\4S jjr\" 5       SSSS4S
\S\\   S\\   S\\   S\\   S\\   S\4S jjr\" 5       SS4S
\S\\   S\\   S\\   S\4
S jjr\" 5       4S
\S\\   S\4S jjrS\
4S jrS\" 5       4S\
SSS\S\\   S\\   S\4S jjrS\
S\\\\4      4S  jr S+S\
S\\\\4      S!\S\\   4S" jjr   S,S\
S#\S$\S%\S&\\\\4      S'\\\      4S( jjr!S\
S\\\\4      S)\\/\"4   4S* jr#g)-z=
A logger that logs training activity to Weights and Biases.
    )DictAnyTupleCallableListIOOptional)
ModuleTypeN)Language)SimpleFrozenList   )dict_to_dotdot_to_dictmatcher_for_regex_patterns)setup_default_console_loggerLoggerTproject_nameremove_config_valuesmodel_log_intervallog_dataset_direntityrun_namelog_best_dirlog_latest_dirlog_custom_statsreturnc	                 
  ^ ^^^^^^^^^
 [        5       m
[        R                  [        R                  4SSS[        S[        S[
        [        [        [        [        4   /S4   [        / S4   4   4UUUUUUU UUU
4
S jjjn	U	$ )a  Creates a logger that interoperates with the Weights & Biases framework.

Args:
    project_name (str):
        The name of the project in the Weights & Biases interface. The project will be created automatically if it doesn't exist yet.
    remove_config_values (List[str]):
        A list of values to exclude from the config before it is uploaded to W&B. Defaults to [].
    model_log_interval (Optional[int]):
        Steps to wait between logging model checkpoints to the W&B dasboard. Defaults to None.
    log_dataset_dir (Optional[str]):
        Directory containing the dataset to be logged and versioned as a W&B artifact. Defaults to None.
    entity (Optional[str]):
        An entity is a username or team name where you're sending runs. If you don't specify an entity, the run will be sent to your default entity, which is usually your username. Defaults to None.
    run_name (Optional[str]):
        The name of the run. If you don't specify a run name, the name will be created by the `wandb` library. Defaults to None.
    log_best_dir (Optional[str]):
        Directory containing the best trained model as saved by spaCy, to be logged and versioned as a W&B artifact. Defaults to None.
    log_latest_dir (Optional[str]):
        Directory containing the latest trained model as saved by spaCy, to be logged and versioned as a W&B artifact. Defaults to None.
    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.
nlpr   stdoutstderrr   Nc                    >
^^ [        T	5      m[        TU TTTS9mT(       a  TTR                  l        T
(       a  [	        TT
SSS9  S[
        [        [        [        4      4UUUU4S jjnSUUU4S jjnX44$ )Nr   r   datasetpathnametypeinfoc                 T   > [        TU 5        [        TU TT5        [        TU T5        g N)_log_scores_log_model_artifact_log_custom_stats)r(   
match_statr   runwandbs    M/home/james-whalen/.local/lib/python3.13/site-packages/spacy_loggers/wandb.pylog_step7wandb_logger_v5.<locals>.setup_logger.<locals>.log_stepJ   s(    t$tS2DEeT:6    c                  r   > T (       a  [        TT SSS9  T(       a  [        TTSSS9  TR                  5         g N
model_bestmodelr$   
model_last_log_dir_artifactjoin)r   r   r0   s   r1   finalize7wandb_logger_v5.<locals>.setup_logger.<locals>.finalizeO   s>    !%% 	 !'% 	 JJLr4   r   N)	r   _setup_wandbr/   r&   r;   r	   r   strr   )r   r   r    r2   r=   r.   r/   r   r   r   r   r   r   r   r   r   r0   s        @@r1   setup_logger%wandb_logger_v5.<locals>.setup_logger7   s     00@A
!5
 %EIINO))	78DcN3 	7 	7
	 	$ !!r4   
_import_wandbsysr   r    r   r   r   r   rA   r   )r   r   r   r   r   r   r   r   r   rB   r0   s   ````````` @r1   wandb_logger_v5rG      s}    H OE '*jjszz*"*"!#*":<*"	xc3h($./"d(1CC	D*" *" *"X r4   c                   ^ ^^^^^^^^	 [        5       m	[        R                  [        R                  4SSS[        S[        S[
        [        [        [        [        4   /S4   [        / S4   4   4UUUUUU UUU	4	S jjjnU$ )a  Creates a logger that interoperates with the Weights & Biases framework.

Args:
    project_name (str):
        The name of the project in the Weights & Biases interface. The project will be created automatically if it doesn't exist yet.
    remove_config_values (List[str]):
        A list of values to exclude from the config before it is uploaded to W&B. Defaults to [].
    model_log_interval (Optional[int]):
        Steps to wait between logging model checkpoints to the W&B dasboard. Defaults to None.
    log_dataset_dir (Optional[str]):
        Directory containing the dataset to be logged and versioned as a W&B artifact. Defaults to None.
    entity (Optional[str]):
        An entity is a username or team name where you're sending runs. If you don't specify an entity, the run will be sent to your default entity, which is usually your username. Defaults to None.
    run_name (Optional[str]):
        The name of the run. If you don't specify a run name, the name will be created by the `wandb` library. Defaults to None.
    log_best_dir (Optional[str]):
        Directory containing the best trained model as saved by spaCy, to be logged and versioned as a W&B artifact. Defaults to None.
    log_latest_dir (Optional[str]):
        Directory containing the latest trained model as saved by spaCy, to be logged and versioned as a W&B artifact. Defaults to None.

Returns:
    LoggerT: Logger instance.
r   r   r   r    r   Nc                    >	^^^ [        XU5      u  mm[        TU TTTS9mT(       a  TTR                  l        T
(       a  [	        TT
SSS9  S[
        [        [        [        4      4UUUU4S jjnSUU	UU4S jjnX44$ )Nr"   r#   r$   r(   c                 J   > T" U 5        [        TU 5        [        TU TT5        g r*   r+   r,   r(   console_log_stepr   r/   r0   s    r1   r2   7wandb_logger_v4.<locals>.setup_logger.<locals>.log_step   $    T"t$tS2DEr4   c                     > T(       a  [        TTSSS9  T(       a  [        TTSSS9  T " 5         TR                  5         g r6   r:   )console_finalizer   r   r0   s   r1   r=   7wandb_logger_v4.<locals>.setup_logger.<locals>.finalize   sD    !%% 	 !'% 	 JJLr4   r?   	r   r@   r/   r&   r;   r	   r   rA   r   )r   r   r    r2   r=   rQ   rM   r/   r   r   r   r   r   r   r   r   r0   s        @@@r1   rB   %wandb_logger_v4.<locals>.setup_logger   s     .J.
** !5
 %EIINO))	F8DcN3 	F 	F
	 	& !!r4   rD   )
r   r   r   r   r   r   r   r   rB   r0   s
   ```````` @r1   wandb_logger_v4rU   g   s}    B OE '*jjszz-"-"!#-":<-"	xc3h($./"d(1CC	D-" -" -"^ r4   c                    ^ ^^^^^^ [        5       m[        R                  [        R                  4S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$ )a5  Creates a logger that interoperates with the Weights & Biases framework.

Args:
    project_name (str):
        The name of the project in the Weights & Biases interface. The project will be created automatically if it doesn't exist yet.
    remove_config_values (List[str]):
        A list of values to exclude from the config before it is uploaded to W&B. Defaults to [].
    model_log_interval (Optional[int]):
        Steps to wait between logging model checkpoints to the W&B dasboard. Defaults to None.
    log_dataset_dir (Optional[str]):
        Directory containing the dataset to be logged and versioned as a W&B artifact. Defaults to None.
    entity (Optional[str]):
        An entity is a username or team name where you're sending runs. If you don't specify an entity, the run will be sent to your default entity, which is usually your username. Defaults to None.
    run_name (Optional[str]):
        The name of the run. If you don't specify a run name, the name will be created by the `wandb` library. Defaults to None.

Returns:
    LoggerT: Logger instance.
r   r   r   r    r   Nc                    >^^^ [        XU5      u  mm[        TU TTTS9mT(       a  TTR                  l        T	(       a  [	        TT	SSS9  S[
        [        [        [        4      4UU
UU4S jjnSUU4S jjnX44$ )Nr"   r#   r$   r(   c                 J   > T" U 5        [        TU 5        [        TU TT5        g r*   rK   rL   s    r1   r2   7wandb_logger_v3.<locals>.setup_logger.<locals>.log_step   rO   r4   c                  4   > T " 5         TR                  5         g r*   r<   rQ   r0   s   r1   r=   7wandb_logger_v3.<locals>.setup_logger.<locals>.finalize       JJLr4   r?   rS   )r   r   r    r2   r=   rQ   rM   r/   r   r   r   r   r   r   r0   s        @@@r1   rB   %wandb_logger_v3.<locals>.setup_logger   s     .J.
** !5
 %EIINO))	F8DcN3 	F 	F
	 	 !!r4   rD   )r   r   r   r   r   r   rB   r0   s   `````` @r1   wandb_logger_v3r`      sv    6 OE '*jjszz""!#":<"	xc3h($./"d(1CC	D" "@ r4   c                    ^ ^^^^ [        5       m[        R                  [        R                  4SSS[        S[        S[
        [        [        [        [        4   /S4   [        / S4   4   4UUU UU4S jjjnU$ )a  Creates a logger that interoperates with the Weights & Biases framework.

Args:
    project_name (str):
        The name of the project in the Weights & Biases interface. The project will be created automatically if it doesn't exist yet.
    remove_config_values (List[str]):
        A list of values to exclude from the config before it is uploaded to W&B. Defaults to [].
    model_log_interval (Optional[int]):
        Steps to wait between logging model checkpoints to the W&B dasboard. Defaults to None.
    log_dataset_dir (Optional[str]):
        Directory containing the dataset to be logged and versioned as a W&B artifact. Defaults to None.

Returns:
    LoggerT: Logger instance.
r   r   r   r    r   Nc                    >^^^ [        XU5      u  mm[        TU T
TS9mT(       a  [        TTSSS9  S[        [        [
        [        4      4UU	UU4S jjnSUU4S jjnX44$ )Nr   r#   r$   r(   c                 J   > T" U 5        [        TU 5        [        TU TT5        g r*   rK   rL   s    r1   r2   7wandb_logger_v2.<locals>.setup_logger.<locals>.log_step$  rO   r4   c                  4   > T " 5         TR                  5         g r*   r[   r\   s   r1   r=   7wandb_logger_v2.<locals>.setup_logger.<locals>.finalize)  r^   r4   r?   )r   r@   r;   r	   r   rA   r   )r   r   r    r2   r=   rQ   rM   r/   r   r   r   r   r0   s        @@@r1   rB   %wandb_logger_v2.<locals>.setup_logger  s~     .J.
** 3;O
 O))	F8DcN3 	F 	F
	 	 !!r4   rD   )r   r   r   r   rB   r0   s   ```` @r1   wandb_logger_v2ri      su    * OE '*jjszz""!#":<"	xc3h($./"d(1CC	D" "4 r4   c                    ^ ^^ [        5       m[        R                  [        R                  4SSS[        S[        S[
        [        [        [        [        4   /S4   [        / S4   4   4U UU4S jjjnU$ )a  Creates a logger that interoperates with the Weights & Biases framework.

Args:
    project_name (str):
        The name of the project in the Weights & Biases interface. The project will be created automatically if it doesn't exist yet.
    remove_config_values (List[str]):
        A list of values to exclude from the config before it is uploaded to W&B. Defaults to [].

Returns:
    LoggerT: Logger instance.
r   r   r   r    r   Nc                    >^^ [        XU5      u  mm[        T	U TTS9  S[        [        [        [
        4      4UU	4S jjnSUU	4S jjnX44$ )Nrc   r(   c                 .   > T" U 5        [        TU 5        g r*   )r+   )r(   rM   r0   s    r1   r2   7wandb_logger_v1.<locals>.setup_logger.<locals>.log_stepM  s    T"t$r4   c                  4   > T " 5         TR                  5         g r*   r[   r\   s   r1   r=   7wandb_logger_v1.<locals>.setup_logger.<locals>.finalizeQ  r^   r4   r?   )r   r@   r	   r   rA   r   )
r   r   r    r2   r=   rQ   rM   r   r   r0   s
        @@r1   rB   %wandb_logger_v1.<locals>.setup_loggerC  sc     .J.
** 	3;O	
	%8DcN3 	% 	%	 	 !!r4   rD   )r   r   rB   r0   s   `` @r1   wandb_logger_v1rq   3  su     OE '*jjszz""!#":<"	xc3h($./"d(1CC	D" "( r4   c                  V     SS K n SSK JnJnJn  U $ ! [         a    [	        S5      ef = f)Nr   )initlogr<   zThe 'wandb' library could not be found - did you install it? Alternatively, specify the 'ConsoleLogger' in the 'training.logger' config section, instead of the 'WandbLogger'.)r0   rs   rt   r<   ImportError)r0   rs   rt   r<   s       r1   rE   rE   Z  s9    
 	*) 
N
 	

s    (r0   r   r   projectc                     UR                   R                  5       n[        U5      nU H  nXg	 M     [        U5      nU R	                  X%USS9nU$ )NT)rv   configr   reinit)rx   interpolater   r   rs   )	r0   r   rv   r   r   rx   
config_dotfieldr/   s	            r1   r@   r@   j  sS     ZZ##%FV$J% &$F
**WF4*
PCJr4   r(   c                 (   Ub  US   nUS   nUS   nU R                  SU05        U(       a8  U R                  UR                  5        VVs0 s H  u  pVSU 3U_M     snn5        [        U[        5      (       a  U R                  U5        g g g s  snnf )Nscoreother_scoreslossesloss_)rt   items
isinstancedict)r0   r(   r~   r   r   kvs          r1   r+   r+   z  s    WN+h		7E"#II&,,.A.$!qc{A~.ABlD))IIl# *  Bs   B
r/   c                    Ub~  U(       av  UR                  S5      (       a_  US   U-  S:X  aR  US   S:w  aH  [        U US   SUR                  -   SUSUS    SUS    3S	US
   [        US   5      S   :X  a  SOS/S9  g g g g g g )Noutput_pathstepr   	pipeline_
checkpointzepoch epochz step latestr~   checkpointsbest )r%   r&   r'   metadataaliases)getr;   idmax)r0   r(   r/   r   s       r1   r,   r,     s     $((="9"9F|00A5$v,!:K!m,$svv-%! gvd6l^D "&w-3tM7J3KA3N"NTV ;L5 #: r4   r%   r&   r'   r   r   c                 `    U R                  X#US9nUR                  XS9  U R                  XeS9  g )N)r'   r   )r&   )r   )Artifactadd_dirlog_artifact)r0   r%   r&   r'   r   r   dataset_artifacts          r1   r;   r;     s:     ~~d~IT-	'9r4   matcherc                     Ub;  UR                  5        H&  u  p4U" U5      (       d  M  U R                  X405        M(     g g r*   )r   rt   )r0   r(   r   r   r   s        r1   r-   r-     s8     JJLDAqzz		1&! ! r4   r*   )NN)$__doc__typingr   r   r   r   r   r   r	   typesr
   rF   spacyr   
spacy.utilr   utilr   r   r   r   r   rA   intrG   rU   r`   ri   rq   rE   r@   r+   r,   r;   boolr-    r4   r1   <module>r      s   B A A  
  ' F F 7 '7&8(,%) ""&$(,0RRs)R !R c]	R
 SMR smR 3-R SMR tCy)R Rp '7&8(,%) ""&$(RRs)R !R c]	R
 SMR smR 3-R SMR Rp '7&8(,%) "==s)= != c]	=
 SM= sm= =F '7&8(,%)	11s)1 !1 c]	1
 1l :J9K$$-1#Y$$N
z 
( !&6&8	  SM	
 s) 	 	$z 	$$sCx.)A 	$  )-	
4S>
" 
 !	8 *.#'
:
:

: 
: 	
:
 tCH~&
: d3i 
:""%d38n5"@H#PT@U"r4   