From d133ae5fad51cc60597df0bfc47164c804daa88f Mon Sep 17 00:00:00 2001 From: Vinicius Livramento Date: Wed, 22 May 2024 16:19:31 +0100 Subject: [PATCH] MOD: Rename use_snapshot parameter --- CHANGELOG.md | 5 +++++ databento/live/client.py | 14 +++++++------- databento/live/protocol.py | 10 +++++----- databento/live/session.py | 6 +++--- tests/test_live_client.py | 12 ++++++------ 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f50a9e6..d2ab2ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.35.0 - TBD + +#### Breaking changes +- Rename `use_snapshot` parameter in `Live.subscribe` function to `snapshot` + ## 0.34.1 - 2024-05-21 #### Enhancements diff --git a/databento/live/client.py b/databento/live/client.py index c282407..e802e14 100644 --- a/databento/live/client.py +++ b/databento/live/client.py @@ -379,7 +379,7 @@ def subscribe( symbols: Iterable[str | int] | str | int = ALL_SYMBOLS, stype_in: SType | str = SType.RAW_SYMBOL, start: str | int | None = None, - use_snapshot: bool = False, + snapshot: bool = False, ) -> None: """ Subscribe to a data stream. Multiple subscription requests can be made @@ -402,14 +402,14 @@ def subscribe( The input symbology type to resolve from. start : str or int, optional 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. - use_snapshot: bool, default to 'False' + snapshot: bool, default to 'False' Reserved for future use. Raises ------ ValueError If a dataset is given that does not match the previous datasets. - If use_snapshot is True and start is not None. + If snapshot is True and start is not None. BentoError If creating the connection times out. If creating the connection fails. @@ -423,12 +423,12 @@ def subscribe( """ logger.info( - "subscribing to %s:%s %s start=%s use_snapshot=%s", + "subscribing to %s:%s %s start=%s snapshot=%s", schema, stype_in, symbols, start if start is not None else "now", - use_snapshot, + snapshot, ) dataset = validate_semantic_string(dataset, "dataset") schema = validate_enum(schema, Schema, "schema") @@ -443,7 +443,7 @@ def subscribe( f"because subscriptions to `{self.dataset}` have already been made.", ) - if use_snapshot and start is not None: + if snapshot and start is not None: raise ValueError("Subscription with snapshot expects start=None") self._session.subscribe( @@ -452,7 +452,7 @@ def subscribe( stype_in=stype_in, symbols=symbols, start=start, - use_snapshot=use_snapshot, + snapshot=snapshot, ) def terminate(self) -> None: diff --git a/databento/live/protocol.py b/databento/live/protocol.py index 73cc3b0..ff59134 100644 --- a/databento/live/protocol.py +++ b/databento/live/protocol.py @@ -256,7 +256,7 @@ def subscribe( symbols: Iterable[str | int] | str | int = ALL_SYMBOLS, stype_in: SType | str = SType.RAW_SYMBOL, start: str | int | None = None, - use_snapshot: bool = False, + snapshot: bool = False, ) -> None: """ Send a SubscriptionRequest to the gateway. @@ -272,17 +272,17 @@ def subscribe( start : str or int, optional UNIX nanosecond epoch timestamp to start streaming from. Must be within 24 hours. - use_snapshot: bool, default to 'False' + snapshot: bool, default to 'False' Reserved for future use. """ logger.info( - "sending subscription to %s:%s %s start=%s use_snapshot=%s", + "sending subscription to %s:%s %s start=%s snapshot=%s", schema, stype_in, symbols, start if start is not None else "now", - use_snapshot, + snapshot, ) stype_in_valid = validate_enum(stype_in, SType, "stype_in") @@ -296,7 +296,7 @@ def subscribe( stype_in=stype_in_valid, symbols=batch_str, start=optional_datetime_to_unix_nanoseconds(start), - snapshot=int(use_snapshot), + snapshot=int(snapshot), ) subscription_bytes.append(bytes(message)) diff --git a/databento/live/session.py b/databento/live/session.py index a2a4b0b..3a42400 100644 --- a/databento/live/session.py +++ b/databento/live/session.py @@ -408,7 +408,7 @@ def subscribe( symbols: Iterable[str | int] | str | int = ALL_SYMBOLS, stype_in: SType | str = SType.RAW_SYMBOL, start: str | int | None = None, - use_snapshot: bool = False, + snapshot: bool = False, ) -> None: """ Send a subscription request on the current connection. This will create @@ -427,7 +427,7 @@ def subscribe( start : str or int, optional UNIX nanosecond epoch timestamp to start streaming from. Must be within 24 hours. - use_snapshot: bool, default to 'False' + snapshot: bool, default to 'False' Reserved for future use. """ @@ -444,7 +444,7 @@ def subscribe( symbols=symbols, stype_in=stype_in, start=start, - use_snapshot=use_snapshot, + snapshot=snapshot, ) def resume_reading(self) -> None: diff --git a/tests/test_live_client.py b/tests/test_live_client.py index 14e25ec..03df56e 100644 --- a/tests/test_live_client.py +++ b/tests/test_live_client.py @@ -203,7 +203,7 @@ def test_live_subscription_with_snapshot_failed( schema=Schema.MBO, symbols=ALL_SYMBOLS, start=start, - use_snapshot=True, + snapshot=True, ) # Ensure this was an authentication error @@ -487,7 +487,7 @@ def test_live_subscribe( @pytest.mark.parametrize( - "use_snapshot", + "snapshot", [ False, True, @@ -496,10 +496,10 @@ def test_live_subscribe( def test_live_subscribe_snapshot( live_client: client.Live, mock_live_server: MockLiveServer, - use_snapshot: bool, + snapshot: bool, ) -> None: """ - Test that use_snapshot parameter is assigned correctly. + Test that snapshot parameter is assigned correctly. """ # Arrange @@ -514,7 +514,7 @@ def test_live_subscribe_snapshot( stype_in=stype_in, symbols=symbols, start=start, - use_snapshot=use_snapshot, + snapshot=snapshot, ) # Act @@ -528,7 +528,7 @@ def test_live_subscribe_snapshot( assert message.stype_in == stype_in assert message.symbols == symbols assert message.start == start - assert message.snapshot == str(int(use_snapshot)) + assert message.snapshot == str(int(snapshot)) @pytest.mark.usefixtures("mock_live_server")