Skip to content

Commit 3544448

Browse files
committed
DEL: Remove unused received variant
1 parent 88e367b commit 3544448

File tree

6 files changed

+58
-10
lines changed

6 files changed

+58
-10
lines changed

CHANGELOG.md

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

3-
## 0.60.1 - TBD
3+
## 0.61.0 - TBD
4+
5+
#### Breaking changes
6+
- Modified the `states` parameter in `batch.list_jobs()`
47

58
#### Enhancements
9+
- Added `JobState` enum
610
- Added export of `SystemCode` and `ErrorCode` from `databento_dbn` to the root `databento` package
711

812
#### Bug fixes
@@ -58,8 +62,8 @@ Python
5862
- "ICE Futures Europe (Financials)" renamed to "ICE Europe Financials"
5963
- "ICE Futures Europe (Commodities)" renamed to "ICE Europe Commodities"
6064
- Upgraded `databento-dbn` to 0.36.1
61-
- Fixed setting of ts_out property of DbnFsm based on decoded metadata. This
62-
was preventing ts_out from being correctly decoded in the Python DBNDecoder
65+
- Fixed setting of `ts_out` property of DbnFsm based on decoded metadata. This
66+
was preventing `ts_out` from being correctly decoded in the Python DBNDecoder
6367
- Fixed decoding of `ts_out` with first records in DBNDecoder
6468

6569
#### Bug fixes

databento/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from databento.common.enums import Delivery
5858
from databento.common.enums import FeedMode
5959
from databento.common.enums import HistoricalGateway
60+
from databento.common.enums import JobState
6061
from databento.common.enums import Packaging
6162
from databento.common.enums import ReconnectPolicy
6263
from databento.common.enums import RecordFlags
@@ -113,6 +114,7 @@
113114
"InstrumentClass",
114115
"InstrumentDefMsg",
115116
"InstrumentMap",
117+
"JobState",
116118
"Live",
117119
"MBOMsg",
118120
"MBP1Msg",

databento/common/enums.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def coercible(enum_type: type[M]) -> type[M]:
2828
Parameters
2929
----------
3030
enum_type : EnumMeta
31-
The deocrated Enum type.
31+
The decorated Enum type.
3232
3333
Returns
3434
-------
@@ -167,7 +167,7 @@ class RollRule(StringyMixin, str, Enum):
167167
"""
168168

169169
VOLUME = "volume"
170-
OPEN_INTEREST = "open_interst"
170+
OPEN_INTEREST = "open_interest"
171171
CALENDAR = "calendar"
172172

173173

@@ -241,3 +241,16 @@ class PriceType(StringyMixin, str, Enum):
241241
FIXED = "fixed"
242242
FLOAT = "float"
243243
DECIMAL = "decimal"
244+
245+
246+
@unique
247+
@coercible
248+
class JobState(StringyMixin, str, Enum):
249+
"""
250+
Represents the different states for batch jobs.
251+
"""
252+
253+
QUEUED = "queued"
254+
PROCESSING = "processing"
255+
DONE = "done"
256+
EXPIRED = "expired"

databento/common/parsing.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from databento_dbn import SType
1818

1919
from databento.common.constants import ALL_SYMBOLS
20+
from databento.common.enums import JobState
21+
from databento.common.validation import validate_enum
2022
from databento.common.validation import validate_smart_symbol
2123

2224

@@ -64,6 +66,31 @@ def optional_values_list_to_string(
6466
return values_list_to_string(values)
6567

6668

69+
def optional_states_list_to_string(
70+
states: Iterable[JobState | str] | JobState | str | None,
71+
) -> str | None:
72+
"""
73+
Concatenate a states string or iterable of string states (if not None).
74+
75+
Parameters
76+
----------
77+
states : Iterable[JobState | str] | JobState | str | None
78+
The states to concatenate.
79+
80+
Returns
81+
-------
82+
str or `None`
83+
84+
"""
85+
if states is None:
86+
return None
87+
elif isinstance(states, (JobState, str)):
88+
return str(states)
89+
else:
90+
states_list = [validate_enum(state, JobState, "state").value for state in states]
91+
return ",".join(states_list)
92+
93+
6794
def optional_string_to_list(
6895
value: Iterable[str] | str | None,
6996
) -> Iterable[str] | list[str] | None:

databento/historical/api/batch.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from databento.common import API_VERSION
3030
from databento.common.constants import HTTP_STREAMING_READ_SIZE
3131
from databento.common.enums import Delivery
32+
from databento.common.enums import JobState
3233
from databento.common.enums import SplitDuration
3334
from databento.common.error import BentoError
3435
from databento.common.error import BentoHttpError
@@ -37,7 +38,7 @@
3738
from databento.common.http import check_http_error
3839
from databento.common.parsing import datetime_to_string
3940
from databento.common.parsing import optional_datetime_to_string
40-
from databento.common.parsing import optional_values_list_to_string
41+
from databento.common.parsing import optional_states_list_to_string
4142
from databento.common.parsing import symbols_list_to_list
4243
from databento.common.publishers import Dataset
4344
from databento.common.validation import validate_enum
@@ -185,7 +186,7 @@ def submit_job(
185186

186187
def list_jobs(
187188
self,
188-
states: Iterable[str] | str = "received,queued,processing,done",
189+
states: Iterable[JobState | str] | JobState | str | None = "queued,processing,done",
189190
since: pd.Timestamp | datetime | date | str | int | None = None,
190191
) -> list[dict[str, Any]]:
191192
"""
@@ -197,8 +198,9 @@ def list_jobs(
197198
198199
Parameters
199200
----------
200-
states : Iterable[str] or str, optional {'received', 'queued', 'processing', 'done', 'expired'} # noqa
201+
states : Iterable[JobState | str] or JobState or str, optional {'queued', 'processing', 'done', 'expired'} # noqa
201202
The filter for jobs states as an iterable of comma separated values.
203+
Defaults to all except 'expired'.
202204
since : pd.Timestamp, datetime, date, str, or int, optional
203205
The filter for timestamp submitted (will not include jobs prior to this).
204206
@@ -209,7 +211,7 @@ def list_jobs(
209211
210212
"""
211213
params: list[tuple[str, str | None]] = [
212-
("states", optional_values_list_to_string(states)),
214+
("states", optional_states_list_to_string(states)),
213215
("since", optional_datetime_to_string(since)),
214216
]
215217

tests/test_historical_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_batch_list_jobs_sends_expected_request(
125125
assert call["headers"]["accept"] == "application/json"
126126
assert all(v in call["headers"]["user-agent"] for v in ("Databento/", "Python/"))
127127
assert call["params"] == [
128-
("states", "received,queued,processing,done"),
128+
("states", "queued,processing,done"),
129129
("since", "2022-01-01"),
130130
]
131131
assert call["timeout"] == (100, 100)

0 commit comments

Comments
 (0)