Skip to content

Commit b9af617

Browse files
committed
Factor TimeseriesNotFound to top level
TO CHERRY into #486
1 parent dd0167b commit b9af617

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

piker/data/history.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from ..brokers._util import (
5858
DataUnavailable,
5959
)
60+
from ..storage import TimeseriesNotFound
6061

6162
if TYPE_CHECKING:
6263
from bidict import bidict
@@ -690,13 +691,18 @@ async def tsdb_backfill(
690691
# but if not then below the remaining history can be lazy
691692
# loaded?
692693
fqme: str = mkt.fqme
693-
tsdb_entry: tuple | None = await storage.load(
694-
fqme,
695-
timeframe=timeframe,
696-
)
697-
698694
last_tsdb_dt: datetime | None = None
699-
if tsdb_entry:
695+
try:
696+
tsdb_entry: tuple | None = await storage.load(
697+
fqme,
698+
timeframe=timeframe,
699+
)
700+
except TimeseriesNotFound:
701+
log.warning(
702+
f'No timeseries yet for {fqme}'
703+
)
704+
705+
else:
700706
(
701707
tsdb_history,
702708
first_tsdb_dt,
@@ -963,7 +969,8 @@ async def manage_history(
963969
sub_for_broadcasts=False,
964970

965971
) as sample_stream:
966-
# register 1s and 1m buffers with the global incrementer task
972+
# register 1s and 1m buffers with the global
973+
# incrementer task
967974
log.info(f'Connected to sampler stream: {sample_stream}')
968975

969976
for timeframe in [60, 1]:

piker/storage/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ async def write_ohlcv(
139139
...
140140

141141

142+
class TimeseriesNotFound(Exception):
143+
'''
144+
No timeseries entry can be found for this backend.
145+
146+
'''
147+
148+
142149
class StorageConnectionError(ConnectionError):
143150
'''
144151
Can't connect to the desired tsdb subsys/service.

piker/storage/nativedb.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
call a poor man's tsdb).
2020
2121
AKA a `piker`-native file-system native "time series database"
22-
without needing an extra process and no standard TSDB features, YET!
22+
without needing an extra process and no standard TSDB features,
23+
YET!
2324
2425
'''
2526
# TODO: like there's soo much..
@@ -67,17 +68,12 @@
6768
from piker.data import def_iohlcv_fields
6869
from piker.data import ShmArray
6970
from piker.log import get_logger
71+
from . import TimeseriesNotFound
7072

7173

7274
log = get_logger('storage.nativedb')
7375

7476

75-
class TimeseriesNotFound(Exception):
76-
'''
77-
No timeseries entry can be found for this backend.
78-
79-
'''
80-
8177
# NOTE: thanks to this SO answer for the below conversion routines
8278
# to go from numpy struct-arrays to polars dataframes and back:
8379
# https://stackoverflow.com/a/72054819

0 commit comments

Comments
 (0)