o
    i
                     @   s   d dl mZ d dlmZ ddlmZmZ ddlmZm	Z	 ddl
mZmZmZ e	ded	d
dee ddddfdedefddZdedefddZdefddZdS )    )Path)msg   )load_project_configlogger   )Argapp)RemoteStorageget_command_hashget_content_hashpushdefaultzName or path of remote storage)helpzELocation of project directory. Defaults to current working directory.TF)r   exists	file_okayremoteproject_dirc                 C   sH   t || D ]\}}|du rtd|  qtd| d|  qdS )aU  Persist outputs to a remote storage. You can alias remotes in your
    project.yml by mapping them to storage paths. A storage can be anything that
    the smart_open library can upload to, e.g. AWS, Google Cloud Storage, SSH,
    local directories etc.

    DOCS: https://github.com/explosion/weasel/tree/main/docs/cli.md#arrow_up-push
    Nz	Skipping zPushed z to )project_pushr   infogood)r   r   output_pathurl r   C/home/ubuntu/.local/lib/python3.10/site-packages/weasel/cli/push.pyproject_push_cli
   s
   r   c           
   	   #   s    t  }||di v r|d | }t |}|dg D ]o}td|d   fdd|dg D }tdd	 |D rGtd
|d  qtdd fdd|dg D |d }td| |dg D ]%} | }| rt|r|j	||t
|d}	td|	|| ||	fV  qgqdS )zPersist outputs to a remote storage. You can alias remotes in your project.yml
    by mapping them to storage paths. A storage can be anything that the smart_open
    library can upload to, e.g. gcs, aws, ssh, local directories etc
    remotescommandszCMD: %snamec                       g | ]} | qS r   r   .0depr   r   r   
<listcomp>*       z project_push.<locals>.<listcomp>depsc                 s   s    | ]}|   V  qd S N)r   r    r   r   r   	<genexpr>+   s    zproject_push.<locals>.<genexpr>z'Dependency missing. Skipping %s outputs c                    r   r   r   r    r#   r   r   r$   /   r%   scriptzCMD_HASH: %soutputs)command_hashcontent_hashz&URL: %s for output %s with cmd_hash %sN)r   getr
   r   debuganyr   r   _is_not_empty_dirr   r   )
r   r   configstoragecmdr&   cmd_hashr   
output_locr   r   r#   r   r      s<   
"
r   locc                 C   s*   |   sdS tdd |  D rdS dS )NTc                 s   s    | ]}t |V  qd S r'   )r1   )r!   childr   r   r   r(   C   s    z$_is_not_empty_dir.<locals>.<genexpr>F)is_dirr0   iterdir)r7   r   r   r   r1   @   s
   r1   N)pathlibr   wasabir   utilr   r   mainr   r	   remote_storager
   r   r   commandcwdstrr   r   r1   r   r   r   r   <module>   s    
!