Drop old commented cruft, use `Fsp.name`

dark_vlm
Tyler Goodlet 2022-01-28 07:51:13 -05:00
parent bd2460846e
commit b112f24e7e
1 changed files with 9 additions and 46 deletions

View File

@ -28,8 +28,6 @@ from typing import Optional, AsyncGenerator, Any
import numpy as np import numpy as np
from pydantic import create_model from pydantic import create_model
import tractor import tractor
# from tractor.trionics import gather_contexts
from tractor._portal import NamespacePath
import pyqtgraph as pg import pyqtgraph as pg
import trio import trio
from trio_typing import TaskStatus from trio_typing import TaskStatus
@ -118,8 +116,6 @@ async def open_fsp_sidepane(
# add (single) selection widget # add (single) selection widget
for name, config in conf.items(): for name, config in conf.items():
# schema[display_name] = {
# name = target.__name__
schema[name] = { schema[name] = {
'label': '**fsp**:', 'label': '**fsp**:',
'type': 'select', 'type': 'select',
@ -200,8 +196,6 @@ async def run_fsp_ui(
shm: ShmArray, shm: ShmArray,
started: trio.Event, started: trio.Event,
target: Fsp, target: Fsp,
# func_name: str,
# display_name: str,
conf: dict[str, dict], conf: dict[str, dict],
loglevel: str, loglevel: str,
# profiler: pg.debug.Profiler, # profiler: pg.debug.Profiler,
@ -216,19 +210,18 @@ async def run_fsp_ui(
config. config.
''' '''
# profiler(f'started UI task for fsp: {func_name}') name = target.name
name = target.__name__ # profiler(f'started UI task for fsp: {name}')
async with ( async with (
# side UI for parameters/controls # side UI for parameters/controls
open_fsp_sidepane( open_fsp_sidepane(
linkedsplits, linkedsplits,
{name: conf}, {name: conf},
# {display_name: conf},
) as sidepane, ) as sidepane,
): ):
await started.wait() await started.wait()
# profiler(f'fsp:{func_name} attached to fsp ctx-stream') # profiler(f'fsp:{name} attached to fsp ctx-stream')
overlay_with = conf.get('overlay', False) overlay_with = conf.get('overlay', False)
if overlay_with: if overlay_with:
@ -238,28 +231,23 @@ async def run_fsp_ui(
chart = linkedsplits.subplots[overlay_with] chart = linkedsplits.subplots[overlay_with]
chart.draw_curve( chart.draw_curve(
# name=display_name,
name=name, name=name,
data=shm.array, data=shm.array,
overlay=True, overlay=True,
color='default_light', color='default_light',
# array_key=func_name,
array_key=name, array_key=name,
separate_axes=conf.get('separate_axes', False), separate_axes=conf.get('separate_axes', False),
**conf.get('chart_kwargs', {}) **conf.get('chart_kwargs', {})
) )
# specially store ref to shm for lookup in display loop # specially store ref to shm for lookup in display loop
# chart._overlays[display_name] = shm
chart._overlays[name] = shm chart._overlays[name] = shm
else: else:
# create a new sub-chart widget for this fsp # create a new sub-chart widget for this fsp
chart = linkedsplits.add_plot( chart = linkedsplits.add_plot(
name=name, name=name,
# name=display_name,
array=shm.array, array=shm.array,
# array_key=func_name,
array_key=name, array_key=name,
sidepane=sidepane, sidepane=sidepane,
@ -278,17 +266,15 @@ async def run_fsp_ui(
# should **not** be the same sub-chart widget # should **not** be the same sub-chart widget
assert chart.name != linkedsplits.chart.name assert chart.name != linkedsplits.chart.name
# array_key = func_name
array_key = name array_key = name
# profiler(f'fsp:{func_name} chart created') # profiler(f'fsp:{name} chart created')
# first UI update, usually from shm pushed history # first UI update, usually from shm pushed history
update_fsp_chart( update_fsp_chart(
chart, chart,
shm, shm,
name, name,
# display_name,
array_key=array_key, array_key=array_key,
) )
@ -301,7 +287,7 @@ async def run_fsp_ui(
# logic inside ``.paint()`` for ``self.opts['fillLevel']`` which # logic inside ``.paint()`` for ``self.opts['fillLevel']`` which
# might be the best solution? # might be the best solution?
# graphics = chart.update_from_array(chart.name, array[func_name]) # graphics = chart.update_from_array(chart.name, array[name])
# graphics.curve.setBrush(50, 50, 200, 100) # graphics.curve.setBrush(50, 50, 200, 100)
# graphics.curve.setFillLevel(50) # graphics.curve.setFillLevel(50)
@ -401,7 +387,7 @@ class FspAdmin:
''' '''
brokername, sym = self.linked.symbol.front_feed() brokername, sym = self.linked.symbol.front_feed()
ns_path = NamespacePath.from_ref(target) ns_path = str(target.ns_path)
async with ( async with (
portal.open_context( portal.open_context(
@ -417,8 +403,7 @@ class FspAdmin:
dst_shm_token=dst_shm.token, dst_shm_token=dst_shm.token,
# target # target
ns_path=str(ns_path), ns_path=ns_path,
# func_name=func_name,
loglevel=loglevel, loglevel=loglevel,
zero_on_step=conf.get('zero_on_step', False), zero_on_step=conf.get('zero_on_step', False),
@ -444,23 +429,18 @@ class FspAdmin:
self, self,
target: Fsp, target: Fsp,
# display_name: str,
conf: dict[str, dict[str, Any]], conf: dict[str, dict[str, Any]],
worker_name: Optional[str] = None, worker_name: Optional[str] = None,
loglevel: str = 'error', loglevel: str = 'info',
) -> (ShmArray, trio.Event): ) -> (ShmArray, trio.Event):
# unpack FSP details from config dict
# func_name = conf['func_name']
# func_name = target.__name__
fqsn = self.linked.symbol.front_feed() fqsn = self.linked.symbol.front_feed()
# allocate an output shm array # allocate an output shm array
dst_shm, opened = maybe_mk_fsp_shm( dst_shm, opened = maybe_mk_fsp_shm(
fqsn, fqsn,
# field_name=func_name,
# display_name=display_name,
target=target, target=target,
readonly=True, readonly=True,
) )
@ -474,13 +454,11 @@ class FspAdmin:
started = trio.Event() started = trio.Event()
self.tn.start_soon( self.tn.start_soon(
self.open_chain, self.open_chain,
portal, portal,
complete, complete,
started, started,
dst_shm, dst_shm,
conf, conf,
# func_name,
target, target,
loglevel, loglevel,
) )
@ -491,19 +469,14 @@ class FspAdmin:
self, self,
target: Fsp, target: Fsp,
# display_name: str,
conf: dict, # yeah probably dumb.. conf: dict, # yeah probably dumb..
loglevel: str = 'error', loglevel: str = 'error',
) -> (trio.Event, ChartPlotWidget): ) -> (trio.Event, ChartPlotWidget):
# func_name = conf['func_name']
# func_name = target.__name__
shm, started = await self.start_engine_task( shm, started = await self.start_engine_task(
target, target,
# display_name,
conf, conf,
loglevel, loglevel,
) )
@ -516,8 +489,6 @@ class FspAdmin:
self.linked, self.linked,
shm, shm,
started, started,
# func_name,
# display_name,
target, target,
conf=conf, conf=conf,
@ -671,7 +642,6 @@ async def open_vlm_displays(
# spawn and overlay $ vlm on the same subchart # spawn and overlay $ vlm on the same subchart
shm, started = await admin.start_engine_task( shm, started = await admin.start_engine_task(
# 'dolla_vlm',
dolla_vlm, dolla_vlm,
{ # fsp engine conf { # fsp engine conf
@ -760,17 +730,13 @@ async def open_vlm_displays(
axis.size_to_values() axis.size_to_values()
# built-in vlm fsps # built-in vlm fsps
# for display_name, conf in {
for target, conf in { for target, conf in {
# 'vwap': {
tina_vwap: { tina_vwap: {
# 'func_name': 'vwap',
'overlay': 'ohlc', # overlays with OHLCV (main) chart 'overlay': 'ohlc', # overlays with OHLCV (main) chart
'anchor': 'session', 'anchor': 'session',
}, },
}.items(): }.items():
started = await admin.open_fsp_chart( started = await admin.open_fsp_chart(
# display_name,
target, target,
conf, conf,
) )
@ -819,17 +785,14 @@ async def start_fsp_displays(
disabled=False disabled=False
) )
# async with gather_contexts((
async with ( async with (
# NOTE: this admin internally opens an actor cluster # NOTE: this admin internally opens an actor cluster
open_fsp_admin(linked, ohlcv) as admin, open_fsp_admin(linked, ohlcv) as admin,
): ):
statuses = [] statuses = []
# for display_name, conf in fsp_conf.items():
for target, conf in fsp_conf.items(): for target, conf in fsp_conf.items():
started = await admin.open_fsp_chart( started = await admin.open_fsp_chart(
# display_name,
target, target,
conf, conf,
) )