Skip to content

Commit 180b97b

Browse files
authored
Merge pull request #369 from pikers/pydantic_zombie
Drop `pydantic.create_model()` usage for `msgspec.defstruct()`
2 parents e2e6632 + f0b3a4d commit 180b97b

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

piker/ui/_fsp.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
from typing import Optional, AsyncGenerator, Any
2828

2929
import numpy as np
30-
from pydantic import create_model
30+
import msgspec
3131
import tractor
3232
import pyqtgraph as pg
3333
import trio
3434
from trio_typing import TaskStatus
3535

36+
from piker.data.types import Struct
3637
from ._axes import PriceAxis
3738
from .._cacheables import maybe_open_context
3839
from ..calc import humanize
@@ -53,7 +54,7 @@
5354
from ..fsp._api import maybe_mk_fsp_shm, Fsp
5455
from ..fsp import cascade
5556
from ..fsp._volume import (
56-
tina_vwap,
57+
# tina_vwap,
5758
dolla_vlm,
5859
flow_rates,
5960
)
@@ -153,12 +154,13 @@ async def open_fsp_sidepane(
153154
)
154155

155156
# https://pydantic-docs.helpmanual.io/usage/models/#dynamic-model-creation
156-
FspConfig = create_model(
157-
'FspConfig',
158-
name=name,
159-
**params,
157+
FspConfig = msgspec.defstruct(
158+
"Point",
159+
[('name', name)] + list(params.items()),
160+
bases=(Struct,),
160161
)
161-
sidepane.model = FspConfig()
162+
model = FspConfig(name=name, **params)
163+
sidepane.model = model
162164

163165
# just a logger for now until we get fsp configs up and running.
164166
async def settings_change(
@@ -440,7 +442,9 @@ async def open_chain(
440442
# if the chart isn't hidden try to update
441443
# the data on screen.
442444
if not self.linked.isHidden():
443-
log.debug(f'Re-syncing graphics for fsp: {ns_path}')
445+
log.debug(
446+
f'Re-syncing graphics for fsp: {ns_path}'
447+
)
444448
self.linked.graphics_cycle(
445449
trigger_all=True,
446450
prepend_update_index=info['first'],

0 commit comments

Comments
 (0)