Attempt to report `piker storage -d <fqsn>` errors

Not really sure there's much we can do besides dump Grpc stuff when we
detect an "error" `str` for the moment..

Either way leave a buncha complaints (como siempre) and do linting
fixups..
service_subpkg
Tyler Goodlet 2023-03-08 20:06:27 -05:00
parent cec2967071
commit 441243f83b
1 changed files with 34 additions and 27 deletions

View File

@ -18,34 +18,22 @@
marketstore cli.
"""
from functools import partial
from pprint import (
pformat,
pprint,
)
from anyio_marketstore import open_marketstore_client
import trio
import tractor
import click
import numpy as np
from ..service.marketstore import (
get_client,
# get_client,
# stream_quotes,
ingest_quote_stream,
# _url,
_tick_tbk_ids,
mk_tbk,
# _tick_tbk_ids,
# mk_tbk,
)
from ..cli import cli
from .. import watchlists as wl
from ..log import get_logger
from ._sharedmem import (
maybe_open_shm_array,
)
from ._source import (
base_iohlc_dtype,
from ..log import (
get_logger,
)
@ -148,7 +136,7 @@ def storesh(
):
symbol = symbols[0]
async with open_tsdb_client(symbol) as storage:
async with open_tsdb_client(symbol):
# TODO: ask if user wants to write history for detected
# available shm buffers?
from tractor.trionics import ipython_embed
@ -186,7 +174,7 @@ def storage(
Start an IPython shell ready to query the local marketstore db.
'''
from piker.data.marketstore import open_tsdb_client
from piker.service.marketstore import open_tsdb_client
from piker.service import open_piker_runtime
async def main():
@ -201,9 +189,28 @@ def storage(
if delete:
for fqsn in symbols:
syms = await storage.client.list_symbols()
breakpoint()
await storage.delete_ts(fqsn, 60)
await storage.delete_ts(fqsn, 1)
resp60s = await storage.delete_ts(fqsn, 60)
msgish = resp60s.ListFields()[0][1]
if 'error' in str(msgish):
# TODO: MEGA LOL, apparently the symbols don't
# flush out until you refresh something or other
# (maybe the WALFILE)... #lelandorlulzone, classic
# alpaca(Rtm) design here ..
# well, if we ever can make this work we
# probably want to dogsplain the real reason
# for the delete errurz..llululu
if fqsn not in syms:
log.error(f'Pair {fqsn} dne in DB')
log.error(f'Deletion error: {fqsn}\n{msgish}')
resp1s = await storage.delete_ts(fqsn, 1)
msgish = resp1s.ListFields()[0][1]
if 'error' in str(msgish):
log.error(f'Deletion error: {fqsn}\n{msgish}')
trio.run(main)