
    &`it                     N   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	m
Z
mZmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZ d dlmZmZ d dlmZmZmZ d d	l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* d d
l+m,Z, d dl-m.Z.m/Z/  ej0        e*          Z1 e/d           G d d                      Z2 e/d           G d de                      Z3dZ4 e/d           G d de5e                      Z6 e/d           G d de                      Z7 e/d           G d de                      Z8e. G d de5e                      Z9 e/d           G d de5e                      Z: e/d           G d de                      Z; e/d           G d  d!e                      Z<dS )"    N)Enum)cached_property)AnyCallableDictListOptionalUnion)cloudpickle)	BaseModelFieldNonNegativeFloatNonNegativeIntPositiveFloatPositiveIntPrivateAttr	validator)import_attrimport_module_and_attr)DeploymentID	ReplicaID
TimeSeries)
DEFAULT_AUTOSCALING_POLICY_NAMEDEFAULT_GRPC_PORTDEFAULT_HTTP_HOSTDEFAULT_HTTP_PORTDEFAULT_REQUEST_ROUTER_PATH&DEFAULT_REQUEST_ROUTING_STATS_PERIOD_S'DEFAULT_REQUEST_ROUTING_STATS_TIMEOUT_SDEFAULT_TARGET_ONGOING_REQUESTS$DEFAULT_UVICORN_KEEP_ALIVE_TIMEOUT_SSERVE_LOGGER_NAME)validate_ssl_config)
Deprecated	PublicAPIalpha)	stabilityc            #          e Zd ZdZdededee         dededee	         de
eeg ef         f         d	ee
eeg ef         f                  d
ee
eeee	ef         f         eg eeee	ef         f         f         f                  dee
eeee	ef         f         eg eeee	ef         f         f         f                  dededeeef         dee         dee         dee         dee         f"dZedeeeee	ef         f                  fd            Zedeeeee	ef         f                  fd            Zedefd            Zedefd            Zedefd            ZdS )AutoscalingContextar  Rich context provided to custom autoscaling policies.

    This class provides comprehensive information about a deployment's current state,
    metrics, and configuration that can be used by custom autoscaling policies to
    make intelligent scaling decisions.

    The context includes deployment metadata, current replica state, built-in and
    custom metrics, capacity bounds, policy state, and timing information.

    Note: The aggregated_metrics and raw_metrics fields support lazy evaluation.
    You can pass callables that will be evaluated only when accessed, with results
    cached for subsequent accesses.
    deployment_iddeployment_nameapp_namecurrent_num_replicastarget_num_replicasrunning_replicastotal_num_requeststotal_queued_requestsaggregated_metricsraw_metricscapacity_adjusted_min_replicascapacity_adjusted_max_replicaspolicy_statelast_scale_up_timelast_scale_down_timecurrent_timeconfigc                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        || _        || _        || _        || _        || _        d S N)r*   r+   r,   r-   r.   r/   _total_num_requests_value_total_queued_requests_value_aggregated_metrics_value_raw_metrics_valuer4   r5   r6   r7   r8   r9   r:   )selfr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   s                     d/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/serve/config.py__init__zAutoscalingContext.__init__9   s    > +.  ! 	!   	   	  	& " 	)
 *<&"- /M+.L+  	  	 ! 	! )     returnc                 `    t          | j                  r|                                 S | j        S r<   )callabler?   rA   s    rB   r2   z%AutoscalingContext.aggregated_metrics   0    D233 	411333--rD   c                 `    t          | j                  r|                                 S | j        S r<   )rG   r@   rH   s    rB   r3   zAutoscalingContext.raw_metrics   s0    D+,, 	-**,,,&&rD   c                 `    t          | j                  r|                                 S | j        S r<   )rG   r=   rH   s    rB   r0   z%AutoscalingContext.total_num_requests   rI   rD   c                 `    t          | j                  r|                                 S | j        S r<   )rG   r>   rH   s    rB   r1   z(AutoscalingContext.total_queued_requests   s0    D566 	74466600rD   c                      | j         | j        z
  S r<   )r0   r1   rH   s    rB   total_running_requestsz)AutoscalingContext.total_running_requests   s     &)CCCrD   N)__name__
__module____qualname____doc__r   strr	   intr   r   r
   floatr   r   r   r   rC   r   r2   r3   r0   r1   propertyrN    rD   rB   r)   r)   )   s        M#M M 3-	M
 "M !M y/M "%"e))<"<=M  (eXb%i5H.H(IJM %S$y%/001T#tIu,<'="=>>?A
M  S$y*4556T#tIz,A'B"BCCDF
!M, ),-M. ),/M0 38n1M2 %UO3M4 'uo5M6 uo7M8 9M M M M^ .HT#tIu<L7M2M-N$O . . . _.
 'Xd3Y
5J0K+K&LM ' ' ' _'
 .E . . . _.
 1u 1 1 1 _1
 D D D D XD D DrD   r)   c                       e Zd ZU dZ ed          Zeed<    ee	d          Z
eeef         ed<    eed	          Zeeef         ed
<    eed          Zeed<    eed          Zeed<    ed
d          d             Zdeeef         f fdZdeddfdZedededd fd            Zdee         fdZddZdefdZ  xZ!S )RequestRouterConfiga  Config for the Serve request router.

    This class configures how Ray Serve routes requests to deployment replicas. The router is
    responsible for selecting which replica should handle each incoming request based on the
    configured routing policy. You can customize the routing behavior by specifying a custom
    request router class and providing configuration parameters.

    The router also manages periodic health checks and scheduling statistics collection from
    replicas to make informed routing decisions.

    Example:
        .. code-block:: python

            from ray.serve.config import RequestRouterConfig, DeploymentConfig
            from ray import serve

            # Use default router with custom stats collection interval
            request_router_config = RequestRouterConfig(
                request_routing_stats_period_s=5.0,
                request_routing_stats_timeout_s=15.0
            )

            # Use custom router class
            request_router_config = RequestRouterConfig(
                request_router_class="ray.serve.llm.request_router.PrefixCacheAffinityRouter",
                request_router_kwargs={"imbalanced_threshold": 20}
            )
            deployment_config = DeploymentConfig(
                request_router_config=request_router_config
            )
            deployment = serve.deploy(
                "my_deployment",
                deployment_config=deployment_config
            )
    rD   default_serialized_request_router_clsa  The class of the request router that Ray Serve uses for this deployment. This value can be a string or a class. All the deployment handles that you create for this deployment use the routing policy defined by the request router. Default to Serve's PowerOfTwoChoicesRequestRouter.r[   descriptionrequest_router_classz\Keyword arguments that Ray Serve passes to the request router class initialize_state method.default_factoryr^   request_router_kwargsa  Duration between record scheduling stats calls for the replica. Defaults to 10s. The health check is by default a no-op Actor call to the replica, but you can define your own request scheduling stats using the 'record_scheduling_stats' method in your deployment.request_routing_stats_period_szDuration in seconds, that replicas wait for a request scheduling stats method to return before considering it as failed. Defaults to 30s.request_routing_stats_timeout_sTalwaysc                     t          |t                    r|S |H	 t          j        |           n2# t          $ r%}t          dt          |           d          d }~ww xY w|S )Nz0request_router_kwargs is not JSON-serializable: .)
isinstancebytesjsondumps	TypeError
ValueErrorrS   )clsves      rB   'request_router_kwargs_json_serializablez;RequestRouterConfig.request_router_kwargs_json_serializable   s~    a 	H=
1    Ps1vvPPP  
 s   0 
A AAkwargsc                     |                     dd          } t                      j        di | |r	|| _        dS |                                  dS )a  Initialize RequestRouterConfig with the given parameters.

        Needed to serialize the request router class since validators are not called
        for attributes that begin with an underscore.

        Args:
            **kwargs: Keyword arguments to pass to BaseModel.
        r\   NrW   )popsuperrC   r\   _serialize_request_router_cls)rA   rs   serialized_request_router_cls	__class__s      rB   rC   zRequestRouterConfig.__init__   sk     )/

,d)
 )
% 	""6"""( 	12OD///..00000rD   rx   rE   Nc                     || _         d S r<   r\   )rA   rx   s     rB   !set_serialized_request_router_clsz5RequestRouterConfig.set_serialized_request_router_cls  s     /L+++rD   request_router_configc                 D    |                                 }||d<    | di |S )Nr\   rW   copy)ro   r}   rx   r:   s       rB   "from_serialized_request_router_clsz6RequestRouterConfig.from_serialized_request_router_cls  s2     '++--3P/0s}}V}}rD   c                     | j         S r<   r{   rH   s    rB   !get_serialized_request_router_clsz5RequestRouterConfig.get_serialized_request_router_cls  s    22rD   c                 B   | j         }t          |t                    r|j         d|j         }|pt
          }t          |          \  }}t          j        |           | 	                    t          j
        |                     t          j        |           || _         dS )zImport and serialize request router class with cloudpickle.

        Import the request router if you pass it in as a string import path.
        Then cloudpickle the request router and set to
        `_serialized_request_router_cls`.
        rh   N)r_   ri   r   rP   rO   r   r   r   register_pickle_by_valuer|   rl   unregister_pickle_by_value)rA   r_   request_router_pathrequest_router_modules       rB   rw   z1RequestRouterConfig._serialize_request_router_cls"  s      $8*H55 	'2TT5I5RTT ! 3Q6Q6L7
 7
33 	,-BCCC..{/@AU/V/VWWW./DEEE %8!!!rD   c                     	 t          j        | j                  S # t          t          f$ r}t	          d| d          |d}~ww xY w)z7Deserialize the request router from cloudpickled bytes.z-Failed to deserialize custom request router: a  

This typically happens when the router depends on external modules that aren't available in the current environment. To fix this:
  - Ensure all dependencies are installed in your Docker image or environment
  - Package your router as a Python package and install it
  - Place the router module in PYTHONPATH

For more details, see: https://docs.ray.io/en/latest/serve/advanced-guides/custom-request-router.html#gotchas-and-limitationsN)r   loadsr\   ModuleNotFoundErrorImportErrorrA   rq   s     rB   get_request_router_classz,RequestRouterConfig.get_request_router_class:  sp    	$T%HIII#[1 
	 
	 
	E E E E	 	 	
	    AA  ArE   N)"rO   rP   rQ   rR   r   r\   rj   __annotations__r   r   r_   r
   rS   r   dictrb   r   r   r   rc   r   r   rd   r   rr   rC   r|   classmethodr   r	   r   rw   r   __classcell__ry   s   @rB   rY   rY      s/        " "H -8K,D,D,D"EDDD16+A2 2 2%X.    -2E'- - -4S>    5:E6M5 5 5"M    6;U7W6 6 6#]    Y&t444  541c3h 1 1 1 1 1 1$L-2L	L L L L
 $(IN	   [38E? 3 3 3 38 8 8 80(        rD   rY   g      $@c                       e Zd ZdZdZdZdS )AggregationFunctionmeanmaxminN)rO   rP   rQ   MEANMAXMINrW   rD   rB   r   r   N  s        D
C
CCCrD   r   c                        e Zd ZU  ed          Zeed<    eed          Z	e
eef         ed<    fdZded	d
fdZededed	d fd            Zd	ee         fdZddZd	efdZd	efdZ xZS )AutoscalingPolicyrD   rZ   _serialized_policy_defzPolicy function can be a string import path or a function callable. If it's a string import path, it must be of the form `path.to.module:function_name`. r]   policy_functionc                     |                     dd           } t                      j        di | |r	|| _        d S |                                  d S Nr   rW   )ru   rv   rC   r   serialize_policy)rA   rs   serialized_policy_defry   s      rB   rC   zAutoscalingPolicy.__init__`  sc     &

