From d2accdac9bfc1f25d3f067515b217c8bd1e9e452 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 2 Jun 2023 14:22:42 -0400 Subject: [PATCH] Drop remaining mkts nonsense from `store delete` --- piker/storage/cli.py | 47 +++++---------------------------------- piker/storage/nativedb.py | 7 +++++- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/piker/storage/cli.py b/piker/storage/cli.py index 9ca170c8..5d7119e2 100644 --- a/piker/storage/cli.py +++ b/piker/storage/cli.py @@ -89,37 +89,6 @@ def ls( trio.run(query_all) -async def del_ts_by_timeframe( - client: Storage, - fqme: str, - timeframe: int, - -) -> None: - - path: Path = await client.delete_ts(fqme, timeframe) - log.info(f'Deleted {path}') - - # TODO: encapsulate per backend errors.. - # - 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 fqme not in syms: - # log.error(f'Pair {fqme} dne in DB') - # msgish = resp.ListFields()[0][1] - # if 'error' in str(msgish): - # log.error( - # f'Deletion error:\n' - # f'backend: {client.name}\n' - # f'fqme: {fqme}\n' - # f'timeframe: {timeframe}s\n' - # f'Error msg:\n\n{msgish}\n', - # ) - - @store.command() def delete( symbols: list[str], @@ -128,13 +97,8 @@ def delete( default=None, help='Storage backend to update' ), - - # delete: bool = typer.Option(False, '-d'), - # host: str = typer.Option( - # 'localhost', - # '-h', - # ), - # port: int = typer.Option('5993', '-p'), + # TODO: expose this as flagged multi-option? + timeframes: list[int] = [1, 60], ): ''' Delete a storage backend's time series for (table) keys provided as @@ -149,15 +113,14 @@ def delete( 'tsdb_storage', enable_modules=['piker.service._ahab'] ), - open_storage_client(name=backend) as (_, storage), + open_storage_client(backend) as (_, client), trio.open_nursery() as n, ): # spawn queries as tasks for max conc! for fqme in symbols: - for tf in [1, 60]: + for tf in timeframes: n.start_soon( - del_ts_by_timeframe, - storage, + client.delete_ts, fqme, tf, ) diff --git a/piker/storage/nativedb.py b/piker/storage/nativedb.py index 8b151111..1a4c5e12 100644 --- a/piker/storage/nativedb.py +++ b/piker/storage/nativedb.py @@ -280,7 +280,12 @@ class NativeStorageClient: period=timeframe, datadir=self._datadir, ) - path.unlink() + if path.is_file(): + path.unlink() + log.warning(f'Deleting parquet entry:\n{path}') + else: + log.warning(f'No path exists:\n{path}') + return path