Skip to content

Commit 28f97be

Browse files
authored
VER: Release 0.16.1
See release notes.
2 parents f546323 + a7c6f57 commit 28f97be

File tree

10 files changed

+35
-14
lines changed

10 files changed

+35
-14
lines changed

CHANGELOG.md

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

3+
## 0.16.1 - 2023-08-03
4+
5+
#### Bug fixes
6+
- Fixed an issue where starting a `Live` client before subscribing gave an incorrect error message
7+
- Fixed an issue where a `Live` client exception callback would fail when the callback function does not have a `__name__` attribute
8+
39
## 0.16.0 - 2023-07-25
410

511
This release includes updates to the fields in text encodings (CSV and JSON), you can read more about the changes [here](https://databento.com/blog/CSV-JSON-updates-july-2023).

databento/common/data.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def get_deriv_ba_types(level: int) -> list[tuple[str, type | str]]:
8686
]
8787

8888

89-
OHLCV_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
89+
OHLCV_MSG: list[tuple[str, type | str]] = [
90+
*RECORD_HEADER,
9091
("open", np.int64),
9192
("high", np.int64),
9293
("low", np.int64),
@@ -162,7 +163,8 @@ def get_deriv_ba_types(level: int) -> list[tuple[str, type | str]]:
162163
("dummy", "S3"), # 3 byte chararray (Adjustment filler for 8-bytes alignment)
163164
]
164165

165-
IMBALANCE_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
166+
IMBALANCE_MSG: list[tuple[str, type | str]] = [
167+
*RECORD_HEADER,
166168
("ts_recv", np.uint64),
167169
("ref_price", np.int64),
168170
("auction_time", np.uint64),
@@ -186,7 +188,8 @@ def get_deriv_ba_types(level: int) -> list[tuple[str, type | str]]:
186188
("dummy", "S1"),
187189
]
188190