+CT J J""6"""  	$*?D'''!!#####rD   r   rE   Nc                     || _         d S r<   r   )rA   r   s     rB   set_serialized_policy_defz+AutoscalingPolicy.set_serialized_policy_defh  s    &;###rD   policy_configc                 D    |                                 }||d<    | di |S r   r   )ro   r   r   r:   s       rB   from_serialized_policy_defz,AutoscalingPolicy.from_serialized_policy_defk  s2     ##%%+@'(s}}V}}rD   c                     | j         S r<   r   rH   s    rB   get_serialized_policy_defz+AutoscalingPolicy.get_serialized_policy_defs  s    **rD   c                 >   | j         }t          |t                    r|j         d|j         }| j        sat          |          \  }}t          j        |           | 	                    t          j
        |                     t          j        |           || _         dS )zSerialize policy with cloudpickle.

        Import the policy if it's passed in as a string import path. Then cloudpickle
        the policy and set `serialized_policy_def` if it's empty.
        rh   N)r   ri   r   rP   rO   r   r   r   r   r   rl   r   )rA   policy_pathpolicy_moduler   s       rB   r   z"AutoscalingPolicy.serialize_policyv  s     *k8,, 	M(3LLk6JLLK* 	B-CK-P-P*M?0???**;+<_+M+MNNN2=AAA*rD   c                 "    | j         t          k    S r<   )r   r   rH   s    rB   is_default_policy_functionz,AutoscalingPolicy.is_default_policy_function  s    #'FFFrD   c                     	 t          j        | j                  S # t          t          f$ r}t	          d| d          |d}~ww xY w)z+Deserialize policy from cloudpickled bytes.z1Failed to deserialize custom autoscaling policy: a  

This typically happens when the policy depends on external modules that aren't available in the current environment. To fix this:
  - Ensure all dependencies are installed in your Docker image or environment
  - Package your policy as a Python package and install it
  - Place the policy module in PYTHONPATH

For more details, see: https://docs.ray.io/en/latest/serve/advanced-guides/advanced-autoscaling.html#gotchas-and-limitationsN)r   r   r   r   r   r   s     rB   
get_policyzAutoscalingPolicy.get_policy  sp    	$T%@AAA#[1 
	 
	 
	DA D D D	 	 	
	r   r   )rO   rP   rQ   r   r   rj   r   r   r   r   r
   rS   r   rC   r   r   r   r   r	   r   r   boolr   r   r   r   s   @rB   r   r   U  s[         %0K$<$<$<E<<<,1E/`- - -OU3=)   $ $ $ $ $<u < < < < <  9>	   [+8E? + + + ++ + + +&GD G G G GH        rD   r   stablec                   D   e Zd ZU dZdZeed<   dZee         ed<   dZ	e
ed<   eZee         ed<    eed	          Zeed
<    edd	          Zeed<    edd	          Zeed<    edd	          Zee         ed<    edd	          Zee         ed<    edd	          Zee         ed<    edd	          Zee         ed<    edd	          Zeed<    edd	          Zee         ed<    edd	          Zeed<    eej        d 	          Zeeef         ed!<    ee d"#          Z!e ed$<    e"dd%&          d'             Z# e"d
          d(ed)efd*            Z$ e"d!d%&          d(eeef         fd+            Z%e&d,             Z'd)efd-Z(d)efd.Z)d)efd/Z*dS )0AutoscalingConfigz Config for the Serve Autoscaler.   min_replicasNinitial_replicasmax_replicastarget_ongoing_requestsz[DEPRECATED] How often to scrape for metrics. Will be replaced by the environment variables `RAY_SERVE_REPLICA_AUTOSCALING_METRIC_PUSH_INTERVAL_S` and `RAY_SERVE_HANDLE_AUTOSCALING_METRIC_PUSH_INTERVAL_S` in a future release.r]   metrics_interval_sg      >@z(Time window to average over for metrics.look_back_period_sg      ?z8[DEPRECATED] Smoothing factor for autoscaling decisions.smoothing_factorz3[DEPRECATED] Please use `upscaling_factor` instead.upscale_smoothing_factorz5[DEPRECATED] Please use `downscaling_factor` instead.downscale_smoothing_factorz:Multiplicative "gain" factor to limit upscaling decisions.upscaling_factorz<Multiplicative "gain" factor to limit downscaling decisions.downscaling_factorg     @zHHow long to wait before scaling down replicas to a value greater than 0.downscale_delay_szuHow long to wait before scaling down replicas from 1 to 0. If not set, the value of `downscale_delay_s` will be used.downscale_to_zero_delay_sz,How long to wait before scaling up replicas.upscale_delay_sz8Function used to aggregate metrics across a time window.aggregation_functionzGThe autoscaling policy for the deployment. This option is experimental.r`   policyTre   c                 
   |                     d          }|                     d          }|||k     rt          d| d| d          |8||k     rt          d| d| d          ||k    rt          d| d| d          |S )	Nr   r   zmax_replicas (z1) must be greater than or equal to min_replicas (z)!zmin_replicas (z2) must be less than or equal to initial_replicas (z5) must be greater than or equal to initial_replicas ()getrn   )ro   r   valuesr   r   s        rB   replicas_settings_validz)AutoscalingConfig.replicas_settings_valid  s	   zz.11!::&899#|(C(C> > >-9> > >  
 ',.. J\ J J5EJ J J   "L00 J\ J J5EJ J J  
 rD   rp   rE   c                 P    |t           k    rt          j        dt                     |S )NzThe `metrics_interval_s` field in AutoscalingConfig is deprecated and will be replaced by the environment variables `RAY_SERVE_REPLICA_AUTOSCALING_METRIC_PUSH_INTERVAL_S` and `RAY_SERVE_HANDLE_AUTOSCALING_METRIC_PUSH_INTERVAL_S` in a future release.)DEFAULT_METRICS_INTERVAL_SwarningswarnDeprecationWarningro   rp   s     rB   &metrics_interval_s_deprecation_warningz8AutoscalingConfig.metrics_interval_s_deprecation_warning  s4    ***M] #   rD   c                     t          |t                    r|S t          t          |                                                    S r<   )ri   r   rS   lowerr   s     rB   aggregation_function_validz,AutoscalingConfig.aggregation_function_valid  s6    a,-- 	H"3q66<<>>222rD   c                 (     | t           dd          S )Nr   d   )r   r   r   )r    )ro   s    rB   r[   zAutoscalingConfig.default  s$    s$C
 
 
 	
rD   c                 :    | j         r| j         S | j        p| j        S r<   )r   r   r   rH   s    rB   get_upscaling_factorz&AutoscalingConfig.get_upscaling_factor  s'      	)((,E0EErD   c                 :    | j         r| j         S | j        p| j        S r<   )r   r   r   rH   s    rB   get_downscaling_factorz(AutoscalingConfig.get_downscaling_factor  s'    " 	+**.G$2GGrD   c                     | j         S r<   )r   rH   s    rB   get_target_ongoing_requestsz-AutoscalingConfig.get_target_ongoing_requests%  s    ++rD   )+rO   rP   rQ   rR   r   r   r   r   r	   r   r   r    r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r
   rS   r   r   r   r   r   r   r   r[   r   r   r   rW   rD   rB   r   r     s        ** $%L.$$$15h~.555 !L+!!!7VXm4VVV(-*U) ) )    )."L) ) )    ',eN' ' 'm   
 9>"W9 9 9h}5    ;@%K; ; ; 7   
 16P1 1 1h}-    38%R3 3 3/    +0%^+ + +'   
 =BE L= = =x(89    )."P) ) )O%    =BE#(N= = =%%8 89    !&)]! ! !F   
 Y~d+++  ,+. Y#$$	} 	 	 	 	 %$	 Y%d333356I1I+J 3 3 3 433
 
 
 [
Fm F F F FH H H H H,] , , , , , ,rD   r   c                       e Zd ZdZdZdZdS )DeploymentModeNoServerHeadOnly	EveryNodeN)rO   rP   rQ   r   r   r   rW   rD   rB   r   r   *  s        HHIIIrD   r   c                       e Zd ZdZdZdZdZeded e	f         de
fd            Zedeee
e	f                  ded          fd	            Zd
S )ProxyLocationa  Config for where to run proxies to receive ingress traffic to the cluster.

    Options:

        - Disabled: don't run proxies at all. This should be used if you are only
          making calls to your applications via deployment handles.
        - HeadOnly: only run a single proxy on the head node.
        - EveryNode: run a proxy on every node in the cluster that has at least one
          replica actor. This is the default.
    Disabledr   r   proxy_locationrE   c                    t          |t                    rt          |          }n5t          |t                    s t          dt	          |           d          |t          j        k    rt          j        S t          |j                  S )Nz'Must be a `ProxyLocation` or str, got: rh   )	ri   rS   r   rm   typer   r   r   value)ro   r   s     rB   _to_deployment_modez!ProxyLocation._to_deployment_modeB  s     nc** 	*>::NNNM:: 	Q$~:N:NQQQ   ]333!**!."6777rD   deployment_modec                    |dS t          |t                    rt          |          }n5t          |t                    s t          dt	          |           d          |t          j        k    rt          j        S t          |j                  S )zConverts DeploymentMode enum into ProxyLocation enum.

        DeploymentMode is a deprecated version of ProxyLocation that's still
        used internally throughout Serve.
        Nz(Must be a `DeploymentMode` or str, got: rh   )	ri   rS   r   rm   r   r   r   r   r   )ro   r   s     rB   _from_deployment_modez#ProxyLocation._from_deployment_modeR  s     "4-- 	,_==OOO^<< 	S4;P;PSSS   n555 )) !6777rD   N)rO   rP   rQ   rR   r   r   r   r   r
   rS   r   r   r	   r   rW   rD   rB   r   r   1  s        	 	 HHI8"?C#788	8 8 8 [8 8&u^S-@'AB8	/	"8 8 8 [8 8 8rD   r   c                      e Zd ZU dZeZee         ed<   e	Z
eed<   g Zee         ed<   ej        Zee         ed<   dZeed<   dZeed	<   dZeed
<   dZee         ed<   eZeed<   dZee         ed<   dZee         ed<   dZee         ed<   dZee         ed<    edd          d             Z ed          d             Z edd          d             Z  edd          d             Z! G d d          Z"dS )HTTPOptionsa  HTTP options for the proxies. Supported fields:

    - host: Host that the proxies listens for HTTP on. Defaults to
      "127.0.0.1". To expose Serve publicly, you probably want to set
      this to "0.0.0.0".
    - port: Port that the proxies listen for HTTP on. Defaults to 8000.
    - root_path: An optional root path to mount the serve application
      (for example, "/prefix"). All deployment routes are prefixed
      with this path.
    - request_timeout_s: End-to-end timeout for HTTP requests.
    - keep_alive_timeout_s: Duration to keep idle connections alive when no
      requests are ongoing.
    - ssl_keyfile: Path to the SSL key file for HTTPS. If provided with
      ssl_certfile, the HTTP server will use HTTPS.
    - ssl_certfile: Path to the SSL certificate file for HTTPS. If provided
      with ssl_keyfile, the HTTP server will use HTTPS.
    - ssl_keyfile_password: Optional password for the SSL key file.
    - ssl_ca_certs: Optional path to CA certificate file for client certificate
      verification.

    - location: [DEPRECATED: use `proxy_location` field instead] The deployment
      location of HTTP servers:

        - "HeadOnly": start one HTTP server on the head node. Serve
          assumes the head node is the node you executed serve.start
          on. This is the default.
        - "EveryNode": start one HTTP server per node.
        - "NoServer": disable HTTP server.

    - num_cpus: [DEPRECATED] The number of CPU cores to reserve for each
      internal Serve HTTP proxy actor.
    hostportmiddlewareslocationr   num_cpus root_url	root_pathNrequest_timeout_skeep_alive_timeout_sssl_keyfilessl_certfilessl_keyfile_passwordssl_ca_certsTre   c                 2    |d         |t           j        S |S )Nr   )r   r   ro   rp   r   s      rB   location_backfill_no_serverz'HTTPOptions.location_backfill_no_server  s    &>!QY!**rD   c                 P    |                     d          }t          ||           |S )Nr   )r   r#   )ro   rp   r   r   s       rB   validate_ssl_certfilez!HTTPOptions.validate_ssl_certfile  s(    jj//A{+++rD   c                 2    |rt          j        d           |S )NzPassing `middlewares` to HTTPOptions is deprecated and will be removed in a future version. Consider using the FastAPI integration to configure middlewares on your deployments: https://docs.ray.io/en/latest/serve/http-guide.html#fastapi-http-deploymentsr   r   r  s      rB   warn_for_middlewaresz HTTPOptions.warn_for_middlewares  s+     	M_   rD   c                 2    |rt          j        d           |S )NzXPassing `num_cpus` to HTTPOptions is deprecated and will be removed in a future version.r  r  s      rB   warn_for_num_cpuszHTTPOptions.warn_for_num_cpus  s*     	M/   rD   c                       e Zd ZdZdZdS )HTTPOptions.ConfigTN)rO   rP   rQ   validate_assignmentarbitrary_types_allowedrW   rD   rB   Configr    s        ""&rD   r  )#rO   rP   rQ   rR   r   r   r	   rS   r   r   r   rT   r   r   r   r   r   r   r   r   r   r   rU   r!   r   r   r   r   r   r   r  r  r  r	  r  rW   rD   rB   r   r   k  s         B ,D(3-+++!D#!!!Kc)7)@Hh~&@@@HcHcIs)-x--- D#DDD!%K#%%%"&L(3-&&&*.(3-..."&L(3-&&&Yz$'''  (' Y~  
 Y}T***  +* Yz$'''  ('' ' ' ' ' ' ' ' ' 'rD   r   c                   ~    e Zd ZU dZeZeed<   g Ze	e
         ed<   dZee         ed<   ede	e         fd            ZdS )gRPCOptionsa  gRPC options for the proxies. Supported fields:

    Args:
        port (int):
            Port for gRPC server if started. Default to 9000. Cannot be
            updated once Serve has started running. Serve must be shut down and
            restarted with the new port instead.
        grpc_servicer_functions (List[str]):
            List of import paths for gRPC `add_servicer_to_server` functions to add to
            Serve's gRPC proxy. Default to empty list, which means no gRPC methods will
            be added and no gRPC server will be started. The servicer functions need to
            be importable from the context of where Serve is running.
        request_timeout_s: End-to-end timeout for gRPC requests.
    r   grpc_servicer_functionsNr   rE   c                     g }| j         D ]r}	 t          |          }t          |          r|                    |           n| d}t	          |          L# t
          $ r}| d}t          |          |d}~ww xY w|S )zReturn a list of callable functions from the grpc_servicer_functions.

        If the function is not callable or not found, it will be ignored and a warning
        will be logged.
        zQ is not a callable function! Please make sure the function is imported correctly.z can't be imported! Please make sure there are no typo in those functions. Or you might want to rebuild service definitions if .proto file is changed.N)r  r   rG   appendrn   r   )rA   	callablesfuncimported_funcmessagerq   s         rB   grpc_servicer_func_callablez'gRPCOptions.grpc_servicer_func_callable  s     	0 	: 	:D: +D 1 1M** .$$]3333   > > >  %W--- 4 ' : : : = = = 
 *'229: s   AA
A: A55A:)rO   rP   rQ   rR   r   r   rT   r   r  r   rS   r   r	   rU   rV   r   r  rW   rD   rB   r  r    s           "D#!!!)+T#Y+++)-x---T(^    X  rD   r  )=rk   loggingr   enumr   	functoolsr   typingr   r   r   r   r	   r
   rayr   ray._common.pydantic_compatr   r   r   r   r   r   r   r   ray._common.utilsr   r   ray.serve._private.commonr   r   r   ray.serve._private.constantsr   r   r   r   r   r   r   r    r!   r"   ray.serve._private.utilsr#   ray.util.annotationsr$   r%   	getLoggerloggerr)   rY   r   rS   r   r   r   r   r   r   r  rW   rD   rB   <module>r&     s            % % % % % % = = = = = = = = = = = = = = = =      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 B A A A A A A A J I I I I I I I I I                        9 8 8 8 8 8 6 6 6 6 6 6 6 6		,	-	- WzD zD zD zD zD zD zD zDz W` ` ` ` `) ` ` `F "  W    #t    WD D D D D	 D D DN XH, H, H, H, H,	 H, H, H,X     S$    X68 68 68 68 68C 68 68 68r XS' S' S' S' S') S' S' S'l W/ / / / /) / / / / /rD   