Skip to content

Commit

Permalink
MOD: Deprecate batch packaging for Python client
Browse files Browse the repository at this point in the history
  • Loading branch information
nmacholl committed Nov 11, 2024
1 parent 05ac86b commit 1583310
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This release adds support for Python v3.13.
#### Enhancements
- Added support for Python 3.13

#### Deprecations
- Deprecated `packaging` parameter for `Historical.batch.submit_job` which will be removed in a future release

## 0.44.1 - 2024-10-29

#### Enhancements
Expand Down
13 changes: 12 additions & 1 deletion databento/historical/api/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from databento.common.enums import Delivery
from databento.common.enums import Packaging
from databento.common.enums import SplitDuration
from databento.common.error import BentoDeprecationWarning
from databento.common.error import BentoError
from databento.common.error import BentoHttpError
from databento.common.error import BentoWarning
Expand All @@ -39,6 +40,7 @@
from databento.common.parsing import optional_values_list_to_string
from databento.common.parsing import symbols_list_to_list
from databento.common.publishers import Dataset
from databento.common.types import Default
from databento.common.validation import validate_enum
from databento.common.validation import validate_path
from databento.common.validation import validate_semantic_string
Expand Down Expand Up @@ -73,7 +75,7 @@ def submit_job(
split_symbols: bool = False,
split_duration: SplitDuration | str = "day",
split_size: int | None = None,
packaging: Packaging | str | None = None,
packaging: Packaging | str | None = Default(None), # type: ignore [assignment]
delivery: Delivery | str = "download",
stype_in: SType | str = "raw_symbol",
stype_out: SType | str = "instrument_id",
Expand Down Expand Up @@ -148,6 +150,15 @@ def submit_job(
"""
stype_in_valid = validate_enum(stype_in, SType, "stype_in")
symbols_list = symbols_list_to_list(symbols, stype_in_valid)

if isinstance(packaging, Default):
packaging = packaging.value
else:
warnings.warn(
message="The `packaging` parameter is deprecated and will be removed in a future release.",
category=BentoDeprecationWarning,
)

data: dict[str, object | None] = {
"dataset": validate_semantic_string(dataset, "dataset"),
"start": datetime_to_string(start),
Expand Down
28 changes: 15 additions & 13 deletions tests/test_historical_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import databento as db
import pytest
import requests
from databento.common.error import BentoDeprecationWarning
from databento.historical.client import Historical


Expand Down Expand Up @@ -63,19 +64,20 @@ def test_batch_submit_job_sends_expected_request(
monkeypatch.setattr(requests, "post", mocked_post := MagicMock())

# Act
historical_client.batch.submit_job(
dataset="GLBX.MDP3",
symbols="ESH1",
schema="trades",
start="2020-12-28T12:00",
end="2020-12-29",
encoding="csv",
split_duration="day",
split_size=10000000000,
packaging="none",
delivery="download",
compression="zstd",
)
with pytest.warns(BentoDeprecationWarning):
historical_client.batch.submit_job(
dataset="GLBX.MDP3",
symbols="ESH1",
schema="trades",
start="2020-12-28T12:00",
end="2020-12-29",
encoding="csv",
split_duration="day",
split_size=10000000000,
packaging="none",
delivery="download",
compression="zstd",
)

# Assert
call = mocked_post.call_args.kwargs
Expand Down

0 comments on commit 1583310

Please sign in to comment.