
    h3                     .   S SK r S SKJr  S SKJrJrJrJrJrJ	r	  S SK
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JrJrJr  SS	KJrJrJrJr  S
SKJrJrJ r J!r!J"r"J#r#  S
SKJ$r$  \$RJ                  " SSSS.S9\!" SS\ 3S9\!" \RL                  " 5       SSSS9\"" SSSSS9\"" SSSSS9\"" SSSS94S\RN                  S\(S \S!\)S"\)S#\)4S$ jj5       r*\" 5       SSSS\S%.S \S\(S&\\(\4   S!\)S"\)S'\)S(\)S)\(S*S4S+ jjr+S\4S \S\\(   S)\(S*S4S, jjr,\" 5       SSS4S-\\(   S.\)S"\)S'\)S*S4
S/ jjr-S-\	\(   S0\	\(   S\(S*S4S1 jr.S \S2\\(\4   S*\)4S3 jr/S \S2\\(\4   S*S4S4 jr0\S5.S \S2\\(\4   S)\(S*\\(\4   4S6 jjr1S \S7\\(   S*\\\(\\(   4      4S8 jr2g)9    N)Path)AnyDictIterableListOptionalSequence)msg)locale_escape   )SimpleFrozenDictSimpleFrozenListcheck_spacy_env_vars)get_checksumget_hashis_cwdjoin_commandload_project_config)parse_config_overridesrun_commandsplit_commandworking_dir   )COMMANDPROJECT_FILEPROJECT_LOCKArgOpt_get_parent_command)apprunT)allow_extra_argsignore_unknown_options)context_settingszName of command defined in the )helpzELocation of project directory. Defaults to current working directory.F)r%   exists	file_okayz--forcez-Fz/Force re-running steps, even if nothing changedz--dryz-Dz+Perform a dry run and don't execute scriptsz--helpz+Show help message and available subcommandsctx
subcommandproject_dirforcedry	show_helpc           	          [        U 5      nU(       d  U(       d  [        X!U5        g[        U R                  5      n[	        UUUUUUS9  g)a8  Run a named command or workflow defined in the project.yml. If a workflow
name is specified, all commands in the workflow are run, in order. If
commands define dependencies and/or outputs, they will only be re-run if
state has changed.

DOCS: https://github.com/explosion/weasel/tree/main/docs/cli.md#rocket-run
)	overridesr+   r,   parent_commandN)r   print_run_helpr   argsproject_run)r(   r)   r*   r+   r,   r-   r0   r/   s           H/home/james-whalen/.local/lib/python3.13/site-packages/weasel/cli/run.pyproject_run_clir5      sE    ( )-N
{?*3884	)	
    )r/   r+   r,   captureskip_requirements_checkr0   r/   r7   r8   r0   returnc          
      p   [        XS9nUR                  S/ 5       V	s0 s H  oS   U	_M
     n
n	UR                  S0 5      n[        [        U
R	                  5       5      [        UR	                  5       5      U5        X;   a4  [
        R                  " SU S35        X    H  n	[        U U	UUUUS9  M     gX   n	U	R                  S/ 5       HF  nX-  R                  5       (       a  M  S	U S
U 3nSnU(       d  SOSn[
        R                  " XUS9  MH     [        5         [        U 5       n[
        R                  " U5        [        UU	5      nU(       d%  U(       d  [
        R                  " SU	S    S35        O [        U	S   XES9  U(       d  [        UU	5        SSS5        gs  sn	f ! , (       d  f       g= f)a  Run a named script defined in the project.yml. If the script is part
of the default pipeline (defined in the "run" section), DVC is used to
execute the command, so it can determine whether to rerun it. It then
calls into "exec" to execute it.

project_dir (Path): Path to project directory.
subcommand (str): Name of command to run.
overrides (Dict[str, Any]): Optional config overrides.
force (bool): Force re-running, even if nothing changed.
dry (bool): Perform a dry run and don't execute commands.
capture (bool): Whether to capture the output and errors of individual commands.
    If False, the stdout and stderr will not be redirected, and if there's an error,
    sys.exit will be called with the return code. You should use capture=False
    when you want to turn over execution to the command, and capture=True
    when you want to run the command more like a function.
skip_requirements_check (bool): No longer used, deprecated.
)r/   commandsname	workflowszRunning workflow '')r/   r+   r,   r7   depsz)Missing dependency specified by command 'z': zHMaybe you forgot to run the 'project assets' command or a previous step?r   Nexitsz
Skipping 'z': nothing changedscript)r,   r7   )r   getvalidate_subcommandlistkeysr
   infor3   r&   failr   r   dividercheck_rerunrun_commandsupdate_lockfile)r*   r)   r/   r+   r,   r7   r8   r0   configcmdr;   r=   deperrerr_help	err_exitscurrent_dirreruns                     r4   r3   r3   4   s   8 !BF,2JJz2,FG,FSFS ,FHG

;+IX]]_-tINN4D/EzR%j\34(C# ) "7762&C%--//A*SQTPUVe%(Ad	i8 ' 	%KK
#S1E:c&k]2DEFS]E#K5 &%1 H0 &%s   F"*A/F''
F5c           
      ,   [        U 5      nUR                  S/ 5      nU Vs0 s H  oUS   U_M
     nnUR                  S0 5      n[        U 5      (       a  SOU nU(       Ga	  [        [	        UR                  5       5      [	        UR                  5       5      U5        [        SU SU SU 35        X;   a+  Xa   R                  S5      n	U	(       a  [        S	U	 S	35        ggX;   a  Xq   n
[        S
[        U
5       S35        [        U
5       VVs/ s H#  u  pUS-    SU 3Xl   R                  SS5      4PM%     nnn[        R                  " U5        U SU S3n[        SU 35        gg[        S5        UR                  S5      nU(       a  [        [        U5       S	35        U(       a^  [        S[         35        [        SU SU 35        [        R                  " U Vs/ s H  oUS   UR                  SS5      4PM     sn5        U(       ao  [        S[         35        [        SU SU 35        [        R                  " UR                  5        VV
s/ s H  u  nn
USR                  U
5      4PM     sn
n5        ggs  snf s  snnf s  snf s  sn
nf )a6  Simulate a CLI help prompt using the info available in the project.yml.

project_dir (Path): The project directory.
subcommand (Optional[str]): The subcommand or None. If a subcommand is
    provided, the subcommand help is shown. Otherwise, the top-level help
    and a list of available commands is printed.
r;   r<   r=    zUsage:  run  r%   
z
Workflow consisting of z
 commands:r   . z run [COMMAND] z --helpzFor command details, run: titlezAvailable commands in zAvailable workflows in z run [WORKFLOW] z -> N)r   rC   r   rD   rE   rF   printlen	enumerater
   tabler   r   itemsjoin)r*   r)   r0   rM   config_commandsrN   r;   r=   project_loc	help_textstepsistep
steps_datahelp_cmdr[   r<   s                    r4   r1   r1   t   st    !-FjjR0O,;<OSFS OH<

;+I{++"KD14	8H3I:V'uZL+GH! ,008I9+R() $)E-c%j\DE  )//GA E7"TF#X^%7%7%CD/   IIj!()WMH.xj9: % 	b	

7#]5)*"-.*<.9:GN+?;-HIII_U_cFSWWVR%89_UV+L>:;GN++;K=IJIIY__EVWEVkdEfkk%01EVWX ; = V Xs   J *J" J J
r;   silentc                 H   U  H  n[        U5      n[        U5      (       a  US   S;   a  [        R                  US'   O1[        U5      (       a!  US   S;   a  [        R                  SS/USS QnU(       d  [	        S[        U5       35        U(       a  M  [        XSS	9  M     g)
a>  Run a sequence of commands in a subprocess, in order.

commands (List[str]): The string commands.
silent (bool): Don't print the commands.
dry (bool): Perform a dry run and don't execut anything.
capture (bool): Whether to capture the output and errors of individual commands.
    If False, the stdout and stderr will not be redirected, and if there's an error,
    sys.exit will be called with the return code. You should use capture=False
    when you want to turn over execution to the command, and capture=True
    when you want to run the command more like a function.
r   )pythonpython3)pippip3z-mrn   r   NzRunning command: )r7   )r   r]   sys
executabler\   r   r   )r;   rj   r,   r7   ccommands         r4   rK   rK      s    " " w<<GAJ*??GAJ\\gajO;~~tUAWQR[AG%l7&;%<=>s1! r6   r=   c                    U (       d#  U(       d  [         R                  " S[         3SS9  X ;  a  X!;  a  / nUS;   a  UR                  S5        U (       a#  UR                  SSR	                  U 5       35        U(       a#  UR                  SSR	                  U5       35        [         R                  " S	U S
[         3SR	                  U5      SS9  ggg)zCheck that a subcommand is valid and defined. Raises an error otherwise.

commands (Sequence[str]): The available commands.
subcommand (str): The subcommand.
z$No commands or workflows defined in r   r@   )assetsassetz-Did you mean to run: python -m weasel assets?zAvailable commands: z, zAvailable workflows: z Can't find command or workflow 'z' in rZ   N)r
   rH   r   appendra   )r;   r=   r)   help_msgs       r4   rD   rD      s     I7~FaP!j&A,,OOKLOO2499X3F2GHIOO3DIIi4H3IJK.zl%~NIIh	
 'B!r6   rs   c                 2   UR                  SS5      (       a  gU [        -  nUR                  5       (       d  g[        R                  " U5      nUS   U;  a  gX1S      nUR                  S/ 5      (       d  g[        X5      n[        U5      [        U5      :g  $ )a  Check if a command should be rerun because its settings or inputs/outputs
changed.

project_dir (Path): The current project directory.
command (Dict[str, Any]): The command, as defined in the project.yml.
strict_version (bool):
RETURNS (bool): Whether to re-run the command.
no_skipFTr<   outs)rC   r   r&   srsly	read_yamlget_lock_entryr   )r*   rs   	lock_pathdataentry
lock_entrys         r4   rJ   rJ      s     {{9e$$l*I??9%Dvd"!E99VR    5JJ8E?22r6   c                     U [         -  nUR                  5       (       d  [        R                  " U0 5        0 nO[        R                  " U5      n[        X5      X1S   '   [        R                  " X#5        g)a*  Update the lockfile after running a command. Will create a lockfile if
it doesn't yet exist and will add an entry for the current command, its
script and dependencies/outputs.

project_dir (Path): The current project directory.
command (Dict[str, Any]): The command, as defined in the project.yml.
r<   N)r   r&   r|   
write_yamlr}   r~   )r*   rs   r   r   s       r4   rL   rL      s_     l*IB'y)*;@D	Y%r6   )r0   c                    [        XR                  S/ 5      5      n[        XR                  S/ 5      5      n[        XR                  S/ 5      5      nU SUS    3US   U/ UQUQS.$ )a  Get a lockfile entry for a given command. An entry includes the command,
the script (command steps) and a list of dependencies and outputs with
their paths and file hashes, if available. The format is based on the
dvc.lock files, to keep things consistent.

project_dir (Path): The current project directory.
command (Dict[str, Any]): The command, as defined in the project.yml.
RETURNS (Dict[str, Any]): The lockfile entry.
r?   outputsoutputs_no_cacherW   r<   rB   )rN   rB   r?   r{   )get_fileinforC   )r*   rs   r0   r?   r{   outs_ncs         r4   r~   r~     sz     [[%<=D[[B%?@D;4F(KLG !wv&78(#!$!!	 r6   pathsc                     / nU H<  nX-  nUR                  5       (       a  [        U5      OSnUR                  X5S.5        M>     U$ )a  Generate the file information for a list of paths (dependencies, outputs).
Includes the file path and the file's checksum.

project_dir (Path): The current project directory.
paths (List[str]): The file paths.
RETURNS (List[Dict[str, str]]): The lockfile entry for a file.
N)pathmd5)r&   r   rw   )r*   r   r   r   	file_pathr   s         r4   r   r   )  sK     D&	)2)9)9););l9%T./  Kr6   )3rp   pathlibr   typingr   r   r   r   r   r	   r|   typerwasabir
   wasabi.utilr   utilr   r   r   r   r   r   r   r   r   r   r   r   mainr   r   r   r   r   r   r    rs   cwdContextstrboolr5   r3   r1   rK   rD   rJ   rL   r~   r    r6   r4   <module>r      s   
  @ @    % K K T T R R T T  	QUV $'F|n%UVDHHJ-t  ~B  NS  TeY3deE7D/\]%0]^
	
 
 	

 
 

 

H !1 2$)!=6=6=6 CH~	=6
 =6 
=6 =6 "=6 =6 
=6B 48w,Y,Y#+C=,YIL,Y	,Y` /0	!2sm!2!2 
!2 	!2
 
!2H
sm
(0
CF
	
233#s(^3 
3@& &S#X &4 && JQ $S#XCF	#s(^.d 49 d3QTCU>V9W r6   