lazy_utils.py 555 Bytes
Newer Older
1
2
3
4
5
6
7
8
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project


def is_ray_initialized():
    """Check if Ray is initialized."""
    try:
        import ray
9

10
11
12
13
14
15
16
17
18
19
        return ray.is_initialized()
    except ImportError:
        return False


def is_in_ray_actor():
    """Check if we are in a Ray actor."""

    try:
        import ray
20
21
22
23
24

        return (
            ray.is_initialized()
            and ray.get_runtime_context().get_actor_id() is not None
        )
25
26
    except ImportError:
        return False