Skip to content

Commit 74d83e9

Browse files
committed
VER: Release Python client 0.5.0
1 parent d911f71 commit 74d83e9

File tree

11 files changed

+71
-21
lines changed

11 files changed

+71
-21
lines changed

CHANGELOG.md

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

3-
## 0.5.0 - TBD
4-
- Fixed columns for derived data schemas (dropped `channel_id`)
3+
## 0.5.0 - 2022-11-07
4+
- Fixed dataframe columns for derived data schemas (dropped `channel_id`)
55
- Fixed `batch.submit_job` requests for `dbz` encoding
66
- Updated `quickstart.ipynb` jupyter notebook
77

databento/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
from typing import Optional
22

33
from databento.common.bento import Bento, FileBento, MemoryBento
4+
from databento.common.enums import (
5+
Compression,
6+
Dataset,
7+
Delivery,
8+
Encoding,
9+
FeedMode,
10+
Flags,
11+
HistoricalGateway,
12+
LiveGateway,
13+
Packaging,
14+
RollRule,
15+
Schema,
16+
SplitDuration,
17+
SType,
18+
SymbologyResolution,
19+
)
420
from databento.historical.api import API_VERSION
521
from databento.historical.client import Historical
622
from databento.historical.error import (
@@ -19,9 +35,23 @@
1935
"BentoError",
2036
"BentoHttpError",
2137
"BentoServerError",
38+
"Compression",
39+
"Dataset",
40+
"Delivery",
41+
"Encoding",
42+
"FeedMode",
2243
"FileBento",
44+
"Flags",
2345
"Historical",
46+
"HistoricalGateway",
47+
"LiveGateway",
2448
"MemoryBento",
49+
"Packaging",
50+
"RollRule",
51+
"Schema",
52+
"SplitDuration",
53+
"SType",
54+
"SymbologyResolution",
2555
]
2656

2757
# Set to either 'DEBUG' or 'INFO', controls console logging

