From 602dea68242fc54498f059fb8797854e3c1ff586 Mon Sep 17 00:00:00 2001 From: Gabriel Barth-Maron Date: Wed, 20 May 2020 08:33:13 -0700 Subject: [PATCH] [1/3] Reverb: Rename distributions package to item_selectors. This rename reflects the fact that not all of the "distributions" were stochastic. PiperOrigin-RevId: 312486733 Change-Id: Iaac336a8eee1ea9bbbf3ad7ee7a88290ebc46471 --- reverb/BUILD | 23 ++++++++++++++++------- reverb/__init__.py | 1 + reverb/distributions.py | 16 +++++++--------- reverb/item_selectors.py | 26 ++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 reverb/item_selectors.py diff --git a/reverb/BUILD b/reverb/BUILD index d015e47..0f4eee4 100644 --- a/reverb/BUILD +++ b/reverb/BUILD @@ -25,6 +25,7 @@ reverb_pytype_strict_library( ":distributions", ":ensure_tf_install", ":errors", + ":item_selectors", ":rate_limiters", ":replay_sample", ":server", @@ -36,7 +37,7 @@ reverb_pytype_strict_library( name = "distributions", srcs = ["distributions.py"], srcs_version = "PY3", - deps = [":pybind"], + deps = [":item_selectors"], ) reverb_pytype_strict_library( @@ -147,6 +148,20 @@ reverb_pytype_library( ], ) +reverb_pytype_strict_library( + name = "ensure_tf_install", + srcs = ["platform/default/ensure_tf_install.py"], + srcs_version = "PY3", +) + +reverb_pytype_strict_library( + name = "item_selectors", + srcs = ["item_selectors.py"], + srcs_version = "PY3", + visibility = ["//visibility:private"], + deps = [":pybind"], +) + reverb_py_test( name = "checkpointer_test", srcs = ["checkpointer_test.py"], @@ -215,9 +230,3 @@ reverb_py_test( ":reverb", ], ) - -reverb_pytype_strict_library( - name = "ensure_tf_install", - srcs = ["platform/default/ensure_tf_install.py"], - srcs_version = "PY3", -) diff --git a/reverb/__init__.py b/reverb/__init__.py index b41100b..27fd0e7 100644 --- a/reverb/__init__.py +++ b/reverb/__init__.py @@ -25,6 +25,7 @@ # pylint: enable=g-bad-import-order from reverb import distributions +from reverb import item_selectors as selectors from reverb import rate_limiters from reverb.client import Client diff --git a/reverb/distributions.py b/reverb/distributions.py index ce9e293..2e1e301 100644 --- a/reverb/distributions.py +++ b/reverb/distributions.py @@ -14,13 +14,11 @@ """Sampling and removing distributions.""" -import functools +from reverb import item_selectors -from reverb import pybind - -Fifo = pybind.FifoDistribution -Lifo = pybind.LifoDistribution -MaxHeap = functools.partial(pybind.HeapDistribution, False) # pylint: disable=invalid-name -MinHeap = functools.partial(pybind.HeapDistribution, True) # pylint: disable=invalid-name -Prioritized = pybind.PrioritizedDistribution -Uniform = pybind.UniformDistribution +Fifo = item_selectors.Fifo +Lifo = item_selectors.Lifo +MaxHeap = item_selectors.MaxHeap +MinHeap = item_selectors.MinHeap +Prioritized = item_selectors.Prioritized +Uniform = item_selectors.Uniform diff --git a/reverb/item_selectors.py b/reverb/item_selectors.py new file mode 100644 index 0000000..ce9e293 --- /dev/null +++ b/reverb/item_selectors.py @@ -0,0 +1,26 @@ +# Copyright 2019 DeepMind Technologies Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Sampling and removing distributions.""" + +import functools + +from reverb import pybind + +Fifo = pybind.FifoDistribution +Lifo = pybind.LifoDistribution +MaxHeap = functools.partial(pybind.HeapDistribution, False) # pylint: disable=invalid-name +MinHeap = functools.partial(pybind.HeapDistribution, True) # pylint: disable=invalid-name +Prioritized = pybind.PrioritizedDistribution +Uniform = pybind.UniformDistribution