<commit_before>from inspect import getmembers, isfunction, ismodule

import ray


# NOTE: Before adding a new API to Ray (and modifying this test), the new API
# must have Ray Client support.
def test_api_functions():
    # These are pulled from the "Python API" of the Ray Docs
    # util.queue.Queue & util.ActorPool are removed because they are under
    # util.*, not the top-level Ray namespace.
    PYTHON_API = [
        "init",
        "is_initialized",
        "remote",
        "get",
        "wait",
        "put",
        "kill",
        "cancel",
        "get_gpu_ids",
        "shutdown",
        "method",
        "nodes",
        "timeline",
        "cluster_resources",
        "available_resources",
        "java_function",
        "java_actor_class",
    ]

    OTHER_ALLOWED_FUNCTIONS = [
        # TODO(ilr) either move this to PYTHON_API or remove.
        "get_actor",
        # In the RuntimeContext API
        "get_runtime_context",
    ]

    functions = getmembers(ray, isfunction)
    function_names = [f[0] for f in functions]
    assert set(function_names) == set(PYTHON_API + OTHER_ALLOWED_FUNCTIONS)


def test_non_ray_modules():
    modules = getmembers(ray, ismodule)<commit_msg>[test] Clean-Up Test-Top-Level API (#15713)<commit_after>from inspect import getmembers, isfunction, ismodule

import ray


# NOTE: Before adding a new API to Ray (and modifying this test), the new API
# must have Ray Client support.
def test_api_functions():
    # These are pulled from the "Python API" of the Ray Docs
    # util.queue.Queue & util.ActorPool are removed because they are under
    # util.*, not the top-level Ray namespace.
    PYTHON_API = [
        "init",
        "is_initialized",
        "remote",
        "get",
        "wait",
        "put",
        "kill",
        "cancel",
        "get_actor",
        "get_gpu_ids",
        "shutdown",
        "method",
        "nodes",
        "timeline",
        "cluster_resources",
        "available_resources",
        "java_function",
        "java_actor_class",
    ]

    OTHER_ALLOWED_FUNCTIONS = [
        # In the RuntimeContext API
        "get_runtime_context",
    ]

    functions = getmembers(ray, isfunction)
    function_names = [f[0] for f in functions]
    assert set(function_names) == set(PYTHON_API + OTHER_ALLOWED_FUNCTIONS)


def test_non_ray_modules():
    modules = getmembers(ray, ismodule)
{'fraction_non_alphanumeric': 0.10175145954962468, 'fraction_numerical': 0.0029190992493744786, 'mean_word_length': 2.4667630057803467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6068340', 'n_tokens_mistral': 739, 'n_tokens_neox': 717, 'n_words': 207}