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. marketstore cli.
""" """
from functools import partial
from pprint import (
pformat,
pprint,
)
from anyio_marketstore import open_marketstore_client
import trio import trio
import tractor import tractor
import click import click
import numpy as np
from ..service.marketstore import ( from ..service.marketstore import (
get_client, # get_client,
# stream_quotes, # stream_quotes,
ingest_quote_stream, ingest_quote_stream,
# _url, # _url,
_tick_tbk_ids, # _tick_tbk_ids,
mk_tbk, # mk_tbk,
) )
from ..cli import cli from ..cli import cli
from .. import watchlists as wl from .. import watchlists as wl
from ..log import get_logger from ..log import (
from ._sharedmem import ( get_logger,
maybe_open_shm_array,
)
from ._source import (
base_iohlc_dtype,
) )
@ -148,7 +136,7 @@ def storesh(
): ):
symbol = symbols[0] 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 # TODO: ask if user wants to write history for detected
# available shm buffers? # available shm buffers?
from tractor.trionics import ipython_embed from tractor.trionics import ipython_embed
@ -186,7 +174,7 @@ def storage(
Start an IPython shell ready to query the local marketstore db. 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 from piker.service import open_piker_runtime
async def main(): async def main():
@ -201,9 +189,28 @@ def storage(
if delete: if delete:
for fqsn in symbols: for fqsn in symbols:
syms = await storage.client.list_symbols() syms = await storage.client.list_symbols()
breakpoint()
await storage.delete_ts(fqsn, 60) resp60s = await storage.delete_ts(fqsn, 60)
await storage.delete_ts(fqsn, 1)
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) trio.run(main)