o
    ciq                     @   sH  d dl Z d dlZd dlZd dlZd dlmZmZmZmZ d dl	Z	d dl
Z	d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ eeZ					dd	ed
ededeeeeeef f  dee dee dee defddZ			ddedededeeef dee dee dedee defddZdedefddZdS )    N)AnyDictOptionalUnion)DeploymentID)DeploymentConfigReplicaConfig)SERVE_LOGGER_NAME)DeploymentInfo)ServeApplicationSchemaFnamereplica_configingressdeployment_configversionroute_prefix	docs_pathreturnc                 C   sb   |du ri }t |trt|}n	t |tstd||_| | | |t 	 ||d}|S )zs
    Takes a deployment's configuration, and returns the arguments needed
    for the controller to deploy it.
    Nz2config must be a DeploymentConfig or a dictionary.)deployment_namedeployment_config_proto_bytesreplica_config_proto_bytesr   deployer_job_idr   r   )

isinstancedictr   	parse_obj	TypeErrorr   to_proto_bytesrayget_runtime_context
get_job_id)r   r   r   r   r   r   r   controller_deploy_args r!   S/home/ubuntu/.local/lib/python3.10/site-packages/ray/serve/_private/deploy_utils.pyget_deploy_args   s    



r#   r   r   r   r   app_namec                 K   st   t |}	|	j}
t||	 }t|tr!tj	t
|d }tt| |d |
|	||t
t d |||d	S )z}Takes deployment args passed to the controller after building an application and
    constructs a DeploymentInfo object.
    little)r   r$   i  )	
actor_namer   r   r   r   start_time_msr   r   r   )r   from_proto_bytesr   r   needs_pickler   bytesr   JobIDfrom_intint
from_byteshexr
   r   to_replica_actor_class_nametime)r   r   r   r   r   r$   r   r   kwargsr   r   r   r!   r!   r"   deploy_args_to_deployment_info6   s2   


r3   
app_configc                 C   s0   t j| j| j| jdddd}t| S )zReturns the code version of an application.

    Args:
        app_config: The application config.

    Returns: a hash of the import path and (application level) runtime env representing
            the code version of the application.
    )import_pathruntime_envargsT)	sort_keyszutf-8)	jsondumpsr5   r6   r7   encodehashlibsha1	hexdigest)r4   encodedr!   r!   r"   get_app_code_version`   s   	r@   )FNNNN)NFN)r<   r9   loggingr1   typingr   r   r   r   r   ray.util.serialization_addonsray.serve._private.commonr   ray.serve._private.configr   r   ray.serve._private.constantsr	   "ray.serve._private.deployment_infor
   ray.serve.schemar   	getLoggerloggerstrboolr#   r*   r3   r@   r!   r!   r!   r"   <module>   st    

*


*