Python ray.shutdown() Examples
The following are 30
code examples of ray.shutdown().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ray
, or try the search function
.
Example #1
Source File: ray_fixtures.py From garage with MIT License | 7 votes |
def ray_local_session_fixture(): """Initializes Ray and shuts down Ray in local mode. Yields: None: Yield is for purposes of pytest module style. All statements before the yield are apart of module setup, and all statements after the yield are apart of module teardown. """ if not ray.is_initialized(): ray.init(local_mode=True, ignore_reinit_error=True, log_to_driver=False, include_webui=False) yield if ray.is_initialized(): ray.shutdown()
Example #2
Source File: test_api.py From ray with Apache License 2.0 | 6 votes |
def testLotsOfStops(self): class TestTrainable(Trainable): def step(self): result = {"name": self.trial_name, "trial_id": self.trial_id} return result def cleanup(self): time.sleep(2) open(os.path.join(self.logdir, "marker"), "a").close() return 1 analysis = tune.run( TestTrainable, num_samples=10, stop={TRAINING_ITERATION: 1}) ray.shutdown() for trial in analysis.trials: path = os.path.join(trial.logdir, "marker") assert os.path.exists(path)
Example #3
Source File: test_cluster.py From ray with Apache License 2.0 | 6 votes |
def start_connected_emptyhead_cluster(): """Starts head with no resources.""" cluster = Cluster( initialize_head=True, connect=True, head_node_args={ "num_cpus": 0, "_internal_config": json.dumps({ "num_heartbeats_timeout": 10 }) }) # Pytest doesn't play nicely with imports _register_all() register_trainable("__fake_remote", MockRemoteTrainer) register_trainable("__fake_durable", MockDurableTrainer) yield cluster # The code after the yield will run as teardown code. ray.shutdown() cluster.shutdown()
Example #4
Source File: ray_fixtures.py From garage with MIT License | 6 votes |
def ray_session_fixture(): """Initializes Ray and shuts down Ray. Yields: None: Yield is for purposes of pytest module style. All statements before the yield are apart of module setup, and all statements after the yield are apart of module teardown. """ if not ray.is_initialized(): ray.init(memory=52428800, object_store_memory=78643200, ignore_reinit_error=True, log_to_driver=False, include_webui=False) yield if ray.is_initialized(): ray.shutdown()
Example #5
Source File: test_run_experiment.py From ray with Apache License 2.0 | 6 votes |
def testCustomResources(self): ray.shutdown() ray.init(resources={"hi": 3}) class train(Trainable): def step(self): return {"timesteps_this_iter": 1, "done": True} trials = run_experiments({ "foo": { "run": train, "resources_per_trial": { "cpu": 1, "custom_resources": { "hi": 2 } } } }) for trial in trials: self.assertEqual(trial.status, Trial.TERMINATED)
Example #6
Source File: test_ars.py From ray with Apache License 2.0 | 6 votes |
def test_ars_compilation(self): """Test whether an ARSTrainer can be built on all frameworks.""" ray.init(num_cpus=2, local_mode=True) config = ars.DEFAULT_CONFIG.copy() # Keep it simple. config["model"]["fcnet_hiddens"] = [10] config["model"]["fcnet_activation"] = None num_iterations = 2 for _ in framework_iterator(config): plain_config = config.copy() trainer = ars.ARSTrainer(config=plain_config, env="CartPole-v0") for i in range(num_iterations): results = trainer.train() print(results) check_compute_single_action(trainer) trainer.stop() ray.shutdown()
Example #7
Source File: ray_wrapper.py From RLs with Apache License 2.0 | 6 votes |
def op_func(envs, op: OP, _args=None): if op == OP.RESET: return ray.get([env.reset.remote() for env in envs]) if op == OP.STEP: return ray.get([env.step.remote(action) for env, action in zip(envs, _args)]) if op == OP.SAMPLE: return ray.get([env.sample.remote() for env in envs]) if op == OP.RENDER: if _args: # record [env.render.remote(filename=r'videos/{0}-{1}.mp4'.format(env.env.spec.id, i)) for i, env in enumerate(envs)] else: [env.render.remote() for env in envs] return None if op == OP.CLOSE: ray.get([env.close.remote() for env in envs]) ray.shutdown() return None
Example #8
Source File: test_local.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self) -> None: ray.shutdown()
Example #9
Source File: test_apex_dqn.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): ray.shutdown()
Example #10
Source File: test_evaluators.py From ray with Apache License 2.0 | 5 votes |
def test_evaluation_option(self): def env_creator(env_config): return gym.make("CartPole-v0") agent_classes = [A3CTrainer, DQNTrainer] for agent_cls in agent_classes: for fw in framework_iterator(frameworks=("torch", "tf")): ray.init(object_store_memory=1000 * 1024 * 1024) register_env("CartPoleWrapped-v0", env_creator) agent = agent_cls( env="CartPoleWrapped-v0", config={ "evaluation_interval": 2, "evaluation_num_episodes": 2, "evaluation_config": { "gamma": 0.98, "env_config": { "fake_arg": True } }, "framework": fw, }) # Given evaluation_interval=2, r0, r2, r4 should not contain # evaluation metrics while r1, r3 should do. r0 = agent.train() r1 = agent.train() r2 = agent.train() r3 = agent.train() self.assertTrue("evaluation" in r1) self.assertTrue("evaluation" in r3) self.assertFalse("evaluation" in r0) self.assertFalse("evaluation" in r2) self.assertTrue("episode_reward_mean" in r1["evaluation"]) self.assertNotEqual(r1["evaluation"], r3["evaluation"]) ray.shutdown()
Example #11
Source File: test_export.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls) -> None: ray.shutdown()
Example #12
Source File: test_filters.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): ray.shutdown()
Example #13
Source File: test_multi_agent_env.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self) -> None: ray.shutdown()
Example #14
Source File: test_exec_api.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls): ray.shutdown()
Example #15
Source File: test_a2c.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): ray.shutdown()
Example #16
Source File: test_pg.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): ray.shutdown()
Example #17
Source File: test_a3c.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): ray.shutdown()
Example #18
Source File: test_impala.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls) -> None: ray.shutdown()
Example #19
Source File: test_rollout_worker.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls): ray.shutdown()
Example #20
Source File: test_checkpoint_restore.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls): ray.shutdown()
Example #21
Source File: test_eager_support.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): ray.shutdown()
Example #22
Source File: test_lstm.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self) -> None: ray.shutdown()
Example #23
Source File: test_catalog.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): ray.shutdown()
Example #24
Source File: test_nested_observation_spaces.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls): ray.shutdown()
Example #25
Source File: test_external_multi_agent_env.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls) -> None: ray.shutdown()
Example #26
Source File: test_supported_multi_agent.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls) -> None: ray.shutdown()
Example #27
Source File: test_supported_multi_agent.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls) -> None: ray.shutdown()
Example #28
Source File: test_io.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): shutil.rmtree(self.test_dir) ray.shutdown()
Example #29
Source File: test_explorations.py From ray with Apache License 2.0 | 5 votes |
def tearDownClass(cls): ray.shutdown()
Example #30
Source File: test_experiment_analysis.py From ray with Apache License 2.0 | 5 votes |
def tearDown(self): shutil.rmtree(self.test_dir, ignore_errors=True) ray.shutdown()