id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11,700 | ray-project/ray | rllib/utils/exploration/upper_confidence_bound.py | rllib.utils.exploration.upper_confidence_bound.UpperConfidenceBound | from ray.rllib.utils.annotations import OldAPIStack, override
from ray.rllib.utils.exploration.exploration import Exploration
from ray.rllib.utils.framework import TensorType, try_import_tf
from ray.rllib.models.action_dist import ActionDistribution
from typing import Union
@OldAPIStack
class UpperConfidenceBound(Expl... | @OldAPIStack
class UpperConfidenceBound(Exploration):
@override(Exploration)
def get_exploration_action(self, action_distribution: ActionDistribution, timestep: Union[int, TensorType], explore: bool=True):
pass
def _get_torch_exploration_action(self, action_dist, explore):
pass
def _g... | 6 | 0 | 9 | 0 | 9 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 3 | 0 | 3 | 3 | 30 | 2 | 28 | 12 | 18 | 0 | 14 | 6 | 10 | 3 | 1 | 1 | 6 |
11,701 | ray-project/ray | rllib/utils/filter.py | rllib.utils.filter.ConcurrentMeanStdFilter | from ray.rllib.utils.annotations import OldAPIStack
import threading
from ray._common.deprecation import deprecation_warning
@OldAPIStack
class ConcurrentMeanStdFilter(MeanStdFilter):
is_concurrent = True
def __init__(self, *args, **kwargs):
super(ConcurrentMeanStdFilter, self).__init__(*args, **kwarg... | @OldAPIStack
class ConcurrentMeanStdFilter(MeanStdFilter):
def __init__(self, *args, **kwargs):
pass
def lock_wrap(func):
pass
def wrapper(*args, **kwargs):
pass
def as_serializable(self) -> 'MeanStdFilter':
'''Returns non-concurren... | 8 | 2 | 8 | 1 | 7 | 0 | 1 | 0.06 | 1 | 2 | 0 | 0 | 4 | 2 | 4 | 17 | 46 | 8 | 36 | 12 | 29 | 2 | 22 | 12 | 15 | 1 | 2 | 1 | 6 |
11,702 | ray-project/ray | rllib/utils/filter.py | rllib.utils.filter.Filter | from ray.rllib.utils.annotations import OldAPIStack
from ray._common.deprecation import Deprecated
@OldAPIStack
class Filter:
"""Processes input, possibly statefully."""
def apply_changes(self, other: 'Filter', *args, **kwargs) -> None:
"""Updates self with "new state" from other filter."""
ra... | @OldAPIStack
class Filter:
'''Processes input, possibly statefully.'''
def apply_changes(self, other: 'Filter', *args, **kwargs) -> None:
'''Updates self with "new state" from other filter.'''
pass
def copy(self) -> 'Filter':
'''Creates a new object with same state as self.
... | 9 | 5 | 3 | 0 | 2 | 1 | 1 | 0.57 | 0 | 1 | 0 | 2 | 6 | 0 | 6 | 6 | 29 | 7 | 14 | 8 | 6 | 8 | 13 | 7 | 6 | 1 | 0 | 0 | 6 |
11,703 | ray-project/ray | rllib/utils/filter.py | rllib.utils.filter.MeanStdFilter | from ray.rllib.utils.typing import TensorStructType
from ray.rllib.utils.numpy import SMALL_NUMBER
import numpy as np
import tree
from ray.rllib.utils.annotations import OldAPIStack
@OldAPIStack
class MeanStdFilter(Filter):
"""Keeps track of a running mean for seen states"""
is_concurrent = False
def __in... | @OldAPIStack
class MeanStdFilter(Filter):
'''Keeps track of a running mean for seen states'''
def __init__(self, shape, demean=True, destd=True, clip=10.0):
pass
def reset_buffer(self) -> None:
pass
def apply_changes(self, other: 'MeanStdFilter', with_buffer: bool=False, *args, **kwar... | 10 | 4 | 24 | 4 | 11 | 9 | 2 | 0.93 | 1 | 5 | 1 | 1 | 7 | 7 | 7 | 13 | 177 | 38 | 72 | 23 | 61 | 67 | 57 | 21 | 48 | 8 | 1 | 3 | 19 |
11,704 | ray-project/ray | rllib/utils/filter.py | rllib.utils.filter.NoFilter | from ray.rllib.utils.annotations import OldAPIStack
import numpy as np
from ray.rllib.utils.typing import TensorStructType
@OldAPIStack
class NoFilter(Filter):
is_concurrent = True
def __call__(self, x: TensorStructType, update=True):
if isinstance(x, (np.ndarray, dict, tuple)):
return x
... | @OldAPIStack
class NoFilter(Filter):
def __call__(self, x: TensorStructType, update=True):
pass
def apply_changes(self, other: 'NoFilter', *args, **kwargs) -> None:
pass
def copy(self) -> 'NoFilter':
pass
def sync(self, other: 'NoFilter') -> None:
pass
def reset_... | 8 | 0 | 3 | 0 | 3 | 0 | 1 | 0.05 | 1 | 4 | 0 | 0 | 6 | 0 | 6 | 12 | 27 | 7 | 19 | 8 | 12 | 1 | 19 | 8 | 12 | 3 | 1 | 1 | 8 |
11,705 | ray-project/ray | rllib/utils/filter.py | rllib.utils.filter.RunningStat | from ray.rllib.utils.serialization import _serialize_ndarray, _deserialize_ndarray
from ray.rllib.utils.annotations import OldAPIStack
import numpy as np
@OldAPIStack
class RunningStat:
def __init__(self, shape=()):
"""Initializes a `RunningStat` instance."""
self.num_pushes = 0
self.num_p... | @OldAPIStack
class RunningStat:
def __init__(self, shape=()):
'''Initializes a `RunningStat` instance.'''
pass
def copy(self):
'''Copies a `RunningStat`.'''
pass
def push(self, x):
'''Updates a `RunningStat` instance by a new value.
Args:
x: A n... | 20 | 12 | 7 | 0 | 6 | 0 | 2 | 0.04 | 0 | 2 | 0 | 0 | 11 | 3 | 12 | 12 | 97 | 11 | 83 | 32 | 64 | 3 | 54 | 26 | 41 | 4 | 0 | 1 | 19 |
11,706 | ray-project/ray | rllib/utils/filter_manager.py | rllib.utils.filter_manager.FilterManager | from ray.rllib.utils.annotations import OldAPIStack
from typing import Optional
import ray
@OldAPIStack
class FilterManager:
"""Manages filters and coordination across remote evaluators that expose
`get_filters` and `sync_filters`.
"""
@staticmethod
def synchronize(local_filters, worker_set, updat... | @OldAPIStack
class FilterManager:
'''Manages filters and coordination across remote evaluators that expose
`get_filters` and `sync_filters`.
'''
@staticmethod
def synchronize(local_filters, worker_set, update_remote=True, timeout_seconds: Optional[float]=None, use_remote_data_for_update: bool=True):... | 4 | 2 | 66 | 7 | 40 | 19 | 8 | 0.52 | 0 | 2 | 0 | 0 | 0 | 0 | 1 | 1 | 72 | 8 | 42 | 15 | 33 | 22 | 19 | 8 | 17 | 8 | 0 | 3 | 8 |
11,707 | ray-project/ray | rllib/utils/framework.py | rllib.utils.framework._FakeTfClassStub | class _FakeTfClassStub:
def __init__(self, *a, **kw):
raise ImportError('Could not import `tensorflow`. Try pip install tensorflow.') | class _FakeTfClassStub:
def __init__(self, *a, **kw):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
11,708 | ray-project/ray | rllib/utils/framework.py | rllib.utils.framework._FakeTorchClassStub | class _FakeTorchClassStub:
def __init__(self, *a, **kw):
raise ImportError('Could not import `torch`. Try pip install torch.') | class _FakeTorchClassStub:
def __init__(self, *a, **kw):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
11,709 | ray-project/ray | rllib/utils/framework.py | rllib.utils.framework._KerasStub | class _KerasStub:
def __init__(self) -> None:
self.Model = _FakeTfClassStub | class _KerasStub:
def __init__(self) -> None:
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 3 | 0 | 3 | 3 | 1 | 0 | 3 | 3 | 1 | 1 | 0 | 0 | 1 |
11,710 | ray-project/ray | rllib/utils/framework.py | rllib.utils.framework._NNStub | class _NNStub:
def __init__(self, *a, **kw):
self.functional = None
self.Module = _FakeTorchClassStub
self.parallel = _ParallelStub() | class _NNStub:
def __init__(self, *a, **kw):
pass | 2 | 0 | 5 | 0 | 4 | 1 | 1 | 0.2 | 0 | 2 | 2 | 0 | 1 | 3 | 1 | 1 | 6 | 0 | 5 | 5 | 3 | 1 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
11,711 | ray-project/ray | rllib/utils/framework.py | rllib.utils.framework._ParallelStub | class _ParallelStub:
def __init__(self, *a, **kw):
self.DataParallel = _FakeTorchClassStub
self.DistributedDataParallel = _FakeTorchClassStub | class _ParallelStub:
def __init__(self, *a, **kw):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 2 | 1 | 1 | 4 | 0 | 4 | 4 | 2 | 0 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
11,712 | ray-project/ray | rllib/utils/framework.py | rllib.utils.framework._TFStub | class _TFStub:
def __init__(self) -> None:
self.keras = _KerasStub()
def __bool__(self):
return False | class _TFStub:
def __init__(self) -> None:
pass
def __bool__(self):
pass | 3 | 0 | 3 | 0 | 2 | 1 | 1 | 0.2 | 0 | 1 | 1 | 0 | 2 | 1 | 2 | 2 | 7 | 1 | 5 | 4 | 2 | 1 | 5 | 4 | 2 | 1 | 0 | 0 | 2 |
11,713 | ray-project/ray | rllib/utils/from_config.py | rllib.utils.from_config._NotProvided | class _NotProvided:
"""Singleton class to provide a "not provided" value for AlgorithmConfig signatures.
Using the only instance of this class indicates that the user does NOT wish to
change the value of some property.
.. testcode::
:skipif: True
from ray.rllib.algorithms.algorithm_co... | class _NotProvided:
'''Singleton class to provide a "not provided" value for AlgorithmConfig signatures.
Using the only instance of this class indicates that the user does NOT wish to
change the value of some property.
.. testcode::
:skipif: True
from ray.rllib.algorithms.algorithm_confi... | 3 | 1 | 3 | 0 | 3 | 0 | 2 | 4.57 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 59 | 20 | 7 | 4 | 4 | 32 | 7 | 4 | 4 | 2 | 0 | 1 | 2 |
11,714 | ray-project/ray | rllib/utils/lambda_defaultdict.py | rllib.utils.lambda_defaultdict.LambdaDefaultDict | from collections import defaultdict
from typing import Any, Callable
class LambdaDefaultDict(defaultdict):
"""A defaultdict that creates default values based on the associated key.
Note that the standard defaultdict can only produce default values (via its factory)
that are independent of the key under wh... |
class LambdaDefaultDict(defaultdict):
'''A defaultdict that creates default values based on the associated key.
Note that the standard defaultdict can only produce default values (via its factory)
that are independent of the key under which they are stored.
As opposed to that, the lambda functions used... | 3 | 2 | 9 | 2 | 4 | 4 | 2 | 2.89 | 1 | 4 | 0 | 0 | 2 | 1 | 2 | 2 | 48 | 13 | 9 | 5 | 6 | 26 | 9 | 4 | 6 | 2 | 1 | 1 | 3 |
11,715 | ray-project/ray | rllib/utils/metrics/learner_info.py | rllib.utils.metrics.learner_info.LearnerInfoBuilder | import tree
from ray.rllib.utils.annotations import OldAPIStack
from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
from collections import defaultdict
from ray.rllib.utils.typing import PolicyID
from typing import Dict
@OldAPIStack
class LearnerInfoBuilder:
def __init__(self, num_devices: int=1):
... | @OldAPIStack
class LearnerInfoBuilder:
def __init__(self, num_devices: int=1):
pass
def add_learn_on_batch_results(self, results: Dict, policy_id: PolicyID=DEFAULT_POLICY_ID) -> None:
'''Adds a policy.learn_on_(loaded)?_batch() result to this builder.
Args:
results: The res... | 6 | 2 | 17 | 1 | 12 | 4 | 3 | 0.35 | 0 | 3 | 0 | 0 | 4 | 3 | 4 | 4 | 73 | 8 | 48 | 20 | 36 | 17 | 25 | 13 | 20 | 5 | 0 | 4 | 11 |
11,716 | ray-project/ray | rllib/utils/metrics/metrics_logger.py | rllib.utils.metrics.metrics_logger.MetricsLogger | from ray.rllib.utils.metrics.stats import Stats, merge_stats
from typing import Any, Dict, List, Optional, Tuple, Union
from ray.rllib.utils import force_tuple, deep_update
from ray.util.annotations import PublicAPI
import tree
from ray._common.deprecation import Deprecated, deprecation_warning
from ray.util import log... | @PublicAPI(stability='alpha')
class MetricsLogger:
'''A generic class collecting and processing metrics in RL training and evaluation.
This class represents the main API used by all of RLlib's components (internal and
user facing) in order to log, collect, and process (reduce) stats during training
and ... | 40 | 18 | 41 | 5 | 13 | 23 | 3 | 2.11 | 0 | 12 | 1 | 0 | 22 | 4 | 23 | 23 | 1,155 | 152 | 322 | 123 | 235 | 681 | 178 | 61 | 150 | 11 | 0 | 4 | 67 |
11,717 | ray-project/ray | rllib/utils/metrics/metrics_logger.py | rllib.utils.metrics.metrics_logger._DummyRLock | class _DummyRLock:
def acquire(self, blocking=True, timeout=-1):
return True
def release(self):
pass
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
pass | class _DummyRLock:
def acquire(self, blocking=True, timeout=-1):
pass
def release(self):
pass
def __enter__(self):
pass
def __exit__(self, exc_type, exc_value, traceback):
pass | 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 4 | 0 | 4 | 4 | 12 | 3 | 9 | 5 | 4 | 0 | 9 | 5 | 4 | 1 | 0 | 0 | 4 |
11,718 | ray-project/ray | rllib/utils/metrics/stats.py | rllib.utils.metrics.stats.Stats | import threading
from typing import Any, Dict, List, Union, Optional, Tuple
import uuid
from ray.rllib.utils import force_list
import heapq
from collections import defaultdict, deque
import numpy as np
import time
from ray.rllib.utils.numpy import convert_to_numpy
from ray.util.annotations import DeveloperAPI
@Develop... | @DeveloperAPI
class Stats:
'''A container class holding a number of values and executing reductions over them.
The individual values in a Stats object may be of any type, for example python int
or float, numpy arrays, or more complex structured (tuple, dict) and are stored in
a list under `self.values`.... | 41 | 16 | 23 | 2 | 9 | 12 | 3 | 1.68 | 0 | 10 | 0 | 0 | 24 | 10 | 26 | 26 | 742 | 90 | 243 | 73 | 202 | 409 | 170 | 59 | 143 | 18 | 0 | 4 | 68 |
11,719 | ray-project/ray | rllib/utils/metrics/window_stat.py | rllib.utils.metrics.window_stat.WindowStat | import numpy as np
from ray.rllib.utils.annotations import OldAPIStack
@OldAPIStack
class WindowStat:
"""Handles/stores incoming dataset and provides window-based statistics.
.. testcode::
:skipif: True
win_stats = WindowStat("level", 3)
win_stats.push(5.0)
win_stats.push(7.0)... | @OldAPIStack
class WindowStat:
'''Handles/stores incoming dataset and provides window-based statistics.
.. testcode::
:skipif: True
win_stats = WindowStat("level", 3)
win_stats.push(5.0)
win_stats.push(7.0)
win_stats.push(7.0)
win_stats.push(10.0)
# Expect... | 8 | 6 | 8 | 0 | 5 | 3 | 1 | 1.07 | 0 | 3 | 0 | 0 | 6 | 5 | 6 | 6 | 73 | 11 | 30 | 12 | 23 | 32 | 22 | 12 | 15 | 2 | 0 | 1 | 7 |
11,720 | ray-project/ray | rllib/utils/minibatch_utils.py | rllib.utils.minibatch_utils.MiniBatchCyclicIterator | from ray.rllib.policy.sample_batch import MultiAgentBatch, concat_samples
from ray.rllib.policy.sample_batch import SampleBatch
from ray.rllib.utils.annotations import DeveloperAPI
@DeveloperAPI
class MiniBatchCyclicIterator(MiniBatchIteratorBase):
"""This implements a simple multi-agent minibatch iterator.
T... | @DeveloperAPI
class MiniBatchCyclicIterator(MiniBatchIteratorBase):
'''This implements a simple multi-agent minibatch iterator.
This iterator will split the input multi-agent batch into minibatches where the
size of batch for each module_id (aka policy_id) is equal to minibatch_size. If the
input batch ... | 6 | 2 | 32 | 4 | 21 | 8 | 3 | 0.47 | 1 | 4 | 0 | 0 | 2 | 8 | 2 | 3 | 133 | 19 | 79 | 29 | 66 | 37 | 45 | 21 | 40 | 8 | 1 | 4 | 11 |
11,721 | ray-project/ray | rllib/utils/minibatch_utils.py | rllib.utils.minibatch_utils.MiniBatchDummyIterator | from ray.rllib.policy.sample_batch import MultiAgentBatch, concat_samples
class MiniBatchDummyIterator(MiniBatchIteratorBase):
def __init__(self, batch: MultiAgentBatch, **kwargs):
super().__init__(batch, **kwargs)
self._batch = batch
def __iter__(self):
yield self._batch |
class MiniBatchDummyIterator(MiniBatchIteratorBase):
def __init__(self, batch: MultiAgentBatch, **kwargs):
pass
def __iter__(self):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 3 | 7 | 1 | 6 | 4 | 3 | 0 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
11,722 | ray-project/ray | rllib/utils/minibatch_utils.py | rllib.utils.minibatch_utils.MiniBatchIteratorBase | from ray.rllib.policy.sample_batch import MultiAgentBatch, concat_samples
from ray.rllib.utils.annotations import DeveloperAPI
@DeveloperAPI
class MiniBatchIteratorBase:
"""The base class for all minibatch iterators."""
def __init__(self, batch: MultiAgentBatch, *, num_epochs: int=1, shuffle_batch_per_epoch: ... | null | 3 | 2 | 29 | 1 | 10 | 18 | 1 | 1.73 | 0 | 2 | 0 | 2 | 1 | 0 | 1 | 1 | 32 | 2 | 11 | 10 | 1 | 19 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
11,723 | ray-project/ray | rllib/utils/minibatch_utils.py | rllib.utils.minibatch_utils.ShardBatchIterator | import math
from ray.rllib.policy.sample_batch import MultiAgentBatch, concat_samples
from ray.rllib.utils.annotations import DeveloperAPI
@DeveloperAPI
class ShardBatchIterator:
"""Iterator for sharding batch into num_shards batches.
Args:
batch: The input multi-agent batch.
num_shards: The n... | @DeveloperAPI
class ShardBatchIterator:
'''Iterator for sharding batch into num_shards batches.
Args:
batch: The input multi-agent batch.
num_shards: The number of shards to split the batch into.
Yields:
A MultiAgentBatch of size len(batch) / num_shards.
'''
def __init__(sel... | 4 | 1 | 9 | 0 | 7 | 3 | 2 | 0.86 | 0 | 2 | 0 | 0 | 2 | 2 | 2 | 2 | 30 | 4 | 14 | 12 | 11 | 12 | 14 | 12 | 11 | 3 | 0 | 2 | 4 |
11,724 | ray-project/ray | rllib/utils/minibatch_utils.py | rllib.utils.minibatch_utils.ShardEpisodesIterator | from ray.rllib.utils.annotations import DeveloperAPI
from typing import List, Optional
from ray.rllib.utils.typing import DeviceType, EpisodeType
@DeveloperAPI
class ShardEpisodesIterator:
"""Iterator for sharding a list of Episodes into `num_shards` lists of Episodes."""
def __init__(self, episodes: List[Epi... | @DeveloperAPI
class ShardEpisodesIterator:
'''Iterator for sharding a list of Episodes into `num_shards` lists of Episodes.'''
def __init__(self, episodes: List[EpisodeType], num_shards: int, len_lookback_buffer: Optional[int]=None):
'''Initializes a ShardEpisodesIterator instance.
Args:
... | 4 | 3 | 36 | 3 | 23 | 11 | 4 | 0.47 | 0 | 3 | 0 | 0 | 2 | 5 | 2 | 2 | 76 | 7 | 47 | 24 | 39 | 22 | 34 | 19 | 31 | 5 | 0 | 3 | 7 |
11,725 | ray-project/ray | rllib/utils/minibatch_utils.py | rllib.utils.minibatch_utils.ShardObjectRefIterator | from ray.rllib.utils.annotations import DeveloperAPI
@DeveloperAPI
class ShardObjectRefIterator:
"""Iterator for sharding a list of ray ObjectRefs into num_shards sub-lists.
Args:
object_refs: The input list of ray ObjectRefs.
num_shards: The number of shards to split the references into.
... | @DeveloperAPI
class ShardObjectRefIterator:
'''Iterator for sharding a list of ray ObjectRefs into num_shards sub-lists.
Args:
object_refs: The input list of ray ObjectRefs.
num_shards: The number of shards to split the references into.
Yields:
A sub-list of ray ObjectRefs with lengt... | 4 | 1 | 9 | 1 | 6 | 2 | 2 | 0.85 | 0 | 2 | 0 | 0 | 2 | 2 | 2 | 2 | 29 | 5 | 13 | 11 | 10 | 11 | 13 | 11 | 10 | 3 | 0 | 1 | 4 |
11,726 | ray-project/ray | rllib/utils/replay_buffers/base.py | rllib.utils.replay_buffers.base.ReplayBufferInterface | import platform
from ray.util.annotations import DeveloperAPI
from abc import ABCMeta, abstractmethod
from typing import Any, Dict, Optional
@DeveloperAPI
class ReplayBufferInterface(metaclass=ABCMeta):
"""Abstract base class for all of RLlib's replay buffers.
Mainly defines the `add()` and `sample()` methods... | @DeveloperAPI
class ReplayBufferInterface(metaclass=ABCMeta):
'''Abstract base class for all of RLlib's replay buffers.
Mainly defines the `add()` and `sample()` methods that every buffer class
must implement to be usable by an Algorithm.
Buffers may determine on all the implementation details themselve... | 19 | 7 | 7 | 1 | 1 | 5 | 1 | 1.84 | 1 | 3 | 0 | 0 | 6 | 0 | 6 | 26 | 68 | 14 | 19 | 13 | 1 | 35 | 8 | 7 | 1 | 1 | 3 | 0 | 6 |
11,727 | ray-project/ray | rllib/utils/replay_buffers/episode_replay_buffer.py | rllib.utils.replay_buffers.episode_replay_buffer.EpisodeReplayBuffer | from typing import Any, Dict, List, Optional, Tuple, Union
from collections import deque
import hashlib
from ray.rllib.utils.metrics import ACTUAL_N_STEP, AGENT_ACTUAL_N_STEP, AGENT_STEP_UTILIZATION, ENV_STEP_UTILIZATION, MODULE_STEP_UTILIZATION, MODULE_ACTUAL_N_STEP, NUM_AGENT_EPISODES_STORED, NUM_AGENT_EPISODES_ADDED... |
class EpisodeReplayBuffer(ReplayBufferInterface):
'''Buffer that stores (completed or truncated) episodes by their ID.
Each "row" (a slot in a deque) in the buffer is occupied by one episode. If an
incomplete episode is added to the buffer and then another chunk of that episode is
added at a later time... | 25 | 17 | 79 | 5 | 51 | 23 | 3 | 0.47 | 1 | 12 | 0 | 0 | 17 | 14 | 17 | 17 | 1,409 | 102 | 887 | 206 | 783 | 421 | 321 | 120 | 303 | 11 | 1 | 6 | 57 |
11,728 | ray-project/ray | rllib/utils/replay_buffers/fifo_replay_buffer.py | rllib.utils.replay_buffers.fifo_replay_buffer.FifoReplayBuffer | from ray.rllib.policy.sample_batch import MultiAgentBatch
from ray.rllib.utils.annotations import override
from ray.rllib.utils.replay_buffers.replay_buffer import ReplayBuffer, StorageUnit
from typing import Any, Dict, Optional
import numpy as np
from ray.util.annotations import DeveloperAPI
from ray.rllib.utils.typin... | @DeveloperAPI
class FifoReplayBuffer(ReplayBuffer):
'''This replay buffer implements a FIFO queue.
Sometimes, e.g. for offline use cases, it may be desirable to use
off-policy algorithms without a Replay Buffer.
This FifoReplayBuffer can be used in-place to achieve the same effect
without having to ... | 20 | 7 | 10 | 1 | 3 | 6 | 1 | 1.55 | 1 | 3 | 0 | 0 | 7 | 1 | 7 | 7 | 98 | 19 | 31 | 16 | 12 | 48 | 20 | 10 | 12 | 2 | 1 | 1 | 8 |
11,729 | ray-project/ray | rllib/utils/replay_buffers/multi_agent_episode_buffer.py | rllib.utils.replay_buffers.multi_agent_episode_buffer.MultiAgentEpisodeReplayBuffer | from ray.rllib.core.columns import Columns
import numpy as np
from ray.rllib.env.multi_agent_episode import MultiAgentEpisode
from ray.rllib.utils.typing import AgentID, ModuleID, SampleBatchType
from ray.rllib.env.single_agent_episode import SingleAgentEpisode
import scipy
from ray.rllib.utils.spaces.space_utils impor... | @DeveloperAPI
class MultiAgentEpisodeReplayBuffer(EpisodeReplayBuffer):
'''Multi-agent episode replay buffer that stores episodes by their IDs.
This class implements a replay buffer as used in "playing Atari with Deep
Reinforcement Learning" (Mnih et al., 2013) for multi-agent reinforcement
learning,
... | 32 | 22 | 49 | 3 | 29 | 16 | 3 | 0.67 | 1 | 13 | 0 | 0 | 21 | 10 | 21 | 21 | 1,157 | 112 | 625 | 200 | 545 | 420 | 298 | 142 | 276 | 17 | 1 | 3 | 69 |
11,730 | ray-project/ray | rllib/utils/replay_buffers/multi_agent_mixin_replay_buffer.py | rllib.utils.replay_buffers.multi_agent_mixin_replay_buffer.MultiAgentMixInReplayBuffer | import collections
from ray.rllib.utils.replay_buffers.multi_agent_prioritized_replay_buffer import MultiAgentPrioritizedReplayBuffer
import numpy as np
import random
from ray.rllib.utils.annotations import override
from ray.rllib.utils.replay_buffers.multi_agent_replay_buffer import MultiAgentReplayBuffer, ReplayMode,... | @DeveloperAPI
class MultiAgentMixInReplayBuffer(MultiAgentPrioritizedReplayBuffer):
'''This buffer adds replayed samples to a stream of new experiences.
- Any newly added batch (`add()`) is immediately returned upon
the next `sample` call (close to on-policy) as well as being moved
into the buffer.
... | 18 | 8 | 45 | 5 | 25 | 15 | 4 | 0.93 | 1 | 8 | 0 | 0 | 5 | 4 | 5 | 5 | 373 | 56 | 164 | 52 | 129 | 153 | 82 | 28 | 73 | 15 | 1 | 6 | 34 |
11,731 | ray-project/ray | rllib/utils/replay_buffers/multi_agent_prioritized_episode_buffer.py | rllib.utils.replay_buffers.multi_agent_prioritized_episode_buffer.MultiAgentPrioritizedEpisodeReplayBuffer | from numpy.typing import NDArray
from collections import defaultdict, deque
import scipy
from ray.rllib.env.multi_agent_episode import MultiAgentEpisode
from ray.rllib.utils.annotations import override
from ray.rllib.execution.segment_tree import MinSegmentTree, SumSegmentTree
from ray.rllib.utils.typing import ModuleI... |
class MultiAgentPrioritizedEpisodeReplayBuffer(MultiAgentEpisodeReplayBuffer, PrioritizedEpisodeReplayBuffer):
'''Multi-agent episode replay buffer that stores episodes by their IDs.
This class implements a replay buffer as used in "Prioritized Experience
Replay" (Schaul et al., 2016) for multi-agent reinf... | 19 | 9 | 92 | 6 | 57 | 30 | 4 | 0.68 | 2 | 12 | 0 | 0 | 10 | 10 | 10 | 10 | 1,056 | 90 | 576 | 170 | 506 | 391 | 257 | 111 | 246 | 19 | 1 | 4 | 42 |
11,732 | ray-project/ray | rllib/utils/replay_buffers/multi_agent_prioritized_replay_buffer.py | rllib.utils.replay_buffers.multi_agent_prioritized_replay_buffer.MultiAgentPrioritizedReplayBuffer | from ray.rllib.utils.annotations import override
from ray.util.annotations import DeveloperAPI
from ray.rllib.utils.replay_buffers.prioritized_replay_buffer import PrioritizedReplayBuffer
from ray.util.timer import _Timer
import numpy as np
from ray.rllib.utils.replay_buffers.multi_agent_replay_buffer import MultiAgent... | @DeveloperAPI
class MultiAgentPrioritizedReplayBuffer(MultiAgentReplayBuffer, PrioritizedReplayBuffer):
'''A prioritized replay buffer shard for multiagent setups.
This buffer is meant to be run in parallel to distribute experiences
across `num_shards` shards. Unlike simpler buffers, it holds a set of
b... | 12 | 5 | 58 | 4 | 35 | 20 | 6 | 0.57 | 2 | 7 | 1 | 0 | 4 | 4 | 4 | 4 | 252 | 20 | 148 | 41 | 118 | 84 | 52 | 17 | 47 | 16 | 1 | 4 | 25 |
11,733 | ray-project/ray | rllib/utils/replay_buffers/multi_agent_replay_buffer.py | rllib.utils.replay_buffers.multi_agent_replay_buffer.MultiAgentReplayBuffer | from ray.rllib.utils.annotations import override
from ray.util.annotations import DeveloperAPI
import collections
from ray._common.deprecation import Deprecated
from ray.rllib.utils.replay_buffers.replay_buffer import _ALL_POLICIES, ReplayBuffer, StorageUnit
from ray.util.debug import log_once
from ray.util.timer impor... | @DeveloperAPI
class MultiAgentReplayBuffer(ReplayBuffer):
'''A replay buffer shard for multiagent setups.
This buffer is meant to be run in parallel to distribute experiences
across `num_shards` shards. Unlike simpler buffers, it holds a set of
buffers - one for each policy ID.
'''
def __init__... | 27 | 11 | 26 | 2 | 15 | 8 | 3 | 0.53 | 1 | 9 | 2 | 0 | 10 | 12 | 10 | 10 | 337 | 38 | 195 | 64 | 149 | 104 | 98 | 40 | 85 | 10 | 1 | 4 | 38 |
11,734 | ray-project/ray | rllib/utils/replay_buffers/multi_agent_replay_buffer.py | rllib.utils.replay_buffers.multi_agent_replay_buffer.ReplayMode | from enum import Enum
from ray.util.annotations import DeveloperAPI
@DeveloperAPI
class ReplayMode(Enum):
LOCKSTEP = 'lockstep'
INDEPENDENT = 'independent' | @DeveloperAPI
class ReplayMode(Enum):
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 4 | 0 | 0 |
11,735 | ray-project/ray | rllib/utils/replay_buffers/prioritized_episode_buffer.py | rllib.utils.replay_buffers.prioritized_episode_buffer.PrioritizedEpisodeReplayBuffer | import numpy as np
import scipy
from ray.rllib.env.single_agent_episode import SingleAgentEpisode
from ray.rllib.utils.typing import ModuleID, SampleBatchType
from ray.rllib.core import DEFAULT_AGENT_ID, DEFAULT_MODULE_ID
from ray.rllib.execution.segment_tree import MinSegmentTree, SumSegmentTree
from ray.rllib.utils i... |
class PrioritizedEpisodeReplayBuffer(EpisodeReplayBuffer):
'''Prioritized Replay Buffer that stores episodes by their ID.
This replay buffer stores episode data (more specifically `SingleAgentEpisode`
objects) and implements prioritized experience replay first proposed
in the paper by Schaul et al. (20... | 13 | 9 | 76 | 6 | 42 | 27 | 4 | 0.85 | 1 | 13 | 0 | 0 | 8 | 9 | 8 | 8 | 712 | 77 | 344 | 114 | 303 | 292 | 181 | 82 | 172 | 12 | 1 | 3 | 30 |
11,736 | ray-project/ray | rllib/utils/replay_buffers/prioritized_replay_buffer.py | rllib.utils.replay_buffers.prioritized_replay_buffer.PrioritizedReplayBuffer | import numpy as np
from ray.rllib.utils.typing import SampleBatchType
from typing import Any, Dict, List, Optional
from ray.rllib.utils.replay_buffers.replay_buffer import ReplayBuffer
from ray.rllib.policy.sample_batch import SampleBatch
import random
from ray.rllib.execution.segment_tree import SumSegmentTree, MinSeg... | @DeveloperAPI
class PrioritizedReplayBuffer(ReplayBuffer):
'''This buffer implements Prioritized Experience Replay.
The algorithm has been described by Tom Schaul et. al. in "Prioritized
Experience Replay". See https://arxiv.org/pdf/1511.05952.pdf for
the full paper.
'''
def __init__(self, capa... | 21 | 8 | 25 | 3 | 12 | 9 | 2 | 0.73 | 1 | 11 | 0 | 0 | 8 | 5 | 8 | 8 | 222 | 35 | 108 | 49 | 80 | 79 | 75 | 35 | 66 | 5 | 1 | 2 | 17 |
11,737 | ray-project/ray | rllib/utils/replay_buffers/replay_buffer.py | rllib.utils.replay_buffers.replay_buffer.ReplayBuffer | from ray.rllib.utils.typing import SampleBatchType
import random
import numpy as np
from ray.util.debug import log_once
from ray.rllib.utils.metrics.window_stat import WindowStat
from ray.rllib.utils.annotations import override
from typing import Any, Dict, List, Optional, Union
from ray.rllib.policy.sample_batch impor... | @DeveloperAPI
class ReplayBuffer(ReplayBufferInterface, FaultAwareApply):
'''The lowest-level replay buffer interface used by RLlib.
This class implements a basic ring-type of buffer with random sampling.
ReplayBuffer is the base class for advanced types that add functionality while
retaining compatibil... | 19 | 7 | 26 | 3 | 15 | 8 | 3 | 0.78 | 2 | 8 | 1 | 0 | 9 | 12 | 9 | 9 | 309 | 53 | 144 | 52 | 119 | 112 | 95 | 37 | 85 | 11 | 1 | 4 | 31 |
11,738 | ray-project/ray | rllib/utils/replay_buffers/replay_buffer.py | rllib.utils.replay_buffers.replay_buffer.StorageUnit | from ray.util.annotations import DeveloperAPI
from enum import Enum
@DeveloperAPI
class StorageUnit(Enum):
"""Specifies how batches are structured in a ReplayBuffer.
timesteps: One buffer slot per timestep.
sequences: One buffer slot per sequence.
episodes: One buffer slot per episode.
fragemts: O... | @DeveloperAPI
class StorageUnit(Enum):
'''Specifies how batches are structured in a ReplayBuffer.
timesteps: One buffer slot per timestep.
sequences: One buffer slot per sequence.
episodes: One buffer slot per episode.
fragemts: One buffer slot per incoming batch.
'''
pass | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 1.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 13 | 2 | 5 | 5 | 4 | 6 | 5 | 5 | 4 | 0 | 4 | 0 | 0 |
11,739 | ray-project/ray | rllib/utils/replay_buffers/reservoir_replay_buffer.py | rllib.utils.replay_buffers.reservoir_replay_buffer.ReservoirReplayBuffer | from typing import Any, Dict
import random
from ray.rllib.utils.typing import SampleBatchType
from ray.rllib.utils.annotations import ExperimentalAPI, override
from ray.rllib.utils.replay_buffers.replay_buffer import ReplayBuffer, warn_replay_capacity
@ExperimentalAPI
class ReservoirReplayBuffer(ReplayBuffer):
"""... | @ExperimentalAPI
class ReservoirReplayBuffer(ReplayBuffer):
'''This buffer implements reservoir sampling.
The algorithm has been described by Jeffrey S. Vitter in "Random sampling
with a reservoir".
'''
def __init__(self, capacity: int=10000, storage_unit: str='timesteps', **kwargs):
'''Ini... | 15 | 6 | 19 | 2 | 9 | 7 | 1 | 0.76 | 1 | 5 | 0 | 0 | 5 | 4 | 5 | 5 | 112 | 17 | 54 | 21 | 38 | 41 | 40 | 15 | 34 | 3 | 1 | 2 | 7 |
11,740 | ray-project/ray | rllib/utils/schedules/constant_schedule.py | rllib.utils.schedules.constant_schedule.ConstantSchedule | from typing import Optional
from ray.rllib.utils.annotations import OldAPIStack, override
from ray.rllib.utils.typing import TensorType
from ray.rllib.utils.schedules.schedule import Schedule
@OldAPIStack
class ConstantSchedule(Schedule):
"""A Schedule where the value remains constant over time."""
def __init... | @OldAPIStack
class ConstantSchedule(Schedule):
'''A Schedule where the value remains constant over time.'''
def __init__(self, value: float, framework: Optional[str]=None):
'''Initializes a ConstantSchedule instance.
Args:
value: The constant value to return, independently of time.
... | 7 | 2 | 5 | 0 | 2 | 2 | 1 | 0.7 | 1 | 3 | 0 | 0 | 3 | 1 | 3 | 3 | 21 | 4 | 10 | 7 | 4 | 7 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
11,741 | ray-project/ray | rllib/utils/schedules/exponential_schedule.py | rllib.utils.schedules.exponential_schedule.ExponentialSchedule | from ray.rllib.utils.schedules.schedule import Schedule
from typing import Optional
from ray.rllib.utils.annotations import OldAPIStack, override
from ray.rllib.utils.typing import TensorType
@OldAPIStack
class ExponentialSchedule(Schedule):
"""Exponential decay schedule from `initial_p` to `final_p`.
Reduces... | @OldAPIStack
class ExponentialSchedule(Schedule):
'''Exponential decay schedule from `initial_p` to `final_p`.
Reduces output over `schedule_timesteps`. After this many time steps
always returns `final_p`.
'''
def __init__(self, schedule_timesteps: int, framework: Optional[str]=None, initial_p: flo... | 5 | 3 | 15 | 1 | 8 | 7 | 2 | 0.94 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 2 | 39 | 4 | 18 | 13 | 8 | 17 | 11 | 6 | 8 | 2 | 1 | 1 | 3 |
11,742 | ray-project/ray | rllib/utils/schedules/linear_schedule.py | rllib.utils.schedules.linear_schedule.LinearSchedule | from ray.rllib.utils.annotations import OldAPIStack
from ray.rllib.utils.schedules.polynomial_schedule import PolynomialSchedule
@OldAPIStack
class LinearSchedule(PolynomialSchedule):
"""Linear interpolation between `initial_p` and `final_p`.
Uses `PolynomialSchedule` with power=1.0.
The formula is:
... | @OldAPIStack
class LinearSchedule(PolynomialSchedule):
'''Linear interpolation between `initial_p` and `final_p`.
Uses `PolynomialSchedule` with power=1.0.
The formula is:
value = `final_p` + (`initial_p` - `final_p`) * (1 - `t`/t_max)
'''
def __init__(self, **kwargs):
'''Initializes a... | 3 | 2 | 3 | 0 | 2 | 1 | 1 | 2 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 13 | 4 | 3 | 2 | 1 | 6 | 3 | 2 | 1 | 1 | 1 | 0 | 1 |
11,743 | ray-project/ray | rllib/utils/schedules/piecewise_schedule.py | rllib.utils.schedules.piecewise_schedule.PiecewiseSchedule | from ray.util.annotations import DeveloperAPI
from ray.rllib.utils.typing import TensorType
from ray.rllib.utils.schedules.schedule import Schedule
from ray.rllib.utils.annotations import override
from typing import Callable, List, Optional, Tuple
@DeveloperAPI
class PiecewiseSchedule(Schedule):
"""Implements a Pi... | @DeveloperAPI
class PiecewiseSchedule(Schedule):
'''Implements a Piecewise Scheduler.'''
def __init__(self, endpoints: List[Tuple[int, float]], framework: Optional[str]=None, interpolation: Callable[[TensorType, TensorType, TensorType], TensorType]=_linear_interpolation, outside_value: Optional[float]=None):
... | 9 | 2 | 18 | 2 | 11 | 6 | 2 | 0.59 | 1 | 5 | 0 | 0 | 3 | 3 | 3 | 3 | 89 | 11 | 49 | 27 | 33 | 29 | 31 | 17 | 25 | 3 | 1 | 2 | 8 |
11,744 | ray-project/ray | rllib/utils/schedules/polynomial_schedule.py | rllib.utils.schedules.polynomial_schedule.PolynomialSchedule | from ray.rllib.utils.typing import TensorType
from ray.rllib.utils.annotations import OldAPIStack, override
from typing import Optional
from ray.rllib.utils.schedules.schedule import Schedule
@OldAPIStack
class PolynomialSchedule(Schedule):
"""Polynomial interpolation between `initial_p` and `final_p`.
Over `... | @OldAPIStack
class PolynomialSchedule(Schedule):
'''Polynomial interpolation between `initial_p` and `final_p`.
Over `schedule_timesteps`. After this many time steps, always returns
`final_p`.
'''
def __init__(self, schedule_timesteps: int, final_p: float, framework: Optional[str], initial_p: float... | 7 | 3 | 15 | 0 | 10 | 4 | 1 | 0.52 | 1 | 4 | 0 | 0 | 3 | 4 | 3 | 3 | 55 | 5 | 33 | 17 | 20 | 17 | 16 | 8 | 12 | 2 | 1 | 1 | 4 |
11,745 | ray-project/ray | rllib/utils/schedules/schedule.py | rllib.utils.schedules.schedule.Schedule | from ray.rllib.utils.annotations import OldAPIStack
from typing import Any, Union
from ray.rllib.utils.typing import TensorType
from abc import ABCMeta, abstractmethod
@OldAPIStack
class Schedule(metaclass=ABCMeta):
"""Schedule classes implement various time-dependent scheduling schemas.
- Constant behavior.
... | @OldAPIStack
class Schedule(metaclass=ABCMeta):
'''Schedule classes implement various time-dependent scheduling schemas.
- Constant behavior.
- Linear decay.
- Piecewise decay.
- Exponential decay.
Useful for backend-agnostic rate/weight changes for learning rates,
exploration epsilons, beta... | 8 | 5 | 8 | 1 | 2 | 5 | 1 | 2.43 | 1 | 3 | 0 | 0 | 5 | 1 | 5 | 25 | 62 | 14 | 14 | 8 | 7 | 34 | 13 | 7 | 7 | 2 | 3 | 1 | 6 |
11,746 | ray-project/ray | rllib/utils/schedules/scheduler.py | rllib.utils.schedules.scheduler.Scheduler | from ray.util.annotations import DeveloperAPI
from ray.rllib.utils.schedules.piecewise_schedule import PiecewiseSchedule
from ray.rllib.utils.typing import LearningRateOrSchedule, TensorType
from typing import Optional
@DeveloperAPI
class Scheduler:
"""Class to manage a scheduled (framework-dependent) tensor varia... | @DeveloperAPI
class Scheduler:
'''Class to manage a scheduled (framework-dependent) tensor variable.
Uses the PiecewiseSchedule (for maximum configuration flexibility)
'''
def __init__(self, fixed_value_or_schedule: LearningRateOrSchedule, *, framework: str='torch', device: Optional[str]=None):
... | 8 | 6 | 30 | 3 | 16 | 11 | 3 | 0.7 | 0 | 6 | 0 | 0 | 4 | 5 | 5 | 5 | 162 | 21 | 83 | 24 | 65 | 58 | 30 | 12 | 24 | 5 | 0 | 2 | 13 |
11,747 | ray-project/ray | rllib/utils/spaces/flexdict.py | rllib.utils.spaces.flexdict.FlexDict | from ray.rllib.utils.annotations import PublicAPI
import gymnasium as gym
@PublicAPI
class FlexDict(gym.spaces.Dict):
"""Gym Dictionary with arbitrary keys updatable after instantiation
Example:
space = FlexDict({})
space['key'] = spaces.Box(4,)
See also: documentation for gym.spaces.Dict
... | @PublicAPI
class FlexDict(gym.spaces.Dict):
'''Gym Dictionary with arbitrary keys updatable after instantiation
Example:
space = FlexDict({})
space['key'] = spaces.Box(4,)
See also: documentation for gym.spaces.Dict
'''
def __init__(self, spaces=None, **spaces_kwargs):
pass
... | 8 | 1 | 5 | 1 | 4 | 0 | 1 | 0.24 | 1 | 3 | 0 | 0 | 6 | 0 | 6 | 6 | 41 | 10 | 25 | 10 | 18 | 6 | 21 | 10 | 14 | 3 | 1 | 1 | 8 |
11,748 | ray-project/ray | rllib/utils/spaces/repeated.py | rllib.utils.spaces.repeated.Repeated | from ray.rllib.utils.annotations import PublicAPI
import numpy as np
import gymnasium as gym
@PublicAPI
class Repeated(gym.Space):
"""Represents a variable-length list of child spaces.
Example:
self.observation_space = spaces.Repeated(spaces.Box(4,), max_len=10)
--> from 0 to 10 boxes of s... | @PublicAPI
class Repeated(gym.Space):
'''Represents a variable-length list of child spaces.
Example:
self.observation_space = spaces.Repeated(spaces.Box(4,), max_len=10)
--> from 0 to 10 boxes of shape (4,)
See also: documentation for rllib.models.RepeatedValues, which shows how
... | 6 | 1 | 4 | 0 | 4 | 0 | 1 | 0.39 | 1 | 4 | 0 | 0 | 4 | 2 | 4 | 4 | 31 | 6 | 18 | 8 | 13 | 7 | 11 | 7 | 6 | 1 | 1 | 0 | 4 |
11,749 | ray-project/ray | rllib/utils/spaces/simplex.py | rllib.utils.spaces.simplex.Simplex | import numpy as np
from ray.rllib.utils.annotations import PublicAPI
import gymnasium as gym
@PublicAPI
class Simplex(gym.Space):
"""Represents a d - 1 dimensional Simplex in R^d.
That is, all coordinates are in [0, 1] and sum to 1.
The dimension d of the simplex is assumed to be shape[-1].
Additiona... | @PublicAPI
class Simplex(gym.Space):
'''Represents a d - 1 dimensional Simplex in R^d.
That is, all coordinates are in [0, 1] and sum to 1.
The dimension d of the simplex is assumed to be shape[-1].
Additionally one can specify the underlying distribution of
the simplex as a Dirichlet distribution b... | 9 | 1 | 5 | 0 | 4 | 0 | 1 | 0.35 | 1 | 4 | 0 | 0 | 7 | 2 | 7 | 7 | 54 | 12 | 31 | 11 | 23 | 11 | 21 | 10 | 13 | 2 | 1 | 1 | 8 |
11,750 | ray-project/ray | rllib/utils/spaces/space_utils.py | rllib.utils.spaces.space_utils.BatchedNdArray | from ray.rllib.utils.annotations import DeveloperAPI
import numpy as np
@DeveloperAPI
class BatchedNdArray(np.ndarray):
"""A ndarray-wrapper the usage of which indicates that there a batch dim exists.
This is such that our `batch()` utility can distinguish between having to
stack n individual batch items ... | @DeveloperAPI
class BatchedNdArray(np.ndarray):
'''A ndarray-wrapper the usage of which indicates that there a batch dim exists.
This is such that our `batch()` utility can distinguish between having to
stack n individual batch items (each one w/o any batch dim) vs having to
concatenate n already batche... | 3 | 1 | 4 | 0 | 3 | 1 | 1 | 2 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 15 | 3 | 4 | 3 | 2 | 8 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
11,751 | ray-project/ray | rllib/utils/tf_run_builder.py | rllib.utils.tf_run_builder._TFRunBuilder | from ray.rllib.utils.annotations import OldAPIStack
import os
@OldAPIStack
class _TFRunBuilder:
"""Used to incrementally build up a TensorFlow run.
This is particularly useful for batching ops from multiple different
policies in the multi-agent setting.
"""
def __init__(self, session, debug_name)... | @OldAPIStack
class _TFRunBuilder:
'''Used to incrementally build up a TensorFlow run.
This is particularly useful for batching ops from multiple different
policies in the multi-agent setting.
'''
def __init__(self, session, debug_name):
pass
def add_feed_dict(self, feed_dict):
... | 6 | 1 | 11 | 0 | 11 | 0 | 3 | 0.09 | 0 | 6 | 0 | 0 | 4 | 5 | 4 | 4 | 52 | 5 | 43 | 13 | 38 | 4 | 30 | 12 | 25 | 6 | 0 | 2 | 11 |
11,752 | ray-project/ray | rllib/utils/typing.py | rllib.utils.typing.ActionConnectorDataType | from ray.rllib.utils.annotations import OldAPIStack
@OldAPIStack
class ActionConnectorDataType:
"""Data type that is fed into and yielded from agent connectors.
Args:
env_id: ID of the environment.
agent_id: ID to help identify the agent from which the data is received.
input_dict: Inp... | @OldAPIStack
class ActionConnectorDataType:
'''Data type that is fed into and yielded from agent connectors.
Args:
env_id: ID of the environment.
agent_id: ID to help identify the agent from which the data is received.
input_dict: Input data that was passed into the policy.
S... | 3 | 1 | 11 | 0 | 11 | 0 | 1 | 0.83 | 0 | 1 | 0 | 0 | 1 | 4 | 1 | 1 | 25 | 3 | 12 | 12 | 4 | 10 | 6 | 6 | 4 | 1 | 0 | 0 | 1 |
11,753 | ray-project/ray | rllib/utils/typing.py | rllib.utils.typing.AgentConnectorDataType | from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional, Sequence, Tuple, Type, TypeVar, Union
from ray.rllib.utils.annotations import OldAPIStack
@OldAPIStack
class AgentConnectorDataType:
"""Data type that is fed into and yielded from agent connectors.
Args:
env_id: ID of the... | @OldAPIStack
class AgentConnectorDataType:
'''Data type that is fed into and yielded from agent connectors.
Args:
env_id: ID of the environment.
agent_id: ID to help identify the agent from which the data is received.
data: A payload (``data``). With RLlib's default sampler, the payload
... | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 1.6 | 0 | 2 | 0 | 0 | 1 | 3 | 1 | 1 | 15 | 2 | 5 | 5 | 3 | 8 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
11,754 | ray-project/ray | rllib/utils/typing.py | rllib.utils.typing.AgentConnectorsOutput | from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional, Sequence, Tuple, Type, TypeVar, Union
from ray.rllib.utils.annotations import OldAPIStack
@OldAPIStack
class AgentConnectorsOutput:
"""Final output data type of agent connectors.
Args are populated depending on the AgentConnector... | @OldAPIStack
class AgentConnectorsOutput:
'''Final output data type of agent connectors.
Args are populated depending on the AgentConnector settings.
The branching happens in ViewRequirementAgentConnector.
Args:
raw_dict: The raw input dictionary that sampler can use to
build episode... | 3 | 1 | 5 | 0 | 5 | 0 | 1 | 1.83 | 0 | 1 | 0 | 0 | 1 | 2 | 1 | 1 | 20 | 3 | 6 | 6 | 2 | 11 | 4 | 4 | 2 | 1 | 0 | 0 | 1 |
11,755 | ray-project/ray | doc/source/rllib/doc_code/rllib_on_ray_readme.py | rllib_on_ray_readme.SimpleCorridor | from typing import Dict, Tuple, Any, Optional
import numpy as np
import gymnasium as gym
class SimpleCorridor(gym.Env):
"""Corridor environment where an agent must learn to move right to reach the exit.
---------------------
| S | 1 | 2 | 3 | G | S=start; G=goal; corridor_length=5
------------------... |
class SimpleCorridor(gym.Env):
'''Corridor environment where an agent must learn to move right to reach the exit.
---------------------
| S | 1 | 2 | 3 | G | S=start; G=goal; corridor_length=5
---------------------
Actions:
0: Move left
1: Move right
Observations:
A si... | 4 | 3 | 11 | 1 | 6 | 5 | 2 | 1.28 | 1 | 0 | 0 | 0 | 3 | 4 | 3 | 3 | 47 | 7 | 18 | 11 | 14 | 23 | 17 | 11 | 13 | 4 | 1 | 1 | 6 |
11,756 | ray-project/ray | rllib/examples/_docs/rllib_on_rllib_readme.py | rllib_on_rllib_readme.ParrotEnv | import gymnasium as gym
import numpy as np
class ParrotEnv(gym.Env):
"""Environment in which an agent must learn to repeat the seen observations.
Observations are float numbers indicating the to-be-repeated values,
e.g. -1.0, 5.1, or 3.2.
The action space is always the same as the observation space.
... |
class ParrotEnv(gym.Env):
'''Environment in which an agent must learn to repeat the seen observations.
Observations are float numbers indicating the to-be-repeated values,
e.g. -1.0, 5.1, or 3.2.
The action space is always the same as the observation space.
Rewards are r=-abs(observation - action),... | 4 | 3 | 10 | 0 | 6 | 4 | 1 | 1.06 | 1 | 0 | 0 | 0 | 3 | 4 | 3 | 3 | 44 | 7 | 18 | 10 | 14 | 19 | 16 | 10 | 12 | 1 | 1 | 0 | 3 |
11,757 | ray-project/ray | release/k8s_tests/run_gcs_ft_on_k8s.py | run_gcs_ft_on_k8s.TestScenario | import enum
class TestScenario(enum.Enum):
KILL_WORKER_NODE = 'kill_worker_node'
KILL_HEAD_NODE = 'kill_head_node' |
class TestScenario(enum.Enum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 4 | 0 | 0 |
11,758 | ray-project/ray | doc/source/ray-core/doc_code/runtime_env_example.py | runtime_env_example.Actor_job | import ray
@ray.remote
class Actor_job:
def g(self):
pass | @ray.remote
class Actor_job:
def g(self):
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
11,759 | ray-project/ray | doc/source/ray-core/doc_code/runtime_env_example.py | runtime_env_example.MyClass | import ray
@ray.remote(runtime_env=runtime_env)
class MyClass:
pass | @ray.remote(runtime_env=runtime_env)
class MyClass:
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
11,760 | ray-project/ray | doc/source/ray-core/doc_code/runtime_env_example.py | runtime_env_example.SomeClass | import ray
@ray.remote
class SomeClass:
pass | @ray.remote
class SomeClass:
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
11,761 | ray-project/ray | doc/source/ray-core/doc_code/scheduling.py | scheduling.Actor | import ray
@ray.remote(num_cpus=1)
class Actor:
pass | @ray.remote(num_cpus=1)
class Actor:
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
11,762 | ray-project/ray | doc/source/ray-core/doc_code/scheduling.py | scheduling.NodeAffinityActor | import ray
@ray.remote(num_cpus=1)
class NodeAffinityActor:
pass | @ray.remote(num_cpus=1)
class NodeAffinityActor:
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
11,763 | ray-project/ray | doc/source/ray-core/doc_code/scheduling.py | scheduling.SpreadActor | import ray
@ray.remote(num_cpus=1)
class SpreadActor:
pass | @ray.remote(num_cpus=1)
class SpreadActor:
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
11,764 | ray-project/ray | release/air_tests/frequent_pausing/script.py | script.FrequentPausesScheduler | from ray.tune.schedulers.trial_scheduler import FIFOScheduler, TrialScheduler
class FrequentPausesScheduler(FIFOScheduler):
def on_trial_result(self, tune_controller, trial, result):
return TrialScheduler.PAUSE |
class FrequentPausesScheduler(FIFOScheduler):
def on_trial_result(self, tune_controller, trial, result):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 22 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 2 | 0 | 1 |
11,765 | ray-project/ray | rllib/examples/_old_api_stack/connectors/self_play_with_policy_checkpoint.py | self_play_with_policy_checkpoint.AddPolicyCallback | from ray.rllib.policy.policy import Policy
from ray.rllib.callbacks.callbacks import RLlibCallback
class AddPolicyCallback(RLlibCallback):
def __init__(self, checkpoint_dir):
self._checkpoint_dir = checkpoint_dir
super().__init__()
def on_algorithm_init(self, *, algorithm, metrics_logger, **k... |
class AddPolicyCallback(RLlibCallback):
def __init__(self, checkpoint_dir):
pass
def on_algorithm_init(self, *, algorithm, metrics_logger, **kwargs):
pass | 3 | 0 | 8 | 1 | 6 | 2 | 1 | 0.23 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 2 | 18 | 2 | 13 | 5 | 10 | 3 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
11,766 | ray-project/ray | release/long_running_tests/workloads/serve.py | serve.Echo | import requests
import time
from ray import serve
@serve.deployment(name='echo', num_replicas=NUM_REPLICAS)
class Echo:
@serve.batch(max_batch_size=MAX_BATCH_SIZE)
async def handle_batch(self, requests):
time.sleep(0.01)
return ['hi' for _ in range(len(requests))]
async def __call__(self,... | @serve.deployment(name='echo', num_replicas=NUM_REPLICAS)
class Echo:
@serve.batch(max_batch_size=MAX_BATCH_SIZE)
async def handle_batch(self, requests):
pass
async def __call__(self, request):
pass | 5 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 | 0 | 2 | 2 | 8 | 1 | 7 | 5 | 3 | 0 | 6 | 3 | 3 | 1 | 0 | 0 | 2 |
11,767 | ray-project/ray | release/long_running_tests/workloads/serve_failure.py | serve_failure.RandomKiller | from ray.serve.context import _get_global_client
import asyncio
import ray
import random
@ray.remote(max_restarts=-1, max_task_retries=-1)
class RandomKiller:
def __init__(self, kill_period_s=1):
self.kill_period_s = kill_period_s
self.sanctuary = set()
async def run(self):
while True... | @ray.remote(max_restarts=-1, max_task_retries=-1)
class RandomKiller:
def __init__(self, kill_period_s=1):
pass
async def run(self):
pass
async def spare(self, app_name: str):
pass
async def stop_spare(self, app_name: str):
pass
def _get_serve_actors(self):
... | 7 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 0 | 3 | 0 | 0 | 5 | 2 | 5 | 5 | 31 | 5 | 26 | 15 | 20 | 0 | 26 | 15 | 20 | 4 | 0 | 3 | 9 |
11,768 | ray-project/ray | release/serve_tests/workloads/serve_resnet_benchmark.py | serve_resnet_benchmark.DataDownloader | from ray import serve
import time
import os
from typing import List, Optional
import torch
@serve.deployment(num_replicas=5)
class DataDownloader:
def __init__(self):
if os.path.exists('/home/ray/.cache/torch/') is False:
self.utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvi... | @serve.deployment(num_replicas=5)
class DataDownloader:
def __init__(self):
pass
def __call__(self, uris: List[str]):
pass | 4 | 0 | 16 | 1 | 13 | 2 | 3 | 0.11 | 0 | 2 | 0 | 0 | 2 | 1 | 2 | 2 | 33 | 3 | 27 | 6 | 24 | 3 | 18 | 5 | 15 | 5 | 0 | 3 | 6 |
11,769 | ray-project/ray | release/serve_tests/workloads/serve_resnet_benchmark.py | serve_resnet_benchmark.ImageObjectioner | import torch
from ray.serve.handle import DeploymentHandle
import asyncio
from typing import List, Optional
from torchvision import models
import time
import starlette.requests
from ray import serve
@serve.deployment
class ImageObjectioner:
def __init__(self, handle: DeploymentHandle, device='cpu'):
self.... | @serve.deployment
class ImageObjectioner:
def __init__(self, handle: DeploymentHandle, device='cpu'):
pass
async def predict(self, uris: List[str]):
pass
async def __call__(self, request: starlette.requests.Request):
pass | 5 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 0 | 2 | 1 | 0 | 3 | 3 | 3 | 3 | 25 | 3 | 22 | 17 | 18 | 0 | 20 | 16 | 16 | 2 | 0 | 1 | 4 |
11,770 | ray-project/ray | python/setup.py | setup.BuildType | from enum import Enum
class BuildType(Enum):
DEFAULT = 1
DEBUG = 2
ASAN = 3
TSAN = 4
DEPS_ONLY = 5 |
class BuildType(Enum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 5 | 0 | 5 | 5 | 4 | 0 | 5 | 5 | 4 | 0 | 4 | 0 | 0 |
11,771 | ray-project/ray | python/setup.py | setup.SetupSpec | class SetupSpec:
def __init__(self, type: SetupType, name: str, description: str, build_type: BuildType):
self.type: SetupType = type
self.name: str = name
version = find_version('ray', '_version.py')
if build_type == BuildType.DEBUG:
self.version: str = f'{version}+dbg'... | class SetupSpec:
def __init__(self, type: SetupType, name: str, description: str, build_type: BuildType):
pass
def get_packages(self):
pass | 3 | 0 | 13 | 0 | 12 | 1 | 3 | 0.04 | 0 | 5 | 2 | 0 | 2 | 8 | 2 | 2 | 27 | 1 | 25 | 14 | 20 | 1 | 19 | 12 | 16 | 4 | 0 | 1 | 6 |
11,772 | ray-project/ray | python/setup.py | setup.SetupType | from enum import Enum
class SetupType(Enum):
RAY = 1
RAY_CPP = 2 |
class SetupType(Enum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 4 | 0 | 0 |
11,773 | ray-project/ray | release/nightly_tests/setup_cluster_compute_config_updater.py | setup_cluster_compute_config_updater.ClusterComputeConfig | from typing import List, Union
import anyscale
import requests
import os
import logging
class ClusterComputeConfig:
def __init__(self):
self.cluster_id = os.environ['ANYSCALE_CLUSTER_ID']
sdk = anyscale.AnyscaleSDK()
self.cluster = sdk.get_cluster(self.cluster_id)
self.compute_conf... |
class ClusterComputeConfig:
def __init__(self):
pass
def update(self, field_path: List[Union[str, int]], field_value: Union[str, int]):
pass | 3 | 0 | 21 | 2 | 20 | 0 | 2 | 0 | 0 | 2 | 0 | 0 | 2 | 3 | 2 | 2 | 44 | 4 | 40 | 13 | 37 | 0 | 18 | 13 | 15 | 2 | 0 | 1 | 3 |
11,774 | ray-project/ray | release/nightly_tests/setup_cluster_compute_config_updater.py | setup_cluster_compute_config_updater.ClusterComputeConfigUpdate | from dataclasses import dataclass
from typing import List, Union
@dataclass
class ClusterComputeConfigUpdate:
field_path: List[Union[str, int]]
field_value: Union[str, int]
update_time_seconds_since_run: int
def __init__(self, update: str):
field_path, field_value, update_time_seconds_since_ru... | @dataclass
class ClusterComputeConfigUpdate:
def __init__(self, update: str):
pass | 3 | 0 | 16 | 3 | 13 | 0 | 4 | 0.18 | 0 | 2 | 0 | 0 | 1 | 0 | 1 | 1 | 24 | 4 | 17 | 4 | 15 | 3 | 15 | 4 | 13 | 4 | 0 | 2 | 4 |
11,775 | ray-project/ray | release/nightly_tests/setup_cluster_compute_config_updater.py | setup_cluster_compute_config_updater.ClusterComputeConfigUpdater | import asyncio
import time
import ray
from typing import List, Union
import logging
@ray.remote(num_cpus=0)
class ClusterComputeConfigUpdater:
def __init__(self, updates: List[ClusterComputeConfigUpdate]):
self.cluster_compute_config = ClusterComputeConfig()
self.updates = updates
self.sta... | @ray.remote(num_cpus=0)
class ClusterComputeConfigUpdater:
def __init__(self, updates: List[ClusterComputeConfigUpdate]):
pass
async def run(self):
pass
async def wait_until_run(self):
pass | 5 | 0 | 7 | 0 | 7 | 0 | 2 | 0 | 0 | 2 | 2 | 0 | 3 | 3 | 3 | 3 | 24 | 2 | 22 | 8 | 18 | 0 | 18 | 8 | 14 | 3 | 0 | 2 | 6 |
11,776 | ray-project/ray | doc/source/serve/doc_code/sklearn_quickstart.py | sklearn_quickstart.BoostingModel | from ray import serve
from typing import Dict
from starlette.requests import Request
@serve.deployment
class BoostingModel:
def __init__(self, model):
self.model = model
self.label_list = iris_dataset['target_names'].tolist()
async def __call__(self, request: Request) -> Dict:
payload... | @serve.deployment
class BoostingModel:
def __init__(self, model):
pass
async def __call__(self, request: Request) -> Dict:
pass | 4 | 0 | 5 | 1 | 5 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 12 | 2 | 10 | 8 | 7 | 0 | 10 | 8 | 7 | 1 | 0 | 0 | 2 |
11,777 | ray-project/ray | doc/source/serve/doc_code/fault_tolerance/sleepy_pid.py | sleepy_pid.SleepyPid | from ray import serve
@serve.deployment
class SleepyPid:
def __init__(self):
import time
time.sleep(10)
def __call__(self) -> int:
import os
return os.getpid() | @serve.deployment
class SleepyPid:
def __init__(self):
pass
def __call__(self) -> int:
pass | 4 | 0 | 4 | 1 | 3 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 | 0 | 2 | 2 | 10 | 3 | 7 | 5 | 2 | 0 | 7 | 5 | 2 | 1 | 0 | 0 | 2 |
11,778 | ray-project/ray | doc/source/serve/doc_code/stable_diffusion.py | stable_diffusion.APIIngress | from fastapi.responses import Response
from ray import serve
from ray.serve.handle import DeploymentHandle
from io import BytesIO
@serve.deployment(num_replicas=1)
@serve.ingress(app)
class APIIngress:
def __init__(self, diffusion_model_handle: DeploymentHandle) -> None:
self.handle = diffusion_model_hand... | @serve.deployment(num_replicas=1)
@serve.ingress(app)
class APIIngress:
def __init__(self, diffusion_model_handle: DeploymentHandle) -> None:
pass
@app.get('/imagine', responses={200: {'content': {'image/png': {}}}}, response_class=Response)
async def generate(self, prompt: str, img_size: int=512):... | 6 | 0 | 5 | 1 | 4 | 0 | 1 | 0 | 0 | 3 | 1 | 0 | 2 | 1 | 2 | 2 | 16 | 2 | 14 | 11 | 6 | 0 | 9 | 6 | 6 | 1 | 0 | 0 | 2 |
11,779 | ray-project/ray | doc/source/serve/doc_code/stable_diffusion.py | stable_diffusion.StableDiffusionV2 | from ray import serve
import torch
@serve.deployment(ray_actor_options={'num_gpus': 1}, autoscaling_config={'min_replicas': 0, 'max_replicas': 2})
class StableDiffusionV2:
def __init__(self):
from diffusers import EulerDiscreteScheduler, StableDiffusionPipeline
model_id = 'stabilityai/stable-diffu... | @serve.deployment(ray_actor_options={'num_gpus': 1}, autoscaling_config={'min_replicas': 0, 'max_replicas': 2})
class StableDiffusionV2:
def __init__(self):
pass
def generate(self, prompt: str, img_size: int=512):
pass | 4 | 0 | 9 | 2 | 8 | 0 | 1 | 0 | 0 | 3 | 0 | 0 | 2 | 1 | 2 | 2 | 20 | 4 | 16 | 8 | 12 | 0 | 12 | 8 | 8 | 1 | 0 | 1 | 2 |
11,780 | ray-project/ray | doc/source/tune/doc_code/stopping.py | stopping.CustomStopper | from ray.tune import Stopper
class CustomStopper(Stopper):
def __init__(self):
self.should_stop = False
def __call__(self, trial_id: str, result: dict) -> bool:
if not self.should_stop and result['mean_accuracy'] >= 0.8:
self.should_stop = True
return self.should_stop
... |
class CustomStopper(Stopper):
def __init__(self):
pass
def __call__(self, trial_id: str, result: dict) -> bool:
pass
def stop_all(self) -> bool:
'''Returns whether to stop trials and prevent new ones from starting.'''
pass | 4 | 1 | 3 | 0 | 3 | 0 | 1 | 0.11 | 1 | 3 | 0 | 0 | 3 | 1 | 3 | 3 | 12 | 2 | 9 | 5 | 5 | 1 | 9 | 5 | 5 | 2 | 1 | 1 | 4 |
11,781 | ray-project/ray | doc/source/serve/doc_code/model_composition/streaming_example.py | streaming_example.Caller | from typing import AsyncGenerator, Generator
from ray.serve.handle import DeploymentHandle, DeploymentResponseGenerator
from ray import serve
@serve.deployment
class Caller:
def __init__(self, streamer: DeploymentHandle):
self._streamer = streamer.options(stream=True)
async def __call__(self, limit: ... | @serve.deployment
class Caller:
def __init__(self, streamer: DeploymentHandle):
pass
async def __call__(self, limit: int) -> AsyncGenerator[int, None]:
pass | 4 | 0 | 6 | 0 | 4 | 2 | 2 | 0.33 | 0 | 3 | 2 | 0 | 2 | 1 | 2 | 2 | 13 | 1 | 9 | 6 | 6 | 3 | 7 | 6 | 4 | 2 | 0 | 1 | 3 |
11,782 | ray-project/ray | doc/source/serve/doc_code/model_composition/streaming_example.py | streaming_example.Streamer | from typing import AsyncGenerator, Generator
from ray import serve
@serve.deployment
class Streamer:
def __call__(self, limit: int) -> Generator[int, None, None]:
for i in range(limit):
yield i | @serve.deployment
class Streamer:
def __call__(self, limit: int) -> Generator[int, None, None]:
pass | 3 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 0 | 2 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 2 | 0 | 1 | 2 |
11,783 | ray-project/ray | doc/source/serve/doc_code/http_guide/streaming_example.py | streaming_example.StreamingResponder | from typing import Generator
from ray import serve
from starlette.responses import StreamingResponse
from starlette.requests import Request
import time
@serve.deployment
class StreamingResponder:
def generate_numbers(self, max: int) -> Generator[str, None, None]:
for i in range(max):
yield str... | @serve.deployment
class StreamingResponder:
def generate_numbers(self, max: int) -> Generator[str, None, None]:
pass
def __call__(self, request: Request) -> StreamingResponse:
pass | 4 | 0 | 4 | 0 | 4 | 0 | 2 | 0 | 0 | 3 | 0 | 0 | 2 | 0 | 2 | 2 | 10 | 1 | 9 | 5 | 6 | 0 | 9 | 5 | 6 | 2 | 0 | 1 | 3 |
11,784 | ray-project/ray | doc/source/ray-core/doc_code/streaming_generator.py | streaming_generator.Actor | import ray
@ray.remote
class Actor:
def f(self):
for i in range(5):
yield i | @ray.remote
class Actor:
def f(self):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 2 | 0 | 1 | 2 |
11,785 | ray-project/ray | doc/source/ray-core/doc_code/streaming_generator.py | streaming_generator.AsyncActor | import ray
@ray.remote
class AsyncActor:
async def f(self):
for i in range(5):
yield i | @ray.remote
class AsyncActor:
async def f(self):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 2 | 0 | 1 | 2 |
11,786 | ray-project/ray | doc/source/ray-core/doc_code/streaming_generator.py | streaming_generator.ThreadedActor | import ray
@ray.remote(max_concurrency=5)
class ThreadedActor:
def f(self):
for i in range(5):
yield i | @ray.remote(max_concurrency=5)
class ThreadedActor:
def f(self):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 2 | 0 | 1 | 2 |
11,787 | ray-project/ray | doc/source/serve/doc_code/streaming_tutorial.py | streaming_tutorial.Batchbot | from ray import serve
from queue import Empty, Queue
import asyncio
import asyncio
from queue import Empty
from queue import Empty
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
from typing import List
from ray import serve
from transformers import AutoModelForCausalLM, AutoTokenizer... | @serve.deployment
@serve.ingress(fastapi_app)
class Batchbot:
def __init__(self, model_id: str):
pass
@fastapi_app.post('/')
async def handle_request(self, prompt: str) -> StreamingResponse:
pass
@serve.batch(max_batch_size=2, batch_wait_timeout_s=15)
async def run_model(self, promp... | 10 | 0 | 8 | 0 | 7 | 0 | 2 | 0.07 | 0 | 4 | 1 | 0 | 5 | 4 | 5 | 5 | 49 | 6 | 40 | 19 | 32 | 3 | 35 | 17 | 29 | 5 | 0 | 4 | 11 |
11,788 | ray-project/ray | doc/source/serve/doc_code/streaming_tutorial.py | streaming_tutorial.Chatbot | import asyncio
import asyncio
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
from transformers import AutoModelForCausalLM, AutoTokenizer
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from queue import Empty, Queue
from queue import Empty
from ray import serve
from ray ... | @serve.deployment
@serve.ingress(fastapi_app)
class Chatbot:
def __init__(self, model_id: str):
pass
@fastapi_app.websocket('/')
async def handle_request(self, ws: WebSocket) -> None:
pass
def generate_text(self, prompt: str, streamer: TextIteratorStreamer):
pass
async def... | 8 | 0 | 11 | 1 | 11 | 0 | 3 | 0.05 | 0 | 4 | 0 | 0 | 4 | 4 | 4 | 4 | 52 | 6 | 44 | 17 | 38 | 2 | 36 | 16 | 31 | 4 | 0 | 3 | 10 |
11,789 | ray-project/ray | doc/source/serve/doc_code/streaming_tutorial.py | streaming_tutorial.RawStreamer | from queue import Empty, Queue
class RawStreamer:
def __init__(self, timeout: float=None):
self.q = Queue()
self.stop_signal = None
self.timeout = timeout
def put(self, values):
self.q.put(values)
def end(self):
self.q.put(self.stop_signal)
def __iter__(self)... |
class RawStreamer:
def __init__(self, timeout: float=None):
pass
def put(self, values):
pass
def end(self):
pass
def __iter__(self):
pass
def __next__(self):
pass | 6 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 3 | 0 | 0 | 5 | 3 | 5 | 5 | 21 | 4 | 17 | 10 | 11 | 0 | 16 | 10 | 10 | 2 | 0 | 1 | 6 |
11,790 | ray-project/ray | doc/source/serve/doc_code/streaming_tutorial.py | streaming_tutorial.Textbot | from transformers import AutoModelForCausalLM, AutoTokenizer
import asyncio
from queue import Empty
import asyncio
from ray import serve
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
from ray import serve
from queue import Empty, Queue
from starlette.responses import StreamingRespon... | @serve.deployment
@serve.ingress(fastapi_app)
class Textbot:
def __init__(self, model_id: str):
pass
@fastapi_app.post('/')
def handle_request(self, prompt: str) -> StreamingResponse:
pass
def generate_text(self, prompt: str, streamer: TextIteratorStreamer):
pass
async def... | 8 | 0 | 8 | 0 | 7 | 1 | 2 | 0.18 | 0 | 4 | 0 | 0 | 4 | 4 | 4 | 4 | 38 | 5 | 28 | 13 | 22 | 5 | 23 | 12 | 18 | 4 | 0 | 3 | 7 |
11,791 | ray-project/ray | doc/source/ray-core/doc_code/task_exceptions.py | task_exceptions.MyException | class MyException(Exception):
... | class MyException(Exception):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
11,792 | ray-project/ray | doc/source/ray-core/doc_code/task_exceptions.py | task_exceptions.MyFinalException | class MyFinalException(Exception):
def __init_subclass__(cls, /, *args, **kwargs):
raise TypeError('Cannot subclass this little exception class.') | class MyFinalException(Exception):
def __init_subclass__(cls, /, *args, **kwargs):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 11 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 3 | 0 | 1 |
11,793 | ray-project/ray | doc/source/ray-core/doc_code/task_exceptions.py | task_exceptions.UnserializableException | import threading
class UnserializableException(Exception):
def __init__(self):
self.lock = threading.Lock() |
class UnserializableException(Exception):
def __init__(self):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 11 | 3 | 0 | 3 | 3 | 1 | 0 | 3 | 3 | 1 | 1 | 3 | 0 | 1 |
11,794 | ray-project/ray | doc/source/ray-core/doc_code/tasks_fault_tolerance.py | tasks_fault_tolerance.RandomError | class RandomError(Exception):
pass | class RandomError(Exception):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
11,795 | ray-project/ray | release/tune_tests/fault_tolerance_tests/workloads/terminate_node_aws.py | terminate_node_aws.InstanceKillerActor | import time
import ray
import random
import logging
@ray.remote(num_cpus=0, resources={'head': 0.01})
class InstanceKillerActor:
def __init__(self, probability: float=0.1, time_between_checks_s: float=60, warmup_time_s: float=0) -> None:
self.probability = probability
self.time_between_checks_s = ... | @ray.remote(num_cpus=0, resources={'head': 0.01})
class InstanceKillerActor:
def __init__(self, probability: float=0.1, time_between_checks_s: float=60, warmup_time_s: float=0) -> None:
pass
def start_killing(self):
pass
def kill(self):
pass | 5 | 0 | 17 | 0 | 16 | 0 | 3 | 0 | 0 | 2 | 0 | 0 | 3 | 5 | 3 | 3 | 53 | 3 | 50 | 18 | 41 | 0 | 33 | 13 | 29 | 4 | 0 | 3 | 8 |
11,796 | ray-project/ray | doc/source/serve/doc_code/production_guide/text_ml.py | text_ml.Summarizer | from transformers import pipeline
from ray.serve.handle import DeploymentHandle
from starlette.requests import Request
from typing import Dict
from ray import serve
@serve.deployment
class Summarizer:
def __init__(self, translator: DeploymentHandle):
self.model = pipeline('summarization', model='t5-small'... | @serve.deployment
class Summarizer:
def __init__(self, translator: DeploymentHandle):
pass
def summarize(self, text: str) -> str:
pass
async def __call__(self, http_request: Request) -> str:
pass
def reconfigure(self, config: Dict):
pass | 6 | 0 | 6 | 1 | 5 | 1 | 1 | 0.16 | 0 | 2 | 1 | 0 | 4 | 4 | 4 | 4 | 28 | 6 | 19 | 13 | 14 | 3 | 17 | 13 | 12 | 1 | 0 | 0 | 4 |
11,797 | ray-project/ray | doc/source/serve/doc_code/production_guide/text_ml.py | text_ml.Translator | from transformers import pipeline
from typing import Dict
from ray import serve
@serve.deployment
class Translator:
def __init__(self):
self.language = 'french'
self.model = pipeline('translation_en_to_fr', model='t5-small')
def translate(self, text: str) -> str:
model_output = self.m... | @serve.deployment
class Translator:
def __init__(self):
pass
def translate(self, text: str) -> str:
pass
def reconfigure(self, config: Dict):
pass | 5 | 0 | 7 | 1 | 6 | 0 | 2 | 0 | 0 | 1 | 0 | 0 | 3 | 2 | 3 | 3 | 23 | 5 | 18 | 8 | 14 | 0 | 15 | 8 | 11 | 4 | 0 | 1 | 6 |
11,798 | ray-project/ray | release/air_tests/air_benchmarks/workloads/torch_benchmark.py | torch_benchmark.NeuralNetwork | from torch import nn, distributed
class NeuralNetwork(nn.Module):
def __init__(self):
super(NeuralNetwork, self).__init__()
self.flatten = nn.Flatten()
self.linear_relu_stack = nn.Sequential(nn.Linear(28 * 28, 512), nn.ReLU(), nn.Linear(512, 512), nn.ReLU(), nn.Linear(512, 10), nn.ReLU())
... |
class NeuralNetwork(nn.Module):
def __init__(self):
pass
def forward(self, x):
pass | 3 | 0 | 8 | 0 | 8 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 17 | 1 | 16 | 6 | 13 | 0 | 9 | 6 | 6 | 1 | 1 | 0 | 2 |
11,799 | ray-project/ray | python/ray/experimental/raysort/tracing_utils.py | tracing_utils.ProgressTracker | from typing import List, Tuple
import ray
from ray.experimental.raysort import constants, logging_utils
from ray.util.metrics import Gauge, Histogram
import logging
@ray.remote
class ProgressTracker:
def __init__(self, gauges: List[str], histograms: List[Tuple[str, List[int]]]):
self.counts = {m: 0 for m ... | @ray.remote
class ProgressTracker:
def __init__(self, gauges: List[str], histograms: List[Tuple[str, List[int]]]):
pass
def reset_gauges(self):
pass
def inc(self, metric_name, value=1, echo=False):
pass
def dec(self, metric_name, value=1, echo=False):
pass
def ob... | 7 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 0 | 2 | 0 | 0 | 5 | 3 | 5 | 5 | 37 | 4 | 33 | 16 | 23 | 0 | 29 | 12 | 23 | 3 | 0 | 1 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.