Skip to content

Commit fc754bf

Browse files
committed
REF: Rename Bento to DBNStore
1 parent 91e8615 commit fc754bf

19 files changed

+134
-131
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.10.0 - TBD
4+
- Renamed `Bento` class to `DBNStore`
5+
36
## 0.9.0 - 2023-03-10
47
- Removed `record_count` property from Bento class
58
- Fixed bug in `Bento` where invalid metadata would prevent iteration

databento/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33
from databento.common import utility
4-
from databento.common.bento import Bento
4+
from databento.common.dbnstore import DBNStore
55
from databento.common.enums import (
66
Compression,
77
Dataset,
@@ -31,7 +31,7 @@
3131

3232
__all__ = [
3333
"API_VERSION",
34-
"Bento",
34+
"DBNStore",
3535
"BentoClientError",
3636
"BentoError",
3737
"BentoHttpError",
@@ -58,4 +58,4 @@
5858

5959
# Convenience imports
6060
enable_logging = utility.enable_logging
61-
from_dbn = Bento.from_file
61+
from_dbn = DBNStore.from_file
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def is_dbn(reader: IO[bytes]) -> bool:
8383

8484

8585
class DataSource(abc.ABC):
86-
"""Abstract base class for backing Bento classes with data."""
86+
"""Abstract base class for backing DBNStore instances with data."""
8787

8888
def __init__(self, source: object) -> None:
8989
...
@@ -103,7 +103,7 @@ def reader(self) -> IO[bytes]:
103103

104104
class FileDataSource(DataSource):
105105
"""
106-
A file-backed data source for a Bento object.
106+
A file-backed data source for a DBNStore object.
107107
108108
Attributes
109109
----------
@@ -181,7 +181,7 @@ def reader(self) -> IO[bytes]:
181181

182182
class MemoryDataSource(DataSource):
183183
"""
184-
A memory-backed data source for a Bento object.
184+
A memory-backed data source for a DBNStore object.
185185
186186
Attributes
187187
----------
@@ -243,7 +243,7 @@ def reader(self) -> IO[bytes]:
243243
return self.__buffer
244244

245245

246-
class Bento:
246+
class DBNStore:
247247
"""
248248
A container for Databento Binary Encoding (DBN) data.
249249
@@ -576,7 +576,7 @@ def raw(self) -> bytes:
576576
577577
See Also
578578
--------
579-
Bento.reader
579+
DBNStore.reader
580580
581581
"""
582582
return self._data_source.reader.read()
@@ -592,7 +592,7 @@ def reader(self) -> IO[bytes]:
592592
593593
See Also
594594
--------
595-
Bento.raw
595+
DBNStore.raw
596596
597597
"""
598598
if self.compression == Compression.ZSTD:
@@ -704,7 +704,7 @@ def symbols(self) -> List[str]:
704704
return self._metadata["symbols"]
705705

706706
@classmethod
707-
def from_file(cls, path: Union[PathLike[str], str]) -> "Bento":
707+
def from_file(cls, path: Union[PathLike[str], str]) -> "DBNStore":
708708
"""
709709
Load the data from a DBN file at the given path.
710710
@@ -715,7 +715,7 @@ def from_file(cls, path: Union[PathLike[str], str]) -> "Bento":
715715
716716
Returns
717717
-------
718-
Bento
718+
DBNStore
719719
720720
Raises
721721
------
@@ -726,7 +726,7 @@ def from_file(cls, path: Union[PathLike[str], str]) -> "Bento":
726726
return cls(FileDataSource(path))
727727

728728
@classmethod
729-
def from_bytes(cls, data: bytes) -> "Bento":
729+
def from_bytes(cls, data: bytes) -> "DBNStore":
730730
"""
731731
Load the data from a raw bytes.
732732
@@ -737,7 +737,7 @@ def from_bytes(cls, data: bytes) -> "Bento":
737737
738738
Returns
739739
-------
740-
Bento
740+
DBNStore
741741
742742
Raises
743743
------
@@ -771,7 +771,7 @@ def request_full_definitions(
771771
self,
772772
client: "Historical",
773773
path: Optional[Union[Path, str]] = None,
774-
) -> "Bento":
774+
) -> "DBNStore":
775775
"""
776776
Request full instrument definitions based on the metadata properties.
777777
@@ -782,11 +782,11 @@ def request_full_definitions(
782782
client : Historical
783783
The historical client to use for the request (contains the API key).
784784
path : Path or str, optional
785-
The path to stream the data to on disk (will then return a `Bento`).
785+
The path to stream the data to on disk (will then return a `DBNStore`).
786786
787787
Returns
788788
-------
789-
Bento
789+
DBNStore
790790
791791
Warnings
792792
--------

databento/historical/api/timeseries.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import List, Optional, Tuple, Union
88

99
import pandas as pd
10-
from databento.common.bento import Bento
10+
from databento.common.dbnstore import DBNStore
1111
from databento.common.deprecated import deprecated
1212
from databento.common.enums import Compression, Dataset, Encoding, Schema, SType
1313
from databento.common.parsing import datetime_to_string, optional_symbols_list_to_string
@@ -38,7 +38,7 @@ def stream(
3838
stype_out: Union[SType, str] = "product_id",
3939
limit: Optional[int] = None,
4040
path: Optional[Union[PathLike[str], str]] = None,
41-
) -> Bento:
41+
) -> DBNStore:
4242
"""
4343
The `.stream` method is deprecated and will be removed in a future version.
4444
The method has been renamed to `.get_range`, which you can now use.
@@ -66,7 +66,7 @@ def get_range(
6666
stype_out: Union[SType, str] = "product_id",
6767
limit: Optional[int] = None,
6868
path: Optional[Union[PathLike[str], str]] = None,
69-
) -> Bento:
69+
) -> DBNStore:
7070
"""
7171
Request a historical time series data stream from Databento.
7272
@@ -101,11 +101,11 @@ def get_range(
101101
limit : int, optional
102102
The maximum number of records to return. If `None` then no limit.
103103
path : PathLike or str, optional
104-
The path to stream the data to on disk (will then return a `Bento`).
104+
The path to stream the data to on disk (will then return a `DBNStore`).
105105
106106
Returns
107107
-------
108-
Bento
108+
DBNStore
109109
110110
Notes
111111
-----
@@ -157,9 +157,9 @@ def get_range(
157157

158158
if path is not None:
159159
writer.close()
160-
return Bento.from_file(path)
160+
return DBNStore.from_file(path)
161161
writer.seek(0) # rewind for read
162-
return Bento.from_bytes(writer.read())
162+
return DBNStore.from_bytes(writer.read())
163163

164164
@deprecated
165165
async def stream_async(
@@ -173,7 +173,7 @@ async def stream_async(
173173
stype_out: Union[SType, str] = "product_id",
174174
limit: Optional[int] = None,
175175
path: Optional[Union[PathLike[str], str]] = None,
176-
) -> Bento:
176+
) -> DBNStore:
177177
"""
178178
The `.stream_async` method is deprecated and will be removed in a future
179179
version.
@@ -202,7 +202,7 @@ async def get_range_async(
202202
stype_out: Union[SType, str] = "product_id",
203203
limit: Optional[int] = None,
204204
path: Optional[Union[PathLike[str], str]] = None,
205-
) -> Bento:
205+
) -> DBNStore:
206206
"""
207207
Asynchronously request a historical time series data stream from Databento.
208208
@@ -237,11 +237,11 @@ async def get_range_async(
237237
limit : int, optional
238238
The maximum number of records to return. If `None` then no limit.
239239
path : PathLike or str, optional
240-
The path to stream the data to on disk (will then return a `Bento`).
240+
The path to stream the data to on disk (will then return a `DBNStore`).
241241
242242
Returns
243243
-------
244-
Bento
244+
DBNStore
245245
246246
Notes
247247
-----
@@ -292,9 +292,9 @@ async def get_range_async(
292292

293293
if path is not None:
294294
writer.close()
295-
return Bento.from_file(path)
295+
return DBNStore.from_file(path)
296296
writer.seek(0) # rewind for read
297-
return Bento.from_bytes(writer.read())
297+
return DBNStore.from_bytes(writer.read())
298298

299299
def _pre_check_data_size( # noqa (prefer not to make static)
300300
self,

databento/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.9.0"
1+
__version__ = "0.10.0"

examples/historical_timeseries_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import asyncio
22
from pprint import pprint
33

4-
from databento import Bento, Historical
4+
from databento import DBNStore, Historical
55

66

77
async def example_get_range_async() -> None:
88
key = "YOUR_API_KEY"
99
client = Historical(key=key)
1010

11-
data: Bento = await client.timeseries.get_range_async(
11+
data: DBNStore = await client.timeseries.get_range_async(
1212
dataset="GLBX.MDP3",
1313
symbols=["ESM2"],
1414
schema="mbo",

examples/historical_timeseries_disk_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pprint import pprint
22

3-
from databento import Bento, Historical
3+
from databento import DBNStore, Historical
44

55

66
if __name__ == "__main__":
@@ -10,7 +10,7 @@
1010
path = "my_data.dbn"
1111

1212
# Execute request through client
13-
data: Bento = client.timeseries.get_range(
13+
data: DBNStore = client.timeseries.get_range(
1414
dataset="GLBX.MDP3",
1515
symbols=["ESM2"],
1616
schema="mbo",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import datetime
22

3-
from databento import Bento
3+
from databento import DBNStore
44

55

66
if __name__ == "__main__":
77
ts_start = datetime.datetime.utcnow()
88

99
# Can load from file path (if exists)
10-
data = Bento.from_file(path="my_data.dbn")
10+
data = DBNStore.from_file(path="my_data.dbn")
1111

1212
print(data.to_df())
1313
print(datetime.datetime.utcnow() - ts_start)

examples/historical_timeseries_replay.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from databento import Bento, Historical
1+
from databento import DBNStore, Historical
22

33

44
if __name__ == "__main__":
55
key = "YOUR_API_KEY"
66
client = Historical(key=key)
77

8-
data: Bento = client.timeseries.get_range(
8+
data: DBNStore = client.timeseries.get_range(
99
dataset="GLBX.MDP3",
1010
symbols=["ESM2"],
1111
schema="trades",

examples/historical_timeseries_to_df.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from pprint import pprint
22

3-
from databento import Bento, Historical
3+
from databento import DBNStore, Historical
44

55

66
if __name__ == "__main__":
77
key = "YOUR_API_KEY"
88
client = Historical(key=key)
99

10-
data: Bento = client.timeseries.get_range(
10+
data: DBNStore = client.timeseries.get_range(
1111
dataset="GLBX.MDP3",
1212
symbols=["ESM2"],
1313
schema="trades",

0 commit comments

Comments
 (0)