mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00

* formatting * format util * format release * format rllib/agents * format rllib/env * format rllib/execution * format rllib/evaluation * format rllib/examples * format rllib/policy * format rllib utils and tests * format streaming * more formatting * update requirements files * fix rllib type checking * updates * update * fix circular import * Update python/ray/tests/test_runtime_env.py * noqa
34 lines
898 B
Python
34 lines
898 B
Python
class Record:
|
|
"""Data record in data stream"""
|
|
|
|
def __init__(self, value):
|
|
self.value = value
|
|
self.stream = None
|
|
|
|
def __repr__(self):
|
|
return "Record({})".format(self.value)
|
|
|
|
def __eq__(self, other):
|
|
if type(self) is type(other):
|
|
return (self.stream, self.value) == (other.stream, other.value)
|
|
return False
|
|
|
|
def __hash__(self):
|
|
return hash((self.stream, self.value))
|
|
|
|
|
|
class KeyRecord(Record):
|
|
"""Data record in a keyed data stream"""
|
|
|
|
def __init__(self, key, value):
|
|
super().__init__(value)
|
|
self.key = key
|
|
|
|
def __eq__(self, other):
|
|
if type(self) is type(other):
|
|
return (self.stream, self.key, self.value) ==\
|
|
(other.stream, other.key, other.value)
|
|
return False
|
|
|
|
def __hash__(self):
|
|
return hash((self.stream, self.key, self.value))
|