o
    `۷iK"                     @   s  d dl Z d dlZd dlZd dlZd dlmZmZ d dlZd dlm	Z	 e
eZi ai i ddi i dZdd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Z d+d, Z!d-d. Z"d/d0 Z#eeeeeeeeeee#ed1Z$d2d3d4d5d6d7d8d9d:d;d<d=d>Z%eeeee e!e"eed?	Z&d@ee'ef fdAdBZ(	CdMd@ee'ef dDe'dEe)dFefdGdHZ*dIdJ Z+dKdL Z,dS )N    N)AnyDictload_function_or_class)ray.head.defaultzray.worker.defaultr   )available_node_typeshead_node_type	head_nodeworker_nodesc              
   C   @   zdd l }W n ty } ztd|d }~ww ddlm} |S )Nr   z}The Ray AWS VM launcher requires the AWS SDK for Python (Boto3) to be installed. You can install it with `pip install boto3`.)AWSNodeProvider)boto3ImportError)ray.autoscaler._private.aws.node_providerr   )provider_configr   er    r   W/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/autoscaler/_private/providers.py_import_aws   s   r   c              
   C   r   )Nr   zThe Ray GCP VM launcher requires the Google API Client to be installed. You can install it with `pip install google-api-python-client`.)GCPNodeProvider)googleapiclientr   )ray.autoscaler._private.gcp.node_providerr   )r   r   r   r   r   r   r   _import_gcp,   s   r   c                 C      ddl m} |S )Nr   )AzureNodeProvider),ray.autoscaler._private._azure.node_providerr   )r   r   r   r   r   _import_azure:      r   c                 C   r   )Nr   )VsphereWcpNodeProvider)-ray.autoscaler._private.vsphere.node_providerr   )r   r   r   r   r   _import_vsphere@   r   r    c                 C   s(   d| v rddl m} |S ddlm} |S )Ncoordinator_addressr   )CoordinatorSenderNodeProvider)LocalNodeProvider)7ray.autoscaler._private.local.coordinator_node_providerr"   +ray.autoscaler._private.local.node_providerr#   )r   r"   r#   r   r   r   _import_localF   s
   r&   c                 C   r   )Nr   )ReadOnlyNodeProvider).ray.autoscaler._private.readonly.node_providerr'   )r   r'   r   r   r   _import_readonlyS   r   r)   c                 C   r   )Nr   )FakeMultiNodeProvider)5ray.autoscaler._private.fake_multi_node.node_providerr*   )r   r*   r   r   r   _import_fake_multinodeY      r,   c                 C   r   )Nr   )FakeMultiNodeDockerProvider)r+   r.   )r   r.   r   r   r   _import_fake_multinode_dockera   r-   r/   c                 C   r   )Nr   )KubeRayNodeProvider)-ray.autoscaler._private.kuberay.node_providerr0   )r   r0   r   r   r   _import_kuberayi   r   r2   c                 C   r   )Nr   )AliyunNodeProvider),ray.autoscaler._private.aliyun.node_providerr3   )r   r3   r   r   r   _import_aliyuno   r   r5   c                 C   r   )Nr   )SparkNodeProvider)+ray.autoscaler._private.spark.node_providerr6   )r   r6   r   r   r   _import_sparku   r   r8   c                  C   0   dd l m  m  m}  tjtj| jdS )Nr   zexample.yaml	'ray.autoscaler._private.fake_multi_node
autoscaler_privatefake_multi_nodeospathjoindirname__file__ray_fake_multinoder   r   r   $_load_fake_multinode_defaults_config{      rF   c                  C   r9   Nr   zdefaults.yaml)	 ray.autoscaler._private.readonlyr<   r=   readonlyr?   r@   rA   rB   rC   )ray_readonlyr   r   r   _load_read_only_defaults_config   rG   rL   c                  C   r9   )Nr   zexample_docker.yamlr:   rD   r   r   r   +_load_fake_multinode_docker_defaults_config   s   rM   c                  C   *   dd l m  m}  tjtj| jdS rH   )ray.autoscaler.localr<   localr?   r@   rA   rB   rC   )	ray_localr   r   r   _load_local_defaults_config      rR   c                  C   rN   rH   )ray.autoscaler.awsr<   awsr?   r@   rA   rB   rC   )ray_awsr   r   r   _load_aws_defaults_config   rS   rW   c                  C   rN   rH   )ray.autoscaler.vspherer<   vspherer?   r@   rA   rB   rC   )ray_vspherer   r   r   _load_vsphere_defaults_config   rS   r[   c                  C   rN   rH   )ray.autoscaler.gcpr<   gcpr?   r@   rA   rB   rC   )ray_gcpr   r   r   _load_gcp_defaults_config   rS   r_   c                  C   rN   rH   )ray.autoscaler.azurer<   azurer?   r@   rA   rB   rC   )	ray_azurer   r   r   _load_azure_defaults_config   rS   rc   c                  C   rN   rH   )ray.autoscaler.aliyunr<   aliyunr?   r@   rA   rB   rC   )
ray_aliyunr   r   r   _load_aliyun_defaults_config   rS   rg   c                 C   s   t | d d}|S )Nmodule)r@   r   )r   provider_clsr   r   r   _import_external   s   rj   )rP   fake_multinodefake_multinode_dockerrJ   rU   r]   rY   ra   kuberayre   externalsparkzReadonly (Manual Cluster Setup)zFake MultinodezFake Multinode DockerLocalAWSGCPAzureKubeRayAliyunExternalvSphereSpark)rJ   rk   rl   rP   rU   r]   ra   rm   re   rn   rY   ro   )	rk   rl   rP   rU   r]   ra   re   rY   rJ   r   c                 C   s0   t | d }|du rtd| d || S )aQ  Get the node provider class for a given provider config.

    Note that this may be used by private node providers that proxy methods to
    built-in node providers, so we should maintain backwards compatibility.

    Args:
        provider_config: provider section of the autoscaler config.

    Returns:
        NodeProvider class
    typeNUnsupported node provider: {})_NODE_PROVIDERSgetNotImplementedErrorformat)r   importerr   r   r   _get_node_provider_cls   s   r   Tcluster_name	use_cachereturnc                 C   sH   t j| dd|f}|r|tv rt| S t| }|| |}|r"|t|< |S )a,  Get the instantiated node provider for a given provider config.

    Note that this may be used by private node providers that proxy methods to
    built-in node providers, so we should maintain backwards compatibility.

    Args:
        provider_config: provider section of the autoscaler config.
        cluster_name: cluster name from the autoscaler config.
        use_cache: whether or not to use a cached definition if available. If
            False, the returned object will also not be stored in the cache.

    Returns:
        NodeProvider
    T)	sort_keys)jsondumps_provider_instancesr   )r   r   r   provider_keyri   new_providerr   r   r   _get_node_provider   s   
r   c                   C   s   i a d S )N)r   r   r   r   r   _clear_provider_cache  s   r   c                 C   s|   | d dkrt tS t| d }|du rtd| d | }t|}t	|}W d   |S 1 s7w   Y  |S )zRetrieve a node provider.

    This is an INTERNAL API. It is not allowed to call this from any Ray
    package outside the autoscaler.
    ry   rn   Nrz   )
copydeepcopyMINIMAL_EXTERNAL_CONFIG_DEFAULT_CONFIGSr|   r}   r~   openyaml	safe_load)r   load_configpath_to_defaultfdefaultsr   r   r   _get_default_config  s   


r   )T)-r   r   loggingr?   typingr   r   r   ray.autoscaler._private.loaderr   	getLogger__name__loggerr   r   r   r   r   r    r&   r)   r,   r/   r2   r5   r8   rF   rL   rM   rR   rW   r[   r_   rc   rg   rj   r{   _PROVIDER_PRETTY_NAMESr   strr   boolr   r   r   r   r   r   r   <module>   s    


