
    tnic                         d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ	 ddlm
Z
mZ d ZdefdZdefd	Zd
 Zd Zd ZdS )z,Helper functions for project group commands.    N)
create_pod)error)get_endpointsget_podsc                     t          j        d|           }|r*t          j        d|                                 d          | S )z$
    Validate the project name.
    z[<>:\"/\\|?*\s]z-Project name contains an invalid character: 'z'.)researchclickBadParametergroup)namematchs     ^/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/runpod/cli/groups/project/helpers.pyvalidate_project_namer      sP     I($//E 
 MEKKMMMMM
 
 	
 K    
project_idc                 P    t                      D ]}| |d         v r
|d         c S dS )zYCheck if a project pod exists.
    Return the pod_id if it exists, else return None.
    r   idN)r   )r   pods     r   get_project_podr      sB     zz  V$$t9 % 4r   c                 D    t                      D ]}| |d         v r|c S dS )z`Check if a project endpoint exists.
    Return the endpoint if it exists, else return None.
    r   N)r   )r   endpoints     r   get_project_endpointr   &   s<     "OO  &)))OOO * 4r   c                 H   t          j        |           D ]}t           j                            | |          }t           j                            ||          }t           j                            |          rt          j        ||           wt          j        ||           dS )z5Copy the template files to the destination directory.N)oslistdirpathjoinisdirshutilcopytreecopy2)template_dirdestinationitemsource_itemdestination_items        r   copy_template_filesr(   1   s    
<(( 8 8gll<667<<T::7==%% 	8OK)9::::L&677778 8r   c                    | d                              dg           D ]}t          d| dd           	 t          | d         d          d| d         d	          d
| d         d         |t          | d         d                   d| d         d          | d         d          | d         d          t          | d         d                   |
  
        }t          d           |c S # t          j        $ r t          d           Y w xY wdS )z5Attempt to launch a pod with the given configuration.project	gpu_typeszTrying to get a pod with z...  )endr   z-dev (uuid)
base_image	gpu_countTports
storage_idvolume_mount_pathcontainer_disk_size_gb)r1   support_public_ipr2   network_volume_idr4   container_disk_in_gbenvzSuccess!zUnavailable.N)getprintr   intrp_error
QueryError)configenvironment_variablesgpu_typecreated_pods       r   attempt_pod_launchrC   <   sK   9%))+r:: " "8(888bAAAA	"$)$V,PPF94Ef4MPPPy!,/fY/<=="&	*735%+I%6|%D"F%+I%67J%K"M%(	):;S)T%U%U)  K *" 	" 	" 	".!!!!!	"4s   B,C$$DDc                  @   t           j                            t          j                    d          } t           j                            |           st          d          t          | dd          5 }t          j        |          cddd           S # 1 swxY w Y   dS )zLoad the project config file.zrunpod.tomlz/runpod.toml not found in the current directory.rzUTF-8)encodingN)	r   r   r   getcwdexistsFileNotFoundErroropentomlkitload)project_config_fileconfig_files     r   load_project_configrO   T   s    ',,ry{{MBB7>>-.. S QRRR	!3	9	9	9 )[|K(() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   2BBB)__doc__r   r   r    r
   rK   runpodr   r   r=   r   r   r   strr   r   r(   rC   rO    r   r   <module>rT      s    2 2 				 				          $ $ $ $ $ $ * * * * * * * *	 	 	    S    8 8 8  0) ) ) ) )r   