From fd8be33f10ec42bf843214ca24b66f6a4474c8b3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 16 Sep 2021 09:17:14 -0400 Subject: [PATCH 1/9] Add portal getter, store throttle rate --- piker/clearing/_ems.py | 4 +++- piker/data/feed.py | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/piker/clearing/_ems.py b/piker/clearing/_ems.py index 583e2509..8ff2b0e2 100644 --- a/piker/clearing/_ems.py +++ b/piker/clearing/_ems.py @@ -373,7 +373,9 @@ async def open_brokerd_trades_dialogue( broker = feed.mod.name # TODO: make a `tractor` bug/test for this! - # portal = feed._brokerd_portal + # if only i could member what the problem was.. + # probably some GC of the portal thing? + # portal = feed.portal # XXX: we must have our own portal + channel otherwise # when the data feed closes it may result in a half-closed diff --git a/piker/data/feed.py b/piker/data/feed.py index 9bfe95a9..bf003b9a 100644 --- a/piker/data/feed.py +++ b/piker/data/feed.py @@ -393,18 +393,23 @@ class Feed: shm: ShmArray mod: ModuleType first_quotes: dict # symbol names to first quote dicts - stream: trio.abc.ReceiveChannel[dict[str, Any]] - _brokerd_portal: tractor._portal.Portal + _portal: tractor.Portal + + stream: trio.abc.ReceiveChannel[dict[str, Any]] + throttle_rate: Optional[int] = None + _trade_stream: Optional[AsyncIterator[dict[str, Any]]] = None _max_sample_rate: int = 0 - search: Callable[..., Awaitable] = None - # cache of symbol info messages received as first message when # a stream startsc. symbols: dict[str, Symbol] = field(default_factory=dict) + @property + def portal(self) -> tractor.Portal: + return self._portal + async def receive(self) -> dict: return await self.stream.receive() @@ -418,7 +423,7 @@ class Feed: delay_s = delay_s or self._max_sample_rate async with open_sample_step_stream( - self._brokerd_portal, + self.portal, delay_s, ) as istream: yield istream @@ -526,7 +531,8 @@ async def open_feed( mod=mod, first_quotes=first_quotes, stream=stream, - _brokerd_portal=portal, + _portal=portal, + throttle_rate=tick_throttle, ) ohlc_sample_rates = [] From bc42d625fc2c5000386d16084632f95eef7f97cd Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 16 Sep 2021 09:17:44 -0400 Subject: [PATCH 2/9] Make labels expand by default --- piker/ui/_label.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/piker/ui/_label.py b/piker/ui/_label.py index c9a0b2a0..a0081a48 100644 --- a/piker/ui/_label.py +++ b/piker/ui/_label.py @@ -23,7 +23,7 @@ from typing import Callable, Optional, Any import pyqtgraph as pg from PyQt5 import QtGui, QtWidgets -from PyQt5.QtWidgets import QLabel +from PyQt5.QtWidgets import QLabel, QSizePolicy from PyQt5.QtCore import QPointF, QRectF, Qt from ._style import ( @@ -269,8 +269,11 @@ class FormatLabel(QLabel): self.setTextFormat(Qt.MarkdownText) # markdown self.setMargin(0) - self.setAlignment( - Qt.AlignVCenter + self.setSizePolicy( + QSizePolicy.Expanding, + QSizePolicy.Expanding, + ) + self.setAlignment(Qt.AlignVCenter | Qt.AlignLeft ) self.setText(self.fmt_str) From 3e25be6321f5bb08017ac7a93e4753e25e75cc72 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 16 Sep 2021 09:19:02 -0400 Subject: [PATCH 3/9] Build out feed status label, add to top of sidepane --- piker/ui/_forms.py | 41 +++++------------------------ piker/ui/order_mode.py | 59 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 34 deletions(-) diff --git a/piker/ui/_forms.py b/piker/ui/_forms.py index 5aed6f9c..38184ca4 100644 --- a/piker/ui/_forms.py +++ b/piker/ui/_forms.py @@ -21,7 +21,6 @@ Text entry "forms" widgets (mostly for configuration and UI user input). from __future__ import annotations from contextlib import asynccontextmanager from functools import partial -from textwrap import dedent from typing import ( Optional, Any, Callable, Awaitable ) @@ -320,14 +319,14 @@ class FieldsForm(QWidget): self.vbox = QVBoxLayout(self) # self.vbox.setAlignment(Qt.AlignVCenter) self.vbox.setAlignment(Qt.AlignBottom) - self.vbox.setContentsMargins(0, 4, 3, 6) + self.vbox.setContentsMargins(3, 6, 3, 6) self.vbox.setSpacing(0) # split layout for the (