mirror of
https://github.com/wassname/ray.git
synced 2026-07-14 11:17:54 +08:00
[tune] Cancel Experiment via Client (#7719)
* init cancel * testing * Update python/ray/tune/tests/test_tune_server.py Co-Authored-By: Richard Liaw <rliaw@berkeley.edu> * Apply suggestions from code review * Apply suggestions from code review * finished * set_finished Co-authored-by: ijrsvt <ian.rodney@gmail.com>
This commit is contained in:
@@ -250,7 +250,7 @@ class TrialRunnerTest3(unittest.TestCase):
|
||||
break
|
||||
|
||||
if self._index > 4:
|
||||
self._finished = True
|
||||
self.set_finished()
|
||||
return trials
|
||||
|
||||
def suggest(self, trial_id):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import unittest
|
||||
import requests
|
||||
import socket
|
||||
import subprocess
|
||||
import unittest
|
||||
import json
|
||||
|
||||
import ray
|
||||
@@ -119,6 +120,22 @@ class TuneServerSuite(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
len([t for t in all_trials if t["status"] == Trial.RUNNING]), 0)
|
||||
|
||||
def testStopExperiment(self):
|
||||
"""Check if stop_experiment works."""
|
||||
runner, client = self.basicSetup()
|
||||
for i in range(2):
|
||||
runner.step()
|
||||
all_trials = client.get_all_trials()["trials"]
|
||||
self.assertEqual(
|
||||
len([t for t in all_trials if t["status"] == Trial.RUNNING]), 1)
|
||||
|
||||
client.stop_experiment()
|
||||
runner.step()
|
||||
self.assertTrue(runner.is_finished())
|
||||
self.assertRaises(
|
||||
requests.exceptions.ReadTimeout,
|
||||
lambda: client.get_all_trials(timeout=1))
|
||||
|
||||
def testCurlCommand(self):
|
||||
"""Check if Stop Trial works."""
|
||||
runner, client = self.basicSetup()
|
||||
|
||||
Reference in New Issue
Block a user