From 31a00eca9404aca3004b60f4bad0681a49370ceb Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 22 May 2023 12:13:00 -0400 Subject: [PATCH] Rename fqsn -> fqme in ui mods --- piker/fsp/_engine.py | 10 ++-- piker/ui/_app.py | 6 +-- piker/ui/_chart.py | 10 ++-- piker/ui/_dataviz.py | 4 +- piker/ui/_display.py | 116 ++++++++++++++++++++--------------------- piker/ui/_fsp.py | 14 ++--- piker/ui/_position.py | 10 ++-- piker/ui/_search.py | 22 ++++---- piker/ui/order_mode.py | 18 +++---- 9 files changed, 105 insertions(+), 105 deletions(-) diff --git a/piker/fsp/_engine.py b/piker/fsp/_engine.py index 3e500f46..13dcfccb 100644 --- a/piker/fsp/_engine.py +++ b/piker/fsp/_engine.py @@ -104,14 +104,14 @@ async def fsp_compute( disabled=True ) - fqsn = symbol.fqme + fqme = symbol.fqme out_stream = func( # TODO: do we even need this if we do the feed api right? # shouldn't a local stream do this before we get a handle # to the async iterable? it's that or we do some kinda # async itertools style? - filter_quotes_by_sym(fqsn, quote_stream), + filter_quotes_by_sym(fqme, quote_stream), # XXX: currently the ``ohlcv`` arg flume.rt_shm, @@ -271,7 +271,7 @@ async def cascade( ctx: tractor.Context, # data feed key - fqsn: str, + fqme: str, src_shm_token: dict, dst_shm_token: tuple[str, np.dtype], @@ -329,7 +329,7 @@ async def cascade( # open a data feed stream with requested broker feed: Feed async with data.feed.maybe_open_feed( - [fqsn], + [fqme], # TODO throttle tick outputs from *this* daemon since # it'll emit tons of ticks due to the throttle only @@ -339,7 +339,7 @@ async def cascade( ) as feed: - flume = feed.flumes[fqsn] + flume = feed.flumes[fqme] symbol = flume.symbol assert src.token == flume.rt_shm.token profiler(f'{func}: feed up') diff --git a/piker/ui/_app.py b/piker/ui/_app.py index 13f19f40..ee4faf57 100644 --- a/piker/ui/_app.py +++ b/piker/ui/_app.py @@ -100,8 +100,8 @@ async def _async_main( starting_done = sbar.open_status('starting ze sexy chartz') needed_brokermods: dict[str, ModuleType] = {} - for fqsn in syms: - brokername, *_ = unpack_fqme(fqsn) + for fqme in syms: + brokername, *_ = unpack_fqme(fqme) needed_brokermods[brokername] = brokers[brokername] async with ( @@ -120,7 +120,7 @@ async def _async_main( # this internally starts a ``display_symbol_data()`` task above order_mode_ready = await godwidget.load_symbols( - fqsns=syms, + fqmes=syms, loglevel=loglevel, ) diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 464fb8b7..13ec23c3 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -152,7 +152,7 @@ class GodWidget(QWidget): def set_chart_symbols( self, - group_key: tuple[str], # of form . + group_key: tuple[str], # of form . all_linked: tuple[LinkedSplits, LinkedSplits], # type: ignore ) -> None: @@ -170,7 +170,7 @@ class GodWidget(QWidget): async def load_symbols( self, - fqsns: list[str], + fqmes: list[str], loglevel: str, reset: bool = False, @@ -183,7 +183,7 @@ class GodWidget(QWidget): ''' # NOTE: for now we use the first symbol in the set as the "key" # for the overlay of feeds on the chart. - group_key: tuple[str] = tuple(fqsns) + group_key: tuple[str] = tuple(fqmes) all_linked = self.get_chart_symbols(group_key) order_mode_started = trio.Event() @@ -217,7 +217,7 @@ class GodWidget(QWidget): self._root_n.start_soon( display_symbol_data, self, - fqsns, + fqmes, loglevel, order_mode_started, ) @@ -548,7 +548,7 @@ class LinkedSplits(QWidget): # be no distinction since we will have multiple symbols per # view as part of "aggregate feeds". self.chart = self.add_plot( - name=symbol.fqsn, + name=symbol.fqme, shm=shm, flume=flume, style=style, diff --git a/piker/ui/_dataviz.py b/piker/ui/_dataviz.py index 7f1ef41e..721483e1 100644 --- a/piker/ui/_dataviz.py +++ b/piker/ui/_dataviz.py @@ -1249,7 +1249,7 @@ class Viz(Struct): i_step = lasts['index'] # last index-specific step. i_step_t = lasts['time'] # last time step. - # fqsn = self.flume.symbol.fqsn + # fqme = self.flume.symbol.fqme # check if "last (is) in view" -> is a real-time update necessary? if self.index_field == 'index': @@ -1304,7 +1304,7 @@ class Viz(Struct): varz['i_last_append'] = i_step # print( - # f'DOING APPEND => {fqsn}\n' + # f'DOING APPEND => {fqme}\n' # f'i_step: {i_step}\n' # f'i_step_t: {i_step_t}\n' # f'glast: {glast}\n' diff --git a/piker/ui/_display.py b/piker/ui/_display.py index d7500544..40ec23b2 100644 --- a/piker/ui/_display.py +++ b/piker/ui/_display.py @@ -163,7 +163,7 @@ class DisplayState(Struct): Chart-local real-time graphics state container. ''' - fqsn: str + fqme: str godwidget: GodWidget quotes: dict[str, Any] @@ -223,7 +223,7 @@ async def increment_history_view( async for msg in istream: profiler = Profiler( - msg=f'History chart cycle for: `{ds.fqsn}`', + msg=f'History chart cycle for: `{ds.fqme}`', delayed=True, disabled=not pg_profile_enabled(), ms_threshold=ms_slower_then, @@ -232,7 +232,7 @@ async def increment_history_view( # l3 = ds.viz.shm.array[-3:] # print( - # f'fast step for {ds.flume.symbol.fqsn}:\n' + # f'fast step for {ds.flume.symbol.fqme}:\n' # f'{list(l3["time"])}\n' # f'{l3}\n' # ) @@ -317,17 +317,17 @@ async def graphics_update_loop( dss: dict[str, DisplayState] = {} - for fqsn, flume in feed.flumes.items(): + for fqme, flume in feed.flumes.items(): ohlcv = flume.rt_shm hist_ohlcv = flume.hist_shm symbol = flume.symbol - fqsn = symbol.fqsn + fqme = symbol.fqme # update last price sticky - fast_viz = fast_chart._vizs[fqsn] + fast_viz = fast_chart._vizs[fqme] index_field = fast_viz.index_field fast_pi = fast_viz.plot - last_price_sticky = fast_pi.getAxis('right')._stickies[fqsn] + last_price_sticky = fast_pi.getAxis('right')._stickies[fqme] last_price_sticky.update_from_data( *ohlcv.array[-1][[ index_field, @@ -336,9 +336,9 @@ async def graphics_update_loop( ) last_price_sticky.show() - hist_viz = hist_chart._vizs[fqsn] + hist_viz = hist_chart._vizs[fqme] slow_pi = hist_viz.plot - hist_last_price_sticky = slow_pi.getAxis('right')._stickies[fqsn] + hist_last_price_sticky = slow_pi.getAxis('right')._stickies[fqme] hist_last_price_sticky.update_from_data( *hist_ohlcv.array[-1][[ index_field, @@ -346,7 +346,7 @@ async def graphics_update_loop( ]] ) - vlm_chart = vlm_charts[fqsn] + vlm_chart = vlm_charts[fqme] vlm_viz = vlm_chart._vizs.get('volume') if vlm_chart else None ( @@ -381,8 +381,8 @@ async def graphics_update_loop( fast_chart.show() last_quote_s = time.time() - dss[fqsn] = ds = linked.display_state = DisplayState(**{ - 'fqsn': fqsn, + dss[fqme] = ds = linked.display_state = DisplayState(**{ + 'fqme': fqme, 'godwidget': godwidget, 'quotes': {}, @@ -454,11 +454,11 @@ async def graphics_update_loop( last_quote_s = time.time() - for fqsn, quote in quotes.items(): - ds = dss[fqsn] + for fqme, quote in quotes.items(): + ds = dss[fqme] ds.quotes = quote - rt_pi, hist_pi = pis[fqsn] + rt_pi, hist_pi = pis[fqme] # chart isn't active/shown so skip render cycle and # pause feed(s) @@ -466,14 +466,14 @@ async def graphics_update_loop( fast_chart.linked.isHidden() or not rt_pi.isVisible() ): - print(f'{fqsn} skipping update for HIDDEN CHART') + print(f'{fqme} skipping update for HIDDEN CHART') fast_chart.pause_all_feeds() continue ic = fast_chart.view._in_interact if ic: fast_chart.pause_all_feeds() - print(f'{fqsn} PAUSING DURING INTERACTION') + print(f'{fqme} PAUSING DURING INTERACTION') await ic.wait() fast_chart.resume_all_feeds() @@ -495,7 +495,7 @@ def graphics_update_cycle( ) -> None: profiler = Profiler( - msg=f'Graphics loop cycle for: `{ds.fqsn}`', + msg=f'Graphics loop cycle for: `{ds.fqme}`', disabled=not pg_profile_enabled(), ms_threshold=ms_slower_then, delayed=True, @@ -509,7 +509,7 @@ def graphics_update_cycle( # - use a streaming minmax algo and drop the use of the # state-tracking ``multi_maxmin()`` routine from above? - fqsn = ds.fqsn + fqme = ds.fqme chart = ds.chart vlm_chart = ds.vlm_chart @@ -548,7 +548,7 @@ def graphics_update_cycle( # the true range? This way you can slap in orders outside the # current L1 (only) book range. main_vb: ChartView = main_viz.plot.vb - this_viz: Viz = chart._vizs[fqsn] + this_viz: Viz = chart._vizs[fqme] this_vb: ChartView = this_viz.plot.vb this_yr = this_vb._yrange if this_yr: @@ -600,7 +600,7 @@ def graphics_update_cycle( profiler, ) - profiler(f'{fqsn} `multi_maxmin()` call') + profiler(f'{fqme} `multi_maxmin()` call') # iterate frames of ticks-by-type such that we only update graphics # using the last update per type where possible. @@ -828,7 +828,7 @@ def graphics_update_cycle( # update any overlayed fsp flows if ( - curve_name != fqsn + curve_name != fqme ): update_fsp_chart( viz, @@ -939,7 +939,7 @@ def graphics_update_cycle( liv and do_rt_update or do_px_step ) - and curve_name not in {fqsn} + and curve_name not in {fqme} ): update_fsp_chart( viz, @@ -1008,7 +1008,7 @@ async def link_views_with_region( hist_pi.addItem(region, ignoreBounds=True) region.setOpacity(6/16) - viz = rt_chart.get_viz(flume.symbol.fqsn) + viz = rt_chart.get_viz(flume.symbol.fqme) assert viz index_field = viz.index_field @@ -1035,7 +1035,7 @@ async def link_views_with_region( # HFT/real-time chart. rng = mn, mx = viewRange[0] - # hist_viz = hist_chart.get_viz(flume.symbol.fqsn) + # hist_viz = hist_chart.get_viz(flume.symbol.fqme) # hist = hist_viz.shm.array[-3:] # print( # f'mn: {mn}\n' @@ -1153,7 +1153,7 @@ _quote_throttle_rate: int = 60 - 6 async def display_symbol_data( godwidget: GodWidget, - fqsns: list[str], + fqmes: list[str], loglevel: str, order_mode_started: trio.Event, @@ -1176,9 +1176,9 @@ async def display_symbol_data( # group_key=loading_sym_key, # ) - for fqsn in fqsns: + for fqme in fqmes: loading_sym_key = sbar.open_status( - f'loading {fqsn} ->', + f'loading {fqme} ->', group_key=True ) @@ -1197,7 +1197,7 @@ async def display_symbol_data( # TODO: we should be able to increase this if we use some # `mypyc` speedups elsewhere? 22ish seems to be the sweet # spot for single-feed chart. - num_of_feeds = len(fqsns) + num_of_feeds = len(fqmes) mx: int = 22 if num_of_feeds > 1: # there will be more ctx switches with more than 1 feed so we @@ -1213,18 +1213,18 @@ async def display_symbol_data( feed: Feed async with open_feed( - fqsns, + fqmes, loglevel=loglevel, tick_throttle=cycles_per_feed, ) as feed: # use expanded contract symbols passed back from feed layer. - fqsns = list(feed.flumes.keys()) + fqmes = list(feed.flumes.keys()) # step_size_s = 1 # tf_key = tf_in_1s[step_size_s] godwidget.window.setWindowTitle( - f'{fqsns} ' + f'{fqmes} ' # f'tick:{symbol.tick_size} ' # f'step:{tf_key} ' ) @@ -1276,7 +1276,7 @@ async def display_symbol_data( # for the "first"/selected symbol we create new chart widgets # and sub-charts for FSPs - fqsn, flume = fitems[0] + fqme, flume = fitems[0] # TODO NOTE: THIS CONTROLS WHAT SYMBOL IS USED FOR ORDER MODE # SUBMISSIONS, we need to make this switch based on selection. @@ -1287,7 +1287,7 @@ async def display_symbol_data( hist_ohlcv: ShmArray = flume.hist_shm symbol = flume.symbol - fqsn = symbol.fqsn + fqme = symbol.fqme hist_chart = hist_linked.plot_ohlc_main( symbol, @@ -1304,9 +1304,9 @@ async def display_symbol_data( # ensure the last datum graphic is generated # for zoom-interaction purposes. - hist_viz = hist_chart.get_viz(fqsn) - hist_viz.draw_last(array_key=fqsn) - pis.setdefault(fqsn, [None, None])[1] = hist_chart.plotItem + hist_viz = hist_chart.get_viz(fqme) + hist_viz.draw_last(array_key=fqme) + pis.setdefault(fqme, [None, None])[1] = hist_chart.plotItem # don't show when not focussed hist_linked.cursor.always_show_xlabel = False @@ -1322,8 +1322,8 @@ async def display_symbol_data( 'last_step_color': 'original', }, ) - rt_viz = rt_chart.get_viz(fqsn) - pis.setdefault(fqsn, [None, None])[0] = rt_chart.plotItem + rt_viz = rt_chart.get_viz(fqme) + pis.setdefault(fqme, [None, None])[0] = rt_chart.plotItem # for pause/resume on mouse interaction rt_chart.feed = feed @@ -1338,7 +1338,7 @@ async def display_symbol_data( has_vlm(ohlcv) and vlm_chart is None ): - vlm_chart = vlm_charts[fqsn] = await ln.start( + vlm_chart = vlm_charts[fqme] = await ln.start( open_vlm_displays, rt_linked, flume, @@ -1372,7 +1372,7 @@ async def display_symbol_data( godwidget.resize_all() await trio.sleep(0) - for fqsn, flume in fitems[1:]: + for fqme, flume in fitems[1:]: # get a new color from the palette bg_chart_color, bg_last_bar_color = next(palette) @@ -1380,18 +1380,18 @@ async def display_symbol_data( hist_ohlcv: ShmArray = flume.hist_shm symbol = flume.symbol - fqsn = symbol.fqsn + fqme = symbol.fqme hist_pi = hist_chart.overlay_plotitem( - name=fqsn, - axis_title=fqsn, + name=fqme, + axis_title=fqme, ) hist_viz = hist_chart.draw_curve( - fqsn, + fqme, hist_ohlcv, flume, - array_key=fqsn, + array_key=fqme, overlay=hist_pi, pi=hist_pi, is_ohlc=True, @@ -1402,26 +1402,26 @@ async def display_symbol_data( # ensure the last datum graphic is generated # for zoom-interaction purposes. - hist_viz.draw_last(array_key=fqsn) + hist_viz.draw_last(array_key=fqme) # TODO: we need a better API to do this.. # specially store ref to shm for lookup in display loop # since only a placeholder of `None` is entered in # ``.draw_curve()``. - hist_viz = hist_chart._vizs[fqsn] + hist_viz = hist_chart._vizs[fqme] assert hist_viz.plot is hist_pi - pis.setdefault(fqsn, [None, None])[1] = hist_pi + pis.setdefault(fqme, [None, None])[1] = hist_pi rt_pi = rt_chart.overlay_plotitem( - name=fqsn, - axis_title=fqsn, + name=fqme, + axis_title=fqme, ) rt_viz = rt_chart.draw_curve( - fqsn, + fqme, ohlcv, flume, - array_key=fqsn, + array_key=fqme, overlay=rt_pi, pi=rt_pi, is_ohlc=True, @@ -1434,9 +1434,9 @@ async def display_symbol_data( # specially store ref to shm for lookup in display loop # since only a placeholder of `None` is entered in # ``.draw_curve()``. - rt_viz = rt_chart._vizs[fqsn] + rt_viz = rt_chart._vizs[fqme] assert rt_viz.plot is rt_pi - pis.setdefault(fqsn, [None, None])[0] = rt_pi + pis.setdefault(fqme, [None, None])[0] = rt_pi rt_chart.setFocus() @@ -1452,7 +1452,7 @@ async def display_symbol_data( # greedily do a view range default and pane resizing # on startup before loading the order-mode machinery. - for fqsn, flume in feed.flumes.items(): + for fqme, flume in feed.flumes.items(): # size view to data prior to order mode init rt_chart.main_viz.default_view( @@ -1495,7 +1495,7 @@ async def display_symbol_data( ) # boot order-mode - order_ctl_fqme: str = fqsns[0] + order_ctl_fqme: str = fqmes[0] mode: OrderMode async with ( open_order_mode( @@ -1522,7 +1522,7 @@ async def display_symbol_data( hist_chart.main_viz.default_view( do_min_bars=True, ) - hist_viz = hist_chart.get_viz(fqsn) + hist_viz = hist_chart.get_viz(fqme) await trio.sleep(0) godwidget.resize_all() diff --git a/piker/ui/_fsp.py b/piker/ui/_fsp.py index 5c61b07e..06814c28 100644 --- a/piker/ui/_fsp.py +++ b/piker/ui/_fsp.py @@ -398,7 +398,7 @@ class FspAdmin: portal: tractor.Portal, complete: trio.Event, started: trio.Event, - fqsn: str, + fqme: str, dst_fsp_flume: Flume, conf: dict, target: Fsp, @@ -418,7 +418,7 @@ class FspAdmin: cascade, # data feed key - fqsn=fqsn, + fqme=fqme, # TODO: pass `Flume.to_msg()`s here? # mems @@ -444,7 +444,7 @@ class FspAdmin: # register output data self._registry[ - (fqsn, ns_path) + (fqme, ns_path) ] = ( stream, dst_fsp_flume.rt_shm, @@ -484,11 +484,11 @@ class FspAdmin: ) -> (Flume, trio.Event): - fqsn = self.flume.symbol.fqsn + fqme = self.flume.symbol.get_fqme(delim_char='') # allocate an output shm array key, dst_shm, opened = maybe_mk_fsp_shm( - fqsn, + fqme, target=target, readonly=True, ) @@ -519,7 +519,7 @@ class FspAdmin: # if not opened: # raise RuntimeError( - # f'Already started FSP `{fqsn}:{func_name}`' + # f'Already started FSP `{fqme}:{func_name}`' # ) complete = trio.Event() @@ -529,7 +529,7 @@ class FspAdmin: portal, complete, started, - fqsn, + fqme, dst_fsp_flume, conf, target, diff --git a/piker/ui/_position.py b/piker/ui/_position.py index f08e234a..7ec859da 100644 --- a/piker/ui/_position.py +++ b/piker/ui/_position.py @@ -125,7 +125,7 @@ async def update_pnl_from_feed( # watch out for wrong quote msg-data if you muck # with backend feed subs code.. - # assert sym == quote['fqsn'] + # assert sym == quote['fqme'] for tick in iterticks(quote, types): # print(f'{1/period} Hz') @@ -417,7 +417,7 @@ class SettingsPane: mode = self.order_mode sym = mode.chart.linked.symbol size = tracker.live_pp.size - flume: Feed = mode.feed.flumes[sym.fqsn] + flume: Feed = mode.feed.flumes[sym.fqme] pnl_value = 0 if size: @@ -430,9 +430,9 @@ class SettingsPane: # maybe start update task global _pnl_tasks - fqsn = sym.fqme - if fqsn not in _pnl_tasks: - _pnl_tasks[fqsn] = True + fqme = sym.fqme + if fqme not in _pnl_tasks: + _pnl_tasks[fqme] = True self.order_mode.nursery.start_soon( update_pnl_from_feed, flume, diff --git a/piker/ui/_search.py b/piker/ui/_search.py index 9627e83d..216a94b6 100644 --- a/piker/ui/_search.py +++ b/piker/ui/_search.py @@ -639,10 +639,10 @@ class SearchWidget(QtWidgets.QWidget): godw = self.godwidget # first entry in the cache is the current symbol(s) - fqsns = set() - for multi_fqsns in list(godw._chart_cache): - for fqsn in set(multi_fqsns): - fqsns.add(fqsn) + fqmes = set() + for multi_fqmes in list(godw._chart_cache): + for fqme in set(multi_fqmes): + fqmes.add(fqme) if keep_current_item_selected: sel = self.view.selectionModel() @@ -650,7 +650,7 @@ class SearchWidget(QtWidgets.QWidget): self.view.set_section_entries( 'cache', - list(fqsns), + list(fqmes), # remove all other completion results except for cache clear_all=only, reverse=True, @@ -722,18 +722,18 @@ class SearchWidget(QtWidgets.QWidget): cidx, provider, symbol = value godw = self.godwidget - fqsn = f'{symbol}.{provider}' - log.info(f'Requesting symbol: {fqsn}') + fqme = f'{symbol}.{provider}' + log.info(f'Requesting symbol: {fqme}') # assert provider in symbol await godw.load_symbols( - fqsns=[fqsn], + fqmes=[fqme], loglevel='info', ) # fully qualified symbol name (SNS i guess is what we're # making?) - fqsn = '.'.join([symbol, provider]).lower() + fqme = '.'.join([symbol, provider]).lower() if clear_to_cache: @@ -743,7 +743,7 @@ class SearchWidget(QtWidgets.QWidget): # LIFO order. this is normally only done internally by # the chart on new symbols being loaded into memory godw.set_chart_symbols( - (fqsn,), ( + (fqme,), ( godw.hist_linked, godw.rt_linked, ) @@ -753,7 +753,7 @@ class SearchWidget(QtWidgets.QWidget): ) self.bar.focus() - return fqsn + return fqme def space_dims(self) -> tuple[float, float]: ''' diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index 32b8b039..098bf14f 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -549,7 +549,7 @@ class OrderMode: # XXX: seems to fail on certain types of races? # assert len(lines) == 2 if lines: - flume: Flume = self.feed.flumes[chart.linked.symbol.fqsn] + flume: Flume = self.feed.flumes[chart.linked.symbol.fqme] _, _, ratio = flume.get_ds_info() for chart, shm in [ @@ -691,7 +691,7 @@ async def open_order_mode( feed: Feed, godw: GodWidget, - fqsn: str, + fqme: str, started: trio.Event, loglevel: str = 'info' @@ -722,7 +722,7 @@ async def open_order_mode( # spawn EMS actor-service async with ( open_ems( - fqsn, + fqme, loglevel=loglevel, ) as ( client, @@ -734,7 +734,7 @@ async def open_order_mode( trio.open_nursery() as tn, ): - log.info(f'Opening order mode for {fqsn}') + log.info(f'Opening order mode for {fqme}') # annotations editors lines = LineEditor(godw=godw) @@ -1027,7 +1027,7 @@ async def process_trade_msg( dialog: Dialog = mode.dialogs.get(oid) if dialog: - fqsn = dialog.symbol + fqme = dialog.symbol match msg: case Status( @@ -1050,16 +1050,16 @@ async def process_trade_msg( assert msg.resp in ('open', 'dark_open'), f'Unknown msg: {msg}' sym = mode.chart.linked.symbol - fqsn = sym.fqme + fqme = sym.fqme if ( - ((order.symbol + f'.{msg.src}') == fqsn) + ((order.symbol + f'.{msg.src}') == fqme) # a existing dark order for the same symbol or ( - order.symbol == fqsn + order.symbol == fqme and ( msg.src in ('dark', 'paperboi') - or (msg.src in fqsn) + or (msg.src in fqme) ) )