Skip to content

Commit d133ae5

Browse files
MOD: Rename use_snapshot parameter
1 parent a553324 commit d133ae5

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

CHANGELOG.md

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

3+
## 0.35.0 - TBD
4+
5+
#### Breaking changes
6+
- Rename `use_snapshot` parameter in `Live.subscribe` function to `snapshot`
7+
38
## 0.34.1 - 2024-05-21
49

510
#### Enhancements

databento/live/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def subscribe(
379379
symbols: Iterable[str | int] | str | int = ALL_SYMBOLS,
380380
stype_in: SType | str = SType.RAW_SYMBOL,
381381
start: str | int | None = None,
382-
use_snapshot: bool = False,
382+
snapshot: bool = False,
383383
) -> None:
384384
"""
385385
Subscribe to a data stream. Multiple subscription requests can be made
@@ -402,14 +402,14 @@ def subscribe(
402402
The input symbology type to resolve from.
403403
start : str or int, optional
404404
UNIX nanosecond epoch timestamp to start streaming from (inclusive), based on `ts_event`. Must be within 24 hours except when requesting the mbo or definition schemas.
405-
use_snapshot: bool, default to 'False'
405+
snapshot: bool, default to 'False'
406406
Reserved for future use.
407407
408408
Raises
409409
------
410410
ValueError
411411
If a dataset is given that does not match the previous datasets.
412-
If use_snapshot is True and start is not None.
412+
If snapshot is True and start is not None.
413413
BentoError
414414
If creating the connection times out.
415415
If creating the connection fails.
@@ -423,12 +423,12 @@ def subscribe(
423423
424424
"""
425425
logger.info(
426-
"subscribing to %s:%s %s start=%s use_snapshot=%s",
426+
"subscribing to %s:%s %s start=%s snapshot=%s",
427427
schema,
428428
stype_in,
429429
symbols,
430430
start if start is not None else "now",
431-
use_snapshot,
431+
snapshot,
432432
)
433433
dataset = validate_semantic_string(dataset, "dataset")
434434
schema = validate_enum(schema, Schema, "schema")
@@ -443,7 +443,7 @@ def subscribe(
443443
f"because subscriptions to `{self.dataset}` have already been made.",
444444
)
445445

446-
if use_snapshot and start is not None:
446+
if snapshot and start is not None:
447447
raise ValueError("Subscription with snapshot expects start=None")
448448

449449
self._session.subscribe(
@@ -452,7 +452,7 @@ def subscribe(
452452
stype_in=stype_in,
453453
symbols=symbols,
454454
start=start,
455-
use_snapshot=use_snapshot,
455+
snapshot=snapshot,
456456
)
457457

458458
def terminate(self) -> None:

databento/live/protocol.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def subscribe(
256256
symbols: Iterable[str | int] | str | int = ALL_SYMBOLS,
257257
stype_in: SType | str = SType.RAW_SYMBOL,
258258
start: str | int | None = None,
259-
use_snapshot: bool = False,
259+
snapshot: bool = False,
260260
) -> None:
261261
"""
262262
Send a SubscriptionRequest to the gateway.
@@ -272,17 +272,17 @@ def subscribe(
272272
start : str or int, optional
273273
UNIX nanosecond epoch timestamp to start streaming from. Must be
274274
within 24 hours.
275-
use_snapshot: bool, default to 'False'
275+
snapshot: bool, default to 'False'
276276
Reserved for future use.
277277
278278
"""
279279
logger.info(
280-
"sending subscription to %s:%s %s start=%s use_snapshot=%s",
280+
"sending subscription to %s:%s %s start=%s snapshot=%s",
281281
schema,
282282
stype_in,
283283
symbols,
284284
start if start is not None else "now",
285-
use_snapshot,
285+
snapshot,
286286
)
287287

288288
stype_in_valid = validate_enum(stype_in, SType, "stype_in")
@@ -296,7 +296,7 @@ def subscribe(
296296
stype_in=stype_in_valid,
297297
symbols=batch_str,
298298
start=optional_datetime_to_unix_nanoseconds(start),
299-
snapshot=int(use_snapshot),
299+
snapshot=int(snapshot),
300300
)
301301
subscription_bytes.append(bytes(message))
302302

databento/live/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def subscribe(
408408
symbols: Iterable[str | int] | str | int = ALL_SYMBOLS,
409409
stype_in: SType | str = SType.RAW_SYMBOL,
410410
start: str | int | None = None,
411-
use_snapshot: bool = False,
411+
snapshot: bool = False,
412412
) -> None:
413413
"""
414414
Send a subscription request on the current connection. This will create
@@ -427,7 +427,7 @@ def subscribe(
427427
start : str or int, optional
428428
UNIX nanosecond epoch timestamp to start streaming from. Must be
429429
within 24 hours.
430-
use_snapshot: bool, default to 'False'
430+
snapshot: bool, default to 'False'
431431
Reserved for future use.
432432
433433
"""
@@ -444,7 +444,7 @@ def subscribe(
444444
symbols=symbols,
445445
stype_in=stype_in,
446446
start=start,
447-
use_snapshot=use_snapshot,
447+
snapshot=snapshot,
448448
)
449449

450450
def resume_reading(self) -> None:

tests/test_live_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def test_live_subscription_with_snapshot_failed(
203203
schema=Schema.MBO,
204204
symbols=ALL_SYMBOLS,
205205
start=start,
206-
use_snapshot=True,
206+
snapshot=True,
207207
)
208208

209209
# Ensure this was an authentication error
@@ -487,7 +487,7 @@ def test_live_subscribe(
487487

488488

489489
@pytest.mark.parametrize(
490-
"use_snapshot",
490+
"snapshot",
491491
[
492492
False,
493493
True,
@@ -496,10 +496,10 @@ def test_live_subscribe(
496496
def test_live_subscribe_snapshot(
497497
live_client: client.Live,
498498
mock_live_server: MockLiveServer,
499-
use_snapshot: bool,
499+
snapshot: bool,
500500
) -> None:
501501
"""
502-
Test that use_snapshot parameter is assigned correctly.
502+
Test that snapshot parameter is assigned correctly.
503503
"""
504504
# Arrange
505505

@@ -514,7 +514,7 @@ def test_live_subscribe_snapshot(
514514
stype_in=stype_in,
515515
symbols=symbols,
516516
start=start,
517-
use_snapshot=use_snapshot,
517+
snapshot=snapshot,
518518
)
519519

520520
# Act
@@ -528,7 +528,7 @@ def test_live_subscribe_snapshot(
528528
assert message.stype_in == stype_in
529529
assert message.symbols == symbols
530530
assert message.start == start
531-
assert message.snapshot == str(int(use_snapshot))
531+
assert message.snapshot == str(int(snapshot))
532532

533533

534534
@pytest.mark.usefixtures("mock_live_server")

0 commit comments

Comments
 (0)