o
    ;i                     @   s   d dl mZmZ d dlmZ ddlmZ ddlmZm	Z	 dddeee
ee
e
f f  d	eeeeeef f  d
edee dee dejfddZdS )    )OptionalUnion)api_pb2   )InvalidError)GPU_Tparse_gpu_configN)rdmacpumemorygpuephemeral_diskr	   returnc           
   	   C   s  t |}| r:t| tr:| d std| d stdtd| d  }td| d  }||k r9td| d| n| rLt| ttfrLtd|  }d }nd }d }|r\t|tr\|}d}	n|rvt|trv|\}}	|	|k rutd|	 d| nd}d}	tj|||||	||pd	d
S )Nr   z%CPU request must be a positive numberr   z#CPU limit must be a positive numberi  z/Cannot specify a CPU limit lower than request: z < z2Cannot specify a memory limit lower than request: F)	milli_cpumilli_cpu_max
gpu_config	memory_mbmemory_mb_maxephemeral_disk_mbr	   )r   
isinstancetupler   intfloatr   	Resources)
r
   r   r   r   r	   r   r   r   r   r    r   D/home/ubuntu/.local/lib/python3.10/site-packages/modal/_resources.py%convert_fn_config_to_resources_config
   sF   r   )typingr   r   modal_protor   	exceptionr   r   r   r   r   r   r   boolr   r   r   r   r   r   <module>   s$   	