databento/common/parsing.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def maybe_symbols_list_to_string(
141141
raise TypeError(f"invalid symbols type, was {type(symbols)}")
142142

143143

144-
def maybe_date_to_string(
145-
value: Optional[Union[date, str]],
146-
) -> Optional[str]:
144+
def maybe_date_to_string(value: Optional[Union[date, str]]) -> Optional[str]:
147145
"""
148146
Return a valid date string from the given value (if not None).
149147
@@ -163,8 +161,25 @@ def maybe_date_to_string(
163161
return str(pd.to_datetime(value).date())
164162

165163

164+
def datetime_to_string(value: Union[pd.Timestamp, date, str, int]) -> str:
165+
"""
166+
Return a valid datetime string from the given value.
167+
168+
Parameters
169+
----------
170+
value : pd.Timestamp or date or str
171+
The value to parse.
172+
173+
Returns
174+
-------
175+
str
176+
177+
"""
178+
return str(pd.to_datetime(value)).replace(" ", "T")
179+
180+
166181
def maybe_datetime_to_string(
167-
value: Optional[Union[pd.Timestamp, date, str]],
182+
value: Optional[Union[pd.Timestamp, date, str, int]],
168183
) -> Optional[str]:
169184
"""
170185
Return a valid datetime string from the given value (if not None).
@@ -182,7 +197,7 @@ def maybe_datetime_to_string(
182197
if value is None:
183198
return None
184199

185-
return str(pd.to_datetime(value)).replace(" ", "T")
200+
return datetime_to_string(value)
186201

187202

188203
def parse_flags(value: int, apply_bitmask: bool = False) -> List[str]:

databento/historical/api/batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def submit_job(
4848
limit: Optional[int] = None,
4949
) -> Dict[str, Any]:
5050
"""
51-
Request a new time series data batch job from Databento.
51+
Request a new time series data batch download from Databento.
5252
5353
Makes a `POST /batch.submit_job` HTTP request.
5454
@@ -94,7 +94,7 @@ def submit_job(
9494
Returns
9595
-------
9696
Dict[str, Any]
97-
The job info for submitted batch download request.
97+
The job info for batch download request.
9898
9999
Warnings
100100
--------

databento/historical/http.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from databento.common.enums import Dataset, Schema, SType
1212
from databento.common.logging import log_info
1313
from databento.common.parsing import (
14+
datetime_to_string,
1415
enum_or_str_lowercase,
15-
maybe_datetime_to_string,
1616
maybe_symbols_list_to_string,
1717
)
1818
from databento.historical.error import BentoClientError, BentoServerError
@@ -52,8 +52,8 @@ def _timeseries_params(
5252
) -> List[Tuple[str, Optional[str]]]:
5353
params: List[Tuple[str, Any]] = [
5454
("dataset", enum_or_str_lowercase(dataset, "dataset")),
55-
("start", maybe_datetime_to_string(start)),
56-
("end", maybe_datetime_to_string(end)),
55+
("start", datetime_to_string(start)),
56+
("end", datetime_to_string(end)),
5757
("symbols", maybe_symbols_list_to_string(symbols) or "*"),
5858
("schema", schema.value),
5959
("stype_in", stype_in.value),
@@ -83,7 +83,7 @@ def _check_api_key(self) -> None:
8383
def _get(
8484
self,
8585
url: str,
86-
params: Optional[List[Tuple[str, str]]] = None,
86+
params: Optional[List[Tuple[str, Optional[str]]]] = None,
8787
basic_auth: bool = False,
8888
) -> Response:
8989
self._check_api_key()
@@ -103,7 +103,7 @@ def _get(
103103
async def _get_async(
104104
self,
105105
url: str,
106-
params: Optional[List[Tuple[str, str]]] = None,
106+
params: Optional[List[Tuple[str, Optional[str]]]] = None,
107107
basic_auth: bool = False,
108108
) -> ClientResponse:
109109
self._check_api_key()
@@ -123,7 +123,7 @@ async def _get_async(
123123
def _post(
124124
self,
125125
url: str,
126-
params: Optional[List[Tuple[str, str]]] = None,
126+
params: Optional[List[Tuple[str, Optional[str]]]] = None,
127127
basic_auth: bool = False,
128128
) -> Response:
129129
self._check_api_key()
@@ -143,7 +143,7 @@ def _post(
143143
def _stream(
144144
self,
145145
url: str,
146-
params: List[Tuple[str, str]],
146+
params: List[Tuple[str, Optional[str]]],
147147
basic_auth: bool,
148148
bento: Bento,
149149
) -> None:

requirements_dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pytest>=7.1.2
2-
pytest-mock>=3.8.1
1+
pytest>=7.2.0
2+
pytest-mock>=3.10.0
33
types-requests

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ ignore = C101, E203, W503
1414
# C101: Coding magic comment not found (not required as utf-8 is the default for python3).
1515
# E203: whitespace before ':' (conflicts with Black)
1616
# W503: in error will be amended by flake8 soon (https://www.flake8rules.com/rules/W503.html)
17+
18+
[tool:pytest]
19+
testpaths = tests
20+
asyncio_mode = auto

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"Programming Language :: Python :: 3.8",
5757
"Programming Language :: Python :: 3.9",
5858
"Programming Language :: Python :: 3.10",
59+
"Programming Language :: Python :: 3.11",
5960
"Topic :: Software Development :: Libraries",
6061
"Topic :: Software Development :: Libraries :: Python Modules",
6162
"Topic :: Office/Business :: Financial",

tests/test_historical_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class TestHistoricalBatch:
10-
def setup(self) -> None:
10+
def setup_method(self) -> None:
1111
key = "DUMMY_API_KEY"
1212
self.client = db.Historical(key=key)
1313

tests/test_historical_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class TestHistoricalMetadata:
12-
def setup(self) -> None:
12+
def setup_method(self) -> None:
1313
key = "DUMMY_API_KEY"
1414
self.client = db.Historical(key=key)
1515

0 commit comments

Comments
 (0)