import time import numpy as np import pytest import ray.cluster_utils from ray._private.test_utils import (client_test_enabled, get_error_message, SignalActor, run_string_as_driver) import ray logger = logging.getLogger(__name__) # https://github.com/ray-project/ray/issues/6662 @pytest.mark.skipif(client_test_enabled(), reason="interferes with grpc") def test_ignore_http_proxy(shutdown_only): ray.init(num_cpus=1) os.environ["http_proxy"] = "http://example.com" os.environ["https_proxy"] = "http://example.com" @ray.remote def f(): return 1 assert ray.get(f.remote()) == 1 # https://github.com/ray-project/ray/issues/16025 def test_release_resources_race(shutdown_only): # This test fails with the flag set to false.
# coding: utf-8 import logging import sys import time import numpy as np import pytest import ray.cluster_utils from ray._private.test_utils import ( client_test_enabled, SignalActor, ) if client_test_enabled(): from ray.util.client import ray else: import ray logger = logging.getLogger(__name__) def test_task_arguments_inline_bytes_limit(ray_start_cluster_enabled): cluster = ray_start_cluster_enabled cluster.add_node( num_cpus=1, resources={"pin_head": 1}, _system_config={ "max_direct_call_object_size": 100 * 1024, # if task_rpc_inlined_bytes_limit is greater than
if process.name() in ("gcs_server", "redis-server") ]) return m def function_entry_num(job_id): from ray.ray_constants import KV_NAMESPACE_FUNCTION_TABLE return len(_internal_kv_list(b"IsolatedExports:" + job_id, namespace=KV_NAMESPACE_FUNCTION_TABLE)) + \ len(_internal_kv_list(b"RemoteFunction:" + job_id, namespace=KV_NAMESPACE_FUNCTION_TABLE)) + \ len(_internal_kv_list(b"ActorClass:" + job_id, namespace=KV_NAMESPACE_FUNCTION_TABLE)) @pytest.mark.skipif(client_test_enabled(), reason="client api doesn't support namespace right now.") def test_function_table_gc(call_ray_start): """This test tries to verify that function table is cleaned up after job exits. """ def f(): data = "0" * 1024 * 1024 # 1MB @ray.remote def r(): nonlocal data @ray.remote class Actor: pass
import time import tempfile import subprocess import numpy as np import pytest from unittest.mock import MagicMock, patch import ray.cluster_utils from ray._private.test_utils import client_test_enabled from ray.tests.client_test_utils import create_remote_signal_actor from ray.exceptions import GetTimeoutError from ray.exceptions import RayTaskError if client_test_enabled(): from ray.util.client import ray else: import ray logger = logging.getLogger(__name__) @pytest.mark.parametrize("shutdown_only", [{ "local_mode": True }, { "local_mode": False }], indirect=True) def test_variable_number_of_args(shutdown_only): ray.init(num_cpus=1)
import threading import time import os import numpy as np import pytest import ray.cluster_utils import ray._private.profiling as profiling from ray._private.gcs_utils import use_gcs_for_bootstrap from ray._private.test_utils import (client_test_enabled, RayTestTimeoutException, SignalActor) from ray.exceptions import ReferenceCountingAssertionError if client_test_enabled(): from ray.util.client import ray else: import ray logger = logging.getLogger(__name__) # issue https://github.com/ray-project/ray/issues/7105 @pytest.mark.skipif(client_test_enabled(), reason="internal api") def test_internal_free(shutdown_only): ray.init(num_cpus=1) @ray.remote class Sampler: def sample(self):
import threading import time import os import numpy as np import pytest import ray.cluster_utils import ray._private.profiling as profiling from ray._private.gcs_utils import use_gcs_for_bootstrap from ray._private.test_utils import (client_test_enabled, RayTestTimeoutException, SignalActor) from ray.exceptions import ReferenceCountingAssertionError if client_test_enabled(): from ray.util.client import ray else: import ray logger = logging.getLogger(__name__) # issue https://github.com/ray-project/ray/issues/7105 @pytest.mark.skipif(client_test_enabled(), reason="internal api") def test_internal_free(shutdown_only): ray.init(num_cpus=1) @ray.remote class Sampler: def sample(self):
@ray.remote class Actor: def __init__(self): # This should use the last version of f. self.x = ray.get(f.remote()) def get_val(self): return self.x actor = Actor.remote() return ray.get(actor.get_val.remote()) assert ray.get(g.remote()) == num_remote_functions - 1 @pytest.mark.skipif(client_test_enabled(), reason="internal api") def test_actor_method_metadata_cache(ray_start_regular): class Actor(object): pass # The cache of ActorClassMethodMetadata. cache = ray.actor.ActorClassMethodMetadata._cache cache.clear() # Check cache hit during ActorHandle deserialization. A1 = ray.remote(Actor) a = A1.remote() assert len(cache) == 1 cached_data_id = [id(x) for x in list(cache.items())[0]] for x in range(10): a = pickle.loads(pickle.dumps(a))
import time import tempfile import subprocess import numpy as np import pytest from unittest.mock import MagicMock, patch import ray.cluster_utils from ray._private.test_utils import client_test_enabled from ray.tests.client_test_utils import create_remote_signal_actor from ray.exceptions import GetTimeoutError from ray.exceptions import RayTaskError if client_test_enabled(): from ray.util.client import ray else: import ray logger = logging.getLogger(__name__) @pytest.mark.parametrize( "shutdown_only", [{ "local_mode": True }, { "local_mode": False }], indirect=True) def test_variable_number_of_args(shutdown_only):
@ray.remote class Actor: def __init__(self): # This should use the last version of f. self.x = ray.get(f.remote()) def get_val(self): return self.x actor = Actor.remote() return ray.get(actor.get_val.remote()) assert ray.get(g.remote()) == num_remote_functions - 1 @pytest.mark.skipif(client_test_enabled(), reason="internal api") def test_actor_method_metadata_cache(ray_start_regular): class Actor(object): pass # The cache of ActorClassMethodMetadata. cache = ray.actor.ActorClassMethodMetadata._cache cache.clear() # Check cache hit during ActorHandle deserialization. A1 = ray.remote(Actor) a = A1.remote() assert len(cache) == 1 cached_data_id = [id(x) for x in list(cache.items())[0]] for x in range(10): a = pickle.loads(pickle.dumps(a))
) + len( _internal_kv_list( b"ActorClass:" + job_id, namespace=KV_NAMESPACE_FUNCTION_TABLE ) ) + len( _internal_kv_list( b"FunctionsToRun:" + job_id, namespace=KV_NAMESPACE_FUNCTION_TABLE ) ) ) @pytest.mark.skipif( client_test_enabled(), reason="client api doesn't support namespace right now." ) def test_function_table_gc(call_ray_start): """This test tries to verify that function table is cleaned up after job exits. """ def f(): data = "0" * 1024 * 1024 # 1MB @ray.remote def r(): nonlocal data @ray.remote class Actor:
import os import numpy as np import pytest import ray.cluster_utils import ray._private.profiling as profiling from ray._private.test_utils import ( client_test_enabled, RayTestTimeoutException, SignalActor, ) from ray.exceptions import ReferenceCountingAssertionError if client_test_enabled(): from ray.util.client import ray else: import ray logger = logging.getLogger(__name__) # issue https://github.com/ray-project/ray/issues/7105 @pytest.mark.skipif(client_test_enabled(), reason="internal api") def test_internal_free(shutdown_only): ray.init(num_cpus=1) @ray.remote class Sampler: def sample(self):