diff --git a/piker/brokers/_util.py b/piker/brokers/_util.py index b2183a95..5c974c06 100644 --- a/piker/brokers/_util.py +++ b/piker/brokers/_util.py @@ -28,6 +28,9 @@ import json import httpx import logging from msgspec import Struct +from tractor._exceptions import ( + reg_err_types, +) from piker.log import ( colorize_json, @@ -107,6 +110,13 @@ class SchemaMismatch(BrokerError): ''' +# auto-register all `BrokerError` subtypes for +# tractor IPC exc-marshalling. +reg_err_types([ + BrokerError, + *BrokerError.__subclasses__(), +]) + def resproc( resp: httpx.Response, diff --git a/piker/brokers/kraken/api.py b/piker/brokers/kraken/api.py index b360ef04..fbf9d6a9 100644 --- a/piker/brokers/kraken/api.py +++ b/piker/brokers/kraken/api.py @@ -118,6 +118,9 @@ class InvalidKey(ValueError): ''' +from tractor._exceptions import reg_err_types +reg_err_types([InvalidKey]) + class Client: diff --git a/piker/brokers/kraken/broker.py b/piker/brokers/kraken/broker.py index c2bdada4..303a923e 100644 --- a/piker/brokers/kraken/broker.py +++ b/piker/brokers/kraken/broker.py @@ -97,6 +97,9 @@ MsgUnion = Union[ class TooFastEdit(Exception): 'Edit requests faster then api submissions' +from tractor._exceptions import reg_err_types +reg_err_types([TooFastEdit]) + # TODO: make this wrap the `Client` and `ws` instances # and give it methods to submit cancel vs. add vs. edit diff --git a/piker/brokers/kraken/symbols.py b/piker/brokers/kraken/symbols.py index 34756008..2f290271 100644 --- a/piker/brokers/kraken/symbols.py +++ b/piker/brokers/kraken/symbols.py @@ -90,7 +90,7 @@ class Pair(Struct): long_position_limit: float = float('inf') # TODO, add API note when this was added! - # execution_venue: str|None = None + execution_venue: str|None = None # TODO: should we make this a literal NamespacePath ref? ns_path: str = 'piker.brokers.kraken:Pair' diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index 69c888cb..5535af3f 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -95,6 +95,9 @@ _time_frames = { class QuestradeError(Exception): "Non-200 OK response code" +from tractor._exceptions import reg_err_types +reg_err_types([QuestradeError]) + class ContractsKey(NamedTuple): symbol: str diff --git a/piker/config.py b/piker/config.py index bcdf8121..80d094f2 100644 --- a/piker/config.py +++ b/piker/config.py @@ -36,6 +36,7 @@ except ModuleNotFoundError: import tomli as tomllib +from tractor._exceptions import reg_err_types from .log import get_logger log = get_logger('broker-config') @@ -172,6 +173,12 @@ class ConfigurationError(Exception): class NoSignature(ConfigurationError): 'No credentials setup for broker backend!' +# auto-register for tractor IPC exc-marshalling. +reg_err_types([ + ConfigurationError, + *ConfigurationError.__subclasses__(), +]) + def _override_config_dir( path: str diff --git a/piker/data/validate.py b/piker/data/validate.py index c5317ede..fc82c799 100644 --- a/piker/data/validate.py +++ b/piker/data/validate.py @@ -34,6 +34,7 @@ from piker.accounting import ( Asset, MktPair, ) +from tractor._exceptions import reg_err_types from ._util import log @@ -43,6 +44,8 @@ class FeedInitializationError(ValueError): ''' +reg_err_types([FeedInitializationError]) + class FeedInit(Struct, frozen=True): ''' diff --git a/piker/service/_ahab.py b/piker/service/_ahab.py index 94b18c9d..1e87c445 100644 --- a/piker/service/_ahab.py +++ b/piker/service/_ahab.py @@ -49,6 +49,7 @@ from requests.exceptions import ( ReadTimeout, ) +from tractor._exceptions import reg_err_types from piker.log import ( get_console_log, get_logger, @@ -66,6 +67,11 @@ class DockerNotStarted(Exception): class ApplicationLogError(Exception): 'App in container reported an error in logs' +reg_err_types([ + DockerNotStarted, + ApplicationLogError, +]) + @acm async def open_docker( diff --git a/piker/service/marketstore.py b/piker/service/marketstore.py index 9cfc7a13..c21a8bad 100644 --- a/piker/service/marketstore.py +++ b/piker/service/marketstore.py @@ -382,6 +382,9 @@ def quote_to_marketstore_structarray( class MarketStoreError(Exception): "Generic marketstore client error" +from tractor._exceptions import reg_err_types +reg_err_types([MarketStoreError]) + # def err_on_resp(response: dict) -> None: # """Raise any errors found in responses from client request. diff --git a/piker/storage/__init__.py b/piker/storage/__init__.py index 361eaadc..90d1f80c 100644 --- a/piker/storage/__init__.py +++ b/piker/storage/__init__.py @@ -151,6 +151,13 @@ class StorageConnectionError(ConnectionError): ''' +from tractor._exceptions import reg_err_types +reg_err_types([ + TimeseriesNotFound, + StorageConnectionError, +]) + + def get_storagemod( name: str,