
    h!                        S r SSKr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JrJrJrJr  SS	KJrJrJrJrJrJr  S
rSrSrS\ S\ S\ S\ 3r\R8                  " \5      \" \R:                  " 5       SSSS9\" SS\ S3S9\" SSSSS9\" SSSSS9\" SSSS S94S!\S"\\   S#\S$\S%\4
S& jj5       r  S0SSSS'.S!\S"\\   S#\S$\S%\S(S4S) jjjr!    S1S*\S+\\\4   S"\\   S#\S$\S%\S(\4S, jjr"S0S-\\   S"\\   S(S4S. jjr#S!\S(S4S/ jr$g)2ztThis module contains helpers and subcommands for integrating Weasel
with Data Version Control (DVC). https://dvc.org    N)Path)AnyDictListOptional)msg   )get_hashjoin_commandload_project_configrun_commandworking_dir   )COMMANDNAMEPROJECT_FILEArgOptappzdvc.yaml.dvcdvcz6# This file is auto-generated by Weasel based on your z. If you've
# edited your z-, you can regenerate this file by running:
#  zELocation of project directory. Defaults to current working directory.TF)helpexists	file_okayzName of workflow defined in z(. Defaults to first workflow if not set.)r   	--verbosez-VzPrint more info--quietz-qzPrint less infoz--forcez-FzForce update DVC configproject_dirworkflowverbosequietforcec                     [        XX#US9  g)aj  Auto-generate Data Version Control (DVC) config. A DVC
project can only define one pipeline, so you need to specify one workflow
defined in the project.yml. If no workflow is specified, the first defined
workflow is used. The DVC config will only be updated if the project.yml
changed.

DOCS: https://github.com/explosion/weasel/tree/main/docs/cli.md#repeat-dvc
r    r!   r"   N)project_update_dvc)r   r   r    r!   r"   s        H/home/james-whalen/.local/lib/python3.13/site-packages/weasel/cli/dvc.pyproject_update_dvc_clir'      s    $ {gRWX    r$   returnc          	          [        U 5      n[        XXX4S9nSnU(       a  [        R                  " S[         3U5        g[        R
                  " S[         S3U5        g)a  Update the auto-generated Data Version Control (DVC) config file. A DVC
project can only define one pipeline, so you need to specify one workflow
defined in the project.yml. Will only update the file if the checksum changed.

project_dir (Path): The project directory.
workflow (Optional[str]): Optional name of workflow defined in project.yml.
    If not set, the first workflow will be used.