189-
STATISTICS_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
191+
STATISTICS_MSG: list[tuple[str, type | str]] = [
192+
*RECORD_HEADER,
190193
("ts_recv", np.uint64),
191194
("ts_ref", np.uint64),
192195
("price", np.int64),
@@ -404,7 +407,8 @@ def get_deriv_ba_fields(level: int) -> list[str]:
404407
"ind_match_price",
405408
"upper_collar",
406409
"lower_collar",
407-
"paired_qty","total_imbalance_qty",
410+
"paired_qty",
411+
"total_imbalance_qty",
408412
"market_imbalance_qty",
409413
"unpaired_qty",
410414
"auction_type",

databento/live/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ def start(
357357
ValueError
358358
If `start()` is called before a subscription has been made.
359359
If `start()` is called after streaming has already started.
360+
If `start()` is called after the live session has closed.
360361
361362
See Also
362363
--------
@@ -365,6 +366,8 @@ def start(
365366
"""
366367
logger.info("starting live client")
367368
if not self.is_connected():
369+
if self.dataset == "":
370+
raise ValueError("cannot start a live client without a subscription")
368371
raise ValueError("cannot start a live client after it is closed")
369372
if self._session.is_started():
370373
raise ValueError("client is already started")

databento/live/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async def _callback_task(
197197
logger.error(
198198
"error dispatching %s to `%s` callback",
199199
type(record).__name__,
200-
record_callback.__name__,
200+
getattr(record_callback, "__name__", str(record_callback)),
201201
exc_info=exc,
202202
)
203203
if exception_callback is not None:
@@ -527,7 +527,7 @@ async def _connect_task(
527527
f"{AUTH_TIMEOUT_SECONDS} second(s).",
528528
) from None
529529
except ValueError as exc:
530-
raise BentoError(f"User authentication failed: {str(exc)}") from None
530+
raise BentoError(f"User authentication failed: {exc!s}") from None
531531

532532
logger.info(
533533
"authentication with remote gateway completed",

databento/version.py

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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "databento"
3-
version = "0.16.0"
3+
version = "0.16.1"
44
description = "Official Python client library for Databento"
55
authors = [
66
"Databento <[email protected]>",

tests/test_historical_bento.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def test_to_ndarray_with_stub_data_returns_expected_array(
215215
assert isinstance(array, np.ndarray)
216216
assert (
217217
str(array)
218-
== "[(14, 160, 1, 5482, 1609160400000429831, 647784973705, 3722750000000, 1, 128, 0, b'C', b'A', 1609160400000704060, 22993, 1170352)\n (14, 160, 1, 5482, 1609160400000431665, 647784973631, 3723000000000, 1, 128, 0, b'C', b'A', 1609160400000711344, 19621, 1170353)\n (14, 160, 1, 5482, 1609160400000433051, 647784973427, 3723250000000, 1, 128, 0, b'C', b'A', 1609160400000728600, 16979, 1170354)\n (14, 160, 1, 5482, 1609160400000434353, 647784973094, 3723500000000, 1, 128, 0, b'C', b'A', 1609160400000740248, 17883, 1170355)]" # noqa
218+
== "[(14, 160, 1, 5482, 1609160400000429831, 647784973705, 3722750000000, 1, 128, 0, b'C', b'A', 1609160400000704060, 22993, 1170352)\n (14, 160, 1, 5482, 1609160400000431665, 647784973631, 3723000000000, 1, 128, 0, b'C', b'A', 1609160400000711344, 19621, 1170353)\n (14, 160, 1, 5482, 1609160400000433051, 647784973427, 3723250000000, 1, 128, 0, b'C', b'A', 1609160400000728600, 16979, 1170354)\n (14, 160, 1, 5482, 1609160400000434353, 647784973094, 3723500000000, 1, 128, 0, b'C', b'A', 1609160400000740248, 17883, 1170355)]"
219219
)
220220

221221

tests/test_historical_error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_client_error_str_and_repr() -> None:
8080
assert str(error) == "400 Bad Request"
8181
assert (
8282
repr(error)
83-
== "BentoClientError(request_id=None, http_status=400, message=Bad Request)" # noqa
83+
== "BentoClientError(request_id=None, http_status=400, message=Bad Request)"
8484
)
8585

8686

@@ -96,5 +96,5 @@ def test_server_error_str_and_repr() -> None:
9696
assert str(error) == "500 Internal Server Error"
9797
assert (
9898
repr(error)
99-
== "BentoServerError(request_id=None, http_status=500, message=Internal Server Error)" # noqa
99+
== "BentoServerError(request_id=None, http_status=500, message=Internal Server Error)"
100100
)

tests/test_historical_metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_get_dataset_condition_sends_expected_request(
176176
call = mocked_get.call_args.kwargs
177177
assert (
178178
call["url"]
179-
== f"{historical_client.gateway}/v{db.API_VERSION}/metadata.get_dataset_condition" # noqa
179+
== f"{historical_client.gateway}/v{db.API_VERSION}/metadata.get_dataset_condition"
180180
)
181181
assert ("dataset", "GLBX.MDP3") in call["params"]
182182
assert ("start_date", "2018-01-01") in call["params"]
@@ -202,7 +202,7 @@ def test_get_dataset_range_sends_expected_request(
202202
call = mocked_get.call_args.kwargs
203203
assert (
204204
call["url"]
205-
== f"{historical_client.gateway}/v{db.API_VERSION}/metadata.get_dataset_range" # noqa
205+
== f"{historical_client.gateway}/v{db.API_VERSION}/metadata.get_dataset_range"
206206
)
207207
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
208208
assert call["headers"]["accept"] == "application/json"
@@ -274,7 +274,7 @@ def test_get_billable_size_sends_expected_request(
274274
call = mocked_get.call_args.kwargs
275275
assert (
276276
call["url"]
277-
== f"{historical_client.gateway}/v{db.API_VERSION}/metadata.get_billable_size" # noqa
277+
== f"{historical_client.gateway}/v{db.API_VERSION}/metadata.get_billable_size"
278278
)
279279
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
280280
assert call["headers"]["accept"] == "application/json"

tests/test_live_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ def test_live_start_twice(
309309
with pytest.raises(ValueError):
310310
live_client.start()
311311

312+
def test_live_start_before_subscribe(
313+
live_client: client.Live,
314+
) -> None:
315+
"""
316+
Test that calling start() before subscribe raises a ValueError.
317+
"""
318+
with pytest.raises(ValueError):
319+
live_client.start()
312320

313321
@pytest.mark.parametrize(
314322
"schema",

0 commit comments

Comments
 (0)