
    %`i&                         d dl 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 d dlmZ erd dlmZ e G d d                      ZdS )    N)TYPE_CHECKINGAnyDictListOptionalUnion)LoggingConfig)	PublicAPI
RuntimeEnvc                      e Zd ZdZ	 	 	 	 	 	 	 	 d deee                  deee                  dee         ded	ee         d
ee         dedeee                  fdZ	dededdfdZ
defdZ	 d!deeeeef         df                  deddfdZ	 d"dee         fdZd
eddfdZdeddfdZd Zd Zd ZdefdZdefdZed             ZdS )#	JobConfiga  A class used to store the configurations of a job.

    Examples:
        .. testcode::
            :hide:

            import ray
            ray.shutdown()

        .. testcode::

            import ray
            from ray.job_config import JobConfig

            ray.init(job_config=JobConfig(default_actor_lifetime="non_detached"))

    Args:
        jvm_options: The jvm options for java workers of the job.
        code_search_path: A list of directories or jar files that
            specify the search path for user code. This will be used as
            `CLASSPATH` in Java and `PYTHONPATH` in Python.
            See :ref:`Ray cross-language programming <cross_language>` for more details.
        runtime_env: A :ref:`runtime environment <runtime-environments>` dictionary.
        metadata: An opaque metadata dictionary.
        ray_namespace: A :ref:`namespace <namespaces-guide>`
            is a logical grouping of jobs and named actors.
        default_actor_lifetime: The default value of actor lifetime,
            can be "detached" or "non_detached".
            See :ref:`actor lifetimes <actor-lifetimes>` for more details.
    NFnon_detachedjvm_optionscode_search_pathruntime_env_client_jobmetadataray_namespacedefault_actor_lifetime_py_driver_sys_pathc	                 B   |pg | _         |pg | _        t          | j        t          t          f          sJ dt          |                       || _        |pi | _        || _        | 	                    |           | 
                    |           |pg | _        d | _        d S )Nz+The type of code search path is incorrect: )r   r   
isinstancelisttupletyper   r   r   set_runtime_envset_default_actor_lifetimer   py_logging_config)	selfr   r   r   r   r   r   r   r   s	            b/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/job_config.py__init__zJobConfig.__init__-   s     '," !1 6B $/$?? 	
 	
VdCS>T>TVV	
 	
? ' B*[)))''(>???#6#<" !%    keyvaluereturnc                     || j         |<   dS )a  Add key-value pair to the metadata dictionary.

        If the key already exists, the value is overwritten to the new value.

        Examples:
            .. testcode::

                import ray
                from ray.job_config import JobConfig

                job_config = JobConfig()
                job_config.set_metadata("submitter", "foo")

        Args:
            key: The key of the metadata.
            value: The value of the metadata.
        N)r   )r    r$   r%   s      r!   set_metadatazJobConfig.set_metadataN   s    $ #cr#   c                 N    |                                                                  S )z)Serialize the struct into protobuf string)_get_proto_job_configSerializeToStringr    s    r!   
_serializezJobConfig._serializeb   s     ))++==???r#   r   validatec                 `    ||ni | _         |r|                                 | _         d| _        dS )a  Modify the runtime_env of the JobConfig.

        We don't validate the runtime_env by default here because it may go
        through some translation before actually being passed to C++ (e.g.,
        working_dir translated from a local directory to a URI).

        Args:
            runtime_env: A :ref:`runtime environment <runtime-environments>` dictionary.
            validate: Whether to validate the runtime env.
        N)r   _validate_runtime_env
_cached_pb)r    r   r.   s      r!   r   zJobConfig.set_runtime_envf   s<     +6*A;;r 	<#99;;Dr#   logging_configc                     || _         dS )a  Set the logging configuration for the job.

        The logging configuration will be applied to the root loggers of
        all Ray task and actor processes that belong to this job.

        Args:
            logging_config: The logging configuration to set.
        N)r   )r    r2   s     r!   set_py_logging_configzJobConfig.set_py_logging_configz   s     "0r#   c                 <    || j         k    r|| _         d| _        dS dS )zuSet Ray :ref:`namespace <namespaces-guide>`.

        Args:
            ray_namespace: The namespace to set.
        N)r   r1   )r    r   s     r!   set_ray_namespacezJobConfig.set_ray_namespace   s-     D...!.D"DOOO /.r#   c                     ddl mc mc m} |dk    r|j        j        j        | _        dS |dk    r|j        j        j        | _        dS t          d          )zSet the default actor lifetime, which can be "detached" or "non_detached".

        See :ref:`actor lifetimes <actor-lifetimes>` for more details.

        Args:
            default_actor_lifetime: The default actor lifetime to set.
        r   Ndetachedr   z@Default actor lifetime must be one of `detached`, `non_detached`)
ray.core.generated.common_pb2core	generated
common_pb2r   ActorLifetimeDETACHED_default_actor_lifetimeNON_DETACHED
ValueError)r    r   r<   s      r!   r   z$JobConfig.set_default_actor_lifetime   s     	;:::::::::::!Z//+5+?+M+VD(((#~55$2? ((( R  r#   c                 |    ddl m} ddlm} | j        }t          ||          s |di | j        } ||           |S )Nr   r   )_validate_no_local_paths )ray.runtime_envr   ray.runtime_env.runtime_envrC   r   r   )r    r   rC   r   s       r!   r0   zJobConfig._validate_runtime_env   sq     	/.....HHHHHH&+z22 	9$*88t'788K  ---r#   c                    ddl mc mc m} ddlm} | j        L|                                }| j        &t          t          j                              |_        n| j        |_        |j                            | j                   |j                            | j                   |j                            | j                   | j                                        D ]\  }}||j        |<   |                                 }|j                             ||dd                     | j        | j        |_        | j        rt3          j        | j                  |_        || _        | j        S )z+Return the protobuf structure of JobConfig.r   N)get_runtime_env_infoTF)is_job_runtime_env	serialize)r9   r:   r;   r<   ray._private.utilsrH   r1   r   r   struuiduuid4r   extendr   py_driver_sys_pathr   r   itemsr0   runtime_env_infoCopyFromr?   r   r   pickledumpsserialized_py_logging_config)r    r<   rH   pbkv
parsed_envs          r!   r*   zJobConfig._get_proto_job_config   s   
 	;:::::::::::;;;;;;?"%%''B!)#&tz||#4#4  #'#5 N!!$"2333&&t'<===!(()ABBB++-- # #1!"A3355J(($$'+#     +7,0,H)% W28,t?U2V2V/ DOr#   c                 N    |                                                                  S N)r0   has_working_dirr,   s    r!   _runtime_env_has_working_dirz&JobConfig._runtime_env_has_working_dir   s     ))++;;===r#   c                 N    |                                                                  S )z2Return the JSON-serialized parsed runtime env dict)r0   rJ   r,   s    r!   _get_serialized_runtime_envz%JobConfig._get_serialized_runtime_env   s     ))++55777r#   c                 >    |                                  j        j        S )z2Return the JSON-serialized parsed runtime env info)r*   rR   runtime_env_configr,   s    r!   _get_proto_runtime_env_configz'JobConfig._get_proto_runtime_env_config   s    ))++<OOr#   c                 >    | |                     dd          |                     dd          |                     dd          |                     dd          |                     dd          |                     dd          |                     d	d          
          S )aU  Generates a JobConfig object from json.

        Examples:
            .. testcode::

                from ray.job_config import JobConfig

                job_config = JobConfig.from_json(
                    {"runtime_env": {"working_dir": "uri://abc"}})

        Args:
            job_config_json: The job config json dictionary.
        r   Nr   r   r   r   
client_jobFrP   )r   r   r   r   r   r   r   )get)clsjob_config_jsons     r!   	from_jsonzJobConfig.from_json   s     s'++M4@@,001CTJJ'++M4@@$((T::)--otDD'++L%@@ / 3 34H$ O O
 
 
 	
r#   )NNNFNNr   N)Fr\   )__name__
__module____qualname____doc__r   r   rL   dictboolr"   r(   r-   r   r   r   r   r	   r4   r6   r   r0   r*   r^   r`   rc   classmethodri   rD   r#   r!   r   r      sU        B ,004&*!#''+&437& &d3i(& #49-& d^	&
 & 4.&  }& !$& &d3i0& & & &B# #C #D # # # #(@C @ @ @ @  eDcNL$@AB  
	   , 370 0 /0 0 0 0	#s 	#t 	# 	# 	# 	#     *  # # #J> > >8S 8 8 8 8Ps P P P P 
 
 [
 
 
r#   r   )rM   typingr   r   r   r   r   r   ray.cloudpicklecloudpicklerT   'ray._private.ray_logging.logging_configr	   ray.util.annotationsr
   rE   r   r   rD   r#   r!   <module>rv      s     B B B B B B B B B B B B B B B B             A A A A A A * * * * * * +****** p
 p
 p
 p
 p
 p
 p
 p
 p
 p
r#   