From f0b3a4d5c08d6fa18211bafef51bd9a7ab60b536 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 30 Jul 2022 17:01:56 -0400 Subject: [PATCH] Drop `pydantic.create_model()` usage for `msgspec.defstruct()` --- piker/ui/_fsp.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/piker/ui/_fsp.py b/piker/ui/_fsp.py index f3165667..3fa73504 100644 --- a/piker/ui/_fsp.py +++ b/piker/ui/_fsp.py @@ -27,12 +27,13 @@ from itertools import cycle from typing import Optional, AsyncGenerator, Any import numpy as np -from pydantic import create_model +import msgspec import tractor import pyqtgraph as pg import trio from trio_typing import TaskStatus +from piker.data.types import Struct from ._axes import PriceAxis from .._cacheables import maybe_open_context from ..calc import humanize @@ -53,7 +54,7 @@ from ._forms import ( from ..fsp._api import maybe_mk_fsp_shm, Fsp from ..fsp import cascade from ..fsp._volume import ( - tina_vwap, + # tina_vwap, dolla_vlm, flow_rates, ) @@ -153,12 +154,13 @@ async def open_fsp_sidepane( ) # https://pydantic-docs.helpmanual.io/usage/models/#dynamic-model-creation - FspConfig = create_model( - 'FspConfig', - name=name, - **params, + FspConfig = msgspec.defstruct( + "Point", + [('name', name)] + list(params.items()), + bases=(Struct,), ) - sidepane.model = FspConfig() + model = FspConfig(name=name, **params) + sidepane.model = model # just a logger for now until we get fsp configs up and running. async def settings_change( @@ -440,7 +442,9 @@ class FspAdmin: # if the chart isn't hidden try to update # the data on screen. if not self.linked.isHidden(): - log.debug(f'Re-syncing graphics for fsp: {ns_path}') + log.debug( + f'Re-syncing graphics for fsp: {ns_path}' + ) self.linked.graphics_cycle( trigger_all=True, prepend_update_index=info['first'],