コード例 #1
0
ファイル: client_connect.py プロジェクト: yiranwang52/ray
def connect(conn_str: str,
            secure: bool = False,
            metadata: List[Tuple[str, str]] = None,
            connection_retries: int = 3,
            job_config: JobConfig = None,
            namespace: str = None,
            *,
            ignore_version: bool = False) -> Dict[str, Any]:
    if ray.is_connected():
        raise RuntimeError("Ray Client is already connected. "
                           "Maybe you called ray.util.connect twice by "
                           "accident?")
    # Enable the same hooks that RAY_CLIENT_MODE does, as
    # calling ray.util.connect() is specifically for using client mode.
    _set_client_hook_status(True)
    _explicitly_enable_client_mode()

    # TODO(barakmich): https://github.com/ray-project/ray/issues/13274
    # for supporting things like cert_path, ca_path, etc and creating
    # the correct metadata
    return ray.connect(conn_str,
                       job_config=job_config,
                       secure=secure,
                       metadata=metadata,
                       connection_retries=connection_retries,
                       namespace=namespace,
                       ignore_version=ignore_version)
コード例 #2
0
 def __dir__(self) -> List[str]:
     if self._method_num_returns is not None:
         return self._method_num_returns.keys()
     if ray.is_connected():
         self._init_class_info()
         return self._method_num_returns.keys()
     return super().__dir__()
コード例 #3
0
ファイル: client_connect.py プロジェクト: parasj/ray
def connect(
        conn_str: str,
        secure: bool = False,
        metadata: List[Tuple[str, str]] = None,
        connection_retries: int = 3,
        job_config: JobConfig = None,
        namespace: str = None,
        *,
        ignore_version: bool = False,
        _credentials: Optional[grpc.ChannelCredentials] = None,
        ray_init_kwargs: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
    if ray.is_connected():
        raise RuntimeError("Ray Client is already connected. Maybe you called "
                           'ray.init("ray://<address>") twice by accident?')

    # Enable the same hooks that RAY_CLIENT_MODE does, as calling
    # ray.init("ray://<address>") is specifically for using client mode.
    _set_client_hook_status(True)
    _explicitly_enable_client_mode()

    # TODO(barakmich): https://github.com/ray-project/ray/issues/13274
    # for supporting things like cert_path, ca_path, etc and creating
    # the correct metadata
    conn = ray.connect(
        conn_str,
        job_config=job_config,
        secure=secure,
        metadata=metadata,
        connection_retries=connection_retries,
        namespace=namespace,
        ignore_version=ignore_version,
        _credentials=_credentials,
        ray_init_kwargs=ray_init_kwargs,
    )
    return conn
コード例 #4
0
ファイル: common.py プロジェクト: haochihlin/ray
 def __del__(self) -> None:
     if ray is None:
         # The ray API stub might be set to None when the script exits.
         # Should be safe to skip call_release in this case, since the
         # client should have already disconnected at this point.
         return
     if ray.is_connected():
         ray.call_release(self.actor_ref.id)
コード例 #5
0
    def __dir__(self) -> List[str]:
        if self._dir is not None:
            return self._dir
        if ray.is_connected():

            @ray.remote(num_cpus=0)
            def get_dir(x):
                return dir(x)

            self._dir = ray.get(get_dir.remote(self))
            return self._dir
        return super().__dir__()
コード例 #6
0
ファイル: client_connect.py プロジェクト: Rid039/ray
def connect(conn_str: str,
            secure: bool = False,
            metadata: List[Tuple[str, str]] = None) -> None:
    if ray.is_connected():
        raise RuntimeError("Ray Client is already connected. "
                           "Maybe you called ray.util.connect twice by "
                           "accident?")
    # Enable the same hooks that RAY_CLIENT_MODE does, as
    # calling ray.util.connect() is specifically for using client mode.
    _enable_client_hook(True)
    _explicitly_enable_client_mode()

    # TODO(barakmich): https://github.com/ray-project/ray/issues/13274
    # for supporting things like cert_path, ca_path, etc and creating
    # the correct metadata
    return ray.connect(conn_str, secure=secure, metadata=metadata)
コード例 #7
0
def disconnect():
    if not ray.is_connected():
        raise RuntimeError("Ray Client is currently disconnected.")
    return ray.disconnect()
コード例 #8
0
 def __del__(self) -> None:
     if ray.is_connected():
         ray.call_release(self.actor_ref.id)
コード例 #9
0
ファイル: common.py プロジェクト: supatomic/ray
 def __del__(self):
     if ray.is_connected() and self.id is not None:
         ray.call_release(self.id)