verbose (bool): Print more info.
quiet (bool): Print less info.
force (bool): Force update DVC config.
r$   z0To execute the workflow with DVC, run: dvc reprozUpdated DVC config from zNo changes found in z, no update neededN)r   update_dvc_configr   goodr   info)r   r   r    r!   r"   configupdatedhelp_msgs           r&   r%   r%   )   sY    & !-FXeG BH+L>:HE'~5GH(Sr(   pathr.   c           	      J   [        U 5        UR                  S0 5      n[        UR                  5       5      n[	        Xr5        U(       d  US   n[        U5      nU R                  5       n U [        -  n	U	R                  5       (       ae  U	R                  SSS9 n
U
R                  5       R                  5       R                  SS5      nSSS5        WU:X  a  U(       d  g	U	R                  5         / nUR                  S
/ 5       Vs0 s H  oS   U_M
     nn/ nU(       a  UR                  S5        U(       a  UR                  S5        Xb    GHZ  nUU   nUR                  S/ 5      nUR                  S/ 5      nUR                  S/ 5      nU(       d  U(       d	  U(       d  MV  SS[        SSU/nU Vs/ s H  nSU/PM	     sn VVs/ s H  nU  H  nUPM     M     nnnU Vs/ s H  nSU/PM	     sn VVs/ s H  nU  H  nUPM     M     nnnU Vs/ s H  nSU/PM	     sn VVs/ s H  nU  H  nUPM     M     nnnS/UQSPUPSP[!        U 5      PSPnUR                  S5      (       a  UR                  S5        / UQUQUQUQUQnUR                  [#        U5      5        GM]     U(       d  [$        R&                  " SSS9  [)        U 5         U H  nS U-   n[+        U5        M     SSS5        U	R                  S!SS9 n
U
R-                  5       nU
R/                  SS5        U
R1                  SU S"[2         S"U 35        SSS5        g#! , (       d  f       GN= fs  snf s  snf s  snnf s  snf s  snnf s  snf s  snnf ! , (       d  f       N= f! , (       d  f       g#= f)$aV  Re-run the DVC commands in dry mode and update dvc.yaml file in the
project directory. The file is auto-generated based on the config. The
first line of the auto-generated file specifies the hash of the config
dict, so if any of the config values change, the DVC config is regenerated.

path (Path): The path to the project directory.
config (Dict[str, Any]): The loaded project.yml.
verbose (bool): Whether to print additional info (via DVC).
quiet (bool): Don't output anything (via DVC).
force (bool): Force update, even if hashes match.
RETURNS (bool): Whether the DVC config file was updated.
	workflowsr   rutf8)encodingz#  NFcommandsnamer   r   depsoutputsoutputs_no_cachepythonz-mprojectrunz-dz-oz-Oz-nz-wz	--no-execno_skipz--always-changedzhNo usable commands for DVC found. This can happen if none of your commands have dependencies or outputs.r   exitszdvc zr+
T)
ensure_dvcgetlistkeyscheck_workflowsr
   resolve
DVC_CONFIGr   openreadlinestripreplaceunlinkappendr   strr   r   failr   r   readseekwriteDVC_CONFIG_COMMENT) r1   r.   r   r    r!   r"   r3   workflow_namesconfig_hashdvc_config_pathfref_hashdvc_commandscmdconfig_commandsflagsr9   commandr:   r;   r<   project_cmdpclcdeps_cmdoutputs_cmdoutputs_nc_cmddvc_cmdfull_cmddvc_commandcontents                                    r&   r+   r+   G   sf   ( t

;+I)..*+NN-!!$6"K<<>DZ'O!!#!71zz|))+33D"=H 8{"5 L39::j"3MN3MC6{C'3MON E[!Y#!$'{{62&++i,";;'92>G,<  tYtD48 9Dq$D 9F 9"2aA2A 9F7>#?w!T1Iw#?L#?RAqq#?L:J&K:JQay:J&KX&KUWPQ!UW!&KXK5K$KKdKCIK{K;;y!!NN-.UWUxU+UUUL23% $(  	5	
 
T	A 1*K$  
 
		dV		4&&(	q!	"[M$6#7r'CD 
5 i 87 O& !:F#?L&KX" 
	 
5	4 sO   /MM/M"M' M-4M2M8%M=NAN
M
N
N"r3   c           
         U (       d  [         R                  " S[         S3SS9  Ub6  X;  a1  [         R                  " SU S[         SS	R                  U 5       3SS9  U(       d%  [         R                  " S
[         SU S    S35        gg)zValidate workflows provided in project.yml and check that a given
workflow can be used to generate a DVC config.

workflows (List[str]): Names of the available workflows.
workflow (Optional[str]): The name of the workflow to convert.
zNo workflows defined in zA. To generate a DVC config, define at least one list of commands.r   rA   Nz
Workflow 'z' not defined in z. Available workflows: z, zLNo workflow specified for DVC pipeline. Using the first workflow defined in z: 'r   ')r   rR   r   joinwarn)r3   r   s     r&   rH   rH      s     &|n 54 5	

  9
"3L> B$$(IIi$8#9;	

 &s9Q<.;	
 r(   c                      [         R                  " SS/[         R                  S9  U S-  R                  5       (       d  [        R
                  " S	S
SS9  gg! [         a    [        R
                  " SSSS9   NRf = f)zqEnsure that the "dvc" command is available and that the current project
directory is an initialized DVC project.
r   z	--version)stdoutztTo use Weasel with DVC (Data Version Control), DVC needs to be installed and the 'dvc' command needs to be availablezYou can install the Python package from pip (pip install dvc) or conda (conda install -c conda-forge dvc). For more details, see the documentation: https://dvc.org/doc/installr   rA   r   z(Project not initialized as a DVC projectzTo initialize a DVC project, you can run 'dvc init' in the project directory. For more details, see the documentation: https://dvc.org/doc/command-reference/initN)
subprocessr?   DEVNULL	Exceptionr   rR   r   )r   s    r&   rD   rD      s    

{+J4F4FG & ((**69 	
 +  
J9 	

s   %A  A:9A:)N)NFFF)%__doc__rr   pathlibr   typingr   r   r   r   wasabir   utilr
   r   r   r   r   mainr   r   r   r   r   r   rJ   DVC_DIRUPDATE_COMMANDrV   r`   cwdrQ   boolr'   r%   r+   rH   rD    r(   r&   <module>r      s&  4   , ,  X X < <

OP\~ ^n 
)1^  
 ^ DHHJ-t  ~B  NS  T!$/KL>  ZB  .C  D{D7HIeY3DEeY3LMYY smY 	Y
 Y Y Y, #T TTsmT 	T
 T T 
TB #S
ScNS smS 	S
 S S 
Sl
tCy 
HSM 
T 
4
D 
T 
r(   