mirror of
https://github.com/wassname/ray.git
synced 2026-07-06 01:07:38 +08:00
[rllib] Deprecate policy optimizers (#8345)
This commit is contained in:
@@ -29,18 +29,10 @@ def test_metrics(ray_start_regular_shared):
|
||||
it = it.gather_sync().for_each(f)
|
||||
it2 = it2.gather_sync().for_each(f)
|
||||
|
||||
# Context cannot be accessed outside the iterator.
|
||||
with pytest.raises(ValueError):
|
||||
LocalIterator.get_metrics()
|
||||
|
||||
# Tests iterators have isolated contexts.
|
||||
assert it.take(4) == [1, 3, 6, 10]
|
||||
assert it2.take(4) == [1, 3, 6, 10]
|
||||
|
||||
# Context cannot be accessed outside the iterator.
|
||||
with pytest.raises(ValueError):
|
||||
LocalIterator.get_metrics()
|
||||
|
||||
|
||||
def test_zip_with_source_actor(ray_start_regular_shared):
|
||||
it = from_items([1, 2, 3, 4], num_shards=2)
|
||||
|
||||
@@ -670,15 +670,8 @@ class LocalIterator(Generic[T]):
|
||||
|
||||
@contextmanager
|
||||
def _metrics_context(self):
|
||||
if hasattr(self.thread_local, "metrics"):
|
||||
prev_metrics = self.thread_local.metrics
|
||||
else:
|
||||
prev_metrics = None
|
||||
try:
|
||||
self.thread_local.metrics = self.shared_metrics.get()
|
||||
yield
|
||||
finally:
|
||||
self.thread_local.metrics = prev_metrics
|
||||
self.thread_local.metrics = self.shared_metrics.get()
|
||||
yield
|
||||
|
||||
def __iter__(self):
|
||||
self._build_once()
|
||||
|
||||
Reference in New Issue
Block a user