Compare commits

..

2 Commits

Author SHA1 Message Date
Gud Boi e0ec09cf19 Flip `.tsp._history` logger to explicit mod-name (again) 2026-02-06 00:39:59 -05:00
Gud Boi 68a87ca45f Adjust `tractor.log` API compat
Update logging helpers to use new `tractor.log` API with `pkg_name=`
kwarg and add optional `tractor` "root logger" enabling.

Deats,
- change `piker.log.get_logger()` to use `pkg_name=` vs `_root_name=`.
- add `**tractor_log_kwargs` passthrough to both wrapper fns.
- add `with_tractor_log: bool` toggle to `.get_console_log()`.
- strip `'piker.'` prefix from logger names when present to avoid
  newly added `tractor.get_logger()` warnings.

Surroundingly,
- add `subsys` import to `.clearing._ems` for log name
- update all `get_console_log()` calls to use `level=` kwarg
- add assertion checks for logger names in `_setup_persistent_emsd()`

Additionally,,
- fix all type annotations: `str|None` vs `str | None`.
- add multiline style to conditional in `.cli.services()`.
- drop unused `Optional` import from `._actor_runtime`.
- drop a few "blank lines" in various function sigs.

Warning: this patch will require an equivalent dev-commit at the time of
writing in `tractor` itself, for now the `piker_pin` branch should be
sufficient to avoid breakage 🙏!

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code

k
2026-02-06 00:33:05 -05:00
4 changed files with 16 additions and 34 deletions

View File

@ -237,8 +237,8 @@ async def open_history_client(
async def get_ohlc( async def get_ohlc(
timeframe: float, timeframe: float,
end_dt: datetime|None = None, end_dt: datetime | None = None,
start_dt: datetime|None = None, start_dt: datetime | None = None,
) -> tuple[ ) -> tuple[
np.ndarray, np.ndarray,
@ -277,11 +277,7 @@ async def open_history_client(
if end_dt is None: if end_dt is None:
inow: int = round(time.time()) inow: int = round(time.time())
if ( if (inow - times[-1]) > 60:
(inow - times[-1])
>
timeframe
):
await tractor.pause() await tractor.pause()
start_dt = from_timestamp(times[0]) start_dt = from_timestamp(times[0])
@ -295,7 +291,7 @@ async def open_history_client(
async def get_mkt_info( async def get_mkt_info(
fqme: str, fqme: str,
) -> tuple[MktPair, Pair]|None: ) -> tuple[MktPair, Pair] | None:
# uppercase since kraken bs_mktid is always upper # uppercase since kraken bs_mktid is always upper
if 'binance' not in fqme.lower(): if 'binance' not in fqme.lower():
@ -372,7 +368,7 @@ async def get_mkt_info(
if 'futes' in mkt_mode: if 'futes' in mkt_mode:
assert isinstance(pair, FutesPair) assert isinstance(pair, FutesPair)
dst: Asset|None = assets.get(pair.bs_dst_asset) dst: Asset | None = assets.get(pair.bs_dst_asset)
if ( if (
not dst not dst
# TODO: a known asset DNE list? # TODO: a known asset DNE list?
@ -431,7 +427,7 @@ async def subscribe(
# might get ack from ws server, or maybe some # might get ack from ws server, or maybe some
# other msg still in transit.. # other msg still in transit..
res = await ws.recv_msg() res = await ws.recv_msg()
subid: str|None = res.get('id') subid: str | None = res.get('id')
if subid: if subid:
assert res['id'] == subid assert res['id'] == subid

View File

@ -134,7 +134,7 @@ _adhoc_fiat_set = set((
# manually discovered tick discrepancies, # manually discovered tick discrepancies,
# onl god knows how or why they'd cuck these up.. # onl god knows how or why they'd cuck these up..
_adhoc_mkt_infos: dict[int|str, dict] = { _adhoc_mkt_infos: dict[int | str, dict] = {
'vtgn.nasdaq': {'price_tick': Decimal('0.01')}, 'vtgn.nasdaq': {'price_tick': Decimal('0.01')},
} }
@ -488,7 +488,8 @@ def con2fqme(
@async_lifo_cache() @async_lifo_cache()
async def get_mkt_info( async def get_mkt_info(
fqme: str, fqme: str,
proxy: MethodProxy|None = None,
proxy: MethodProxy | None = None,
) -> tuple[MktPair, ibis.ContractDetails]: ) -> tuple[MktPair, ibis.ContractDetails]:
@ -549,7 +550,7 @@ async def get_mkt_info(
size_tick: Decimal = Decimal( size_tick: Decimal = Decimal(
str(details.minSize).rstrip('0') str(details.minSize).rstrip('0')
) )
# ?TODO, there is also the Contract.sizeIncrement, bt wtf is it? # |-> TODO: there is also the Contract.sizeIncrement, bt wtf is it?
# NOTE: this is duplicate from the .broker.norm_trade_records() # NOTE: this is duplicate from the .broker.norm_trade_records()
# routine, we should factor all this parsing somewhere.. # routine, we should factor all this parsing somewhere..

View File

@ -67,9 +67,6 @@ def get_console_log(
name: str|None = None, name: str|None = None,
pkg_name: str|None = None, pkg_name: str|None = None,
with_tractor_log: bool = False, with_tractor_log: bool = False,
# ?TODO, support a "log-spec" style `str|dict[str, str]` which
# dictates both the sublogger-key and a level?
# -> see similar idea in `modden`'s usage.
**tractor_log_kwargs, **tractor_log_kwargs,
) -> logging.Logger: ) -> logging.Logger:
@ -88,21 +85,9 @@ def get_console_log(
pkg_name in name pkg_name in name
): ):
name: str = name.lstrip(f'{_proj_name}.') name: str = name.lstrip(f'{_proj_name}.')
if with_tractor_log:
tll: str|None = None
if (
with_tractor_log is not False
):
tll = level
elif maybe_actor := tractor.current_actor(
err_on_no_runtime=False,
):
tll = maybe_actor.loglevel
if tll:
t_log = tractor.log.get_console_log( t_log = tractor.log.get_console_log(
level=tll, level=level,
name='tractor', # <- XXX, force root tractor log! name='tractor', # <- XXX, force root tractor log!
**tractor_log_kwargs, **tractor_log_kwargs,
) )

View File

@ -2205,7 +2205,7 @@ dev = [
{ name = "pytest", specifier = ">=8.3.5" }, { name = "pytest", specifier = ">=8.3.5" },
{ name = "stackscope", specifier = ">=0.2.2,<0.3" }, { name = "stackscope", specifier = ">=0.2.2,<0.3" },
{ name = "typing-extensions", specifier = ">=4.14.1" }, { name = "typing-extensions", specifier = ">=4.14.1" },
{ name = "xonsh", specifier = ">=0.22.2" }, { name = "xonsh", specifier = ">=0.22.1" },
] ]
devx = [ devx = [
{ name = "greenback", specifier = ">=1.2.1,<2" }, { name = "greenback", specifier = ">=1.2.1,<2" },
@ -2217,7 +2217,7 @@ repl = [
{ name = "prompt-toolkit", specifier = ">=3.0.50" }, { name = "prompt-toolkit", specifier = ">=3.0.50" },
{ name = "psutil", specifier = ">=7.0.0" }, { name = "psutil", specifier = ">=7.0.0" },
{ name = "pyperclip", specifier = ">=1.9.0" }, { name = "pyperclip", specifier = ">=1.9.0" },
{ name = "xonsh", specifier = ">=0.22.2" }, { name = "xonsh", specifier = ">=0.22.1" },
] ]
testing = [ testing = [
{ name = "pexpect", specifier = ">=4.9.0,<5" }, { name = "pexpect", specifier = ">=4.9.0,<5" },
@ -2469,8 +2469,8 @@ wheels = [
[[package]] [[package]]
name = "xonsh" name = "xonsh"
version = "0.22.3" version = "0.22.1"
source = { git = "https://github.com/xonsh/xonsh.git?branch=main#b446946fd94c3913e002318db1d1b41ee4fa1f9a" } source = { git = "https://github.com/xonsh/xonsh.git?branch=main#336658ff0919f8d7bb96d581136d37d470a8fe99" }
[[package]] [[package]]
name = "yapic-json" name = "yapic-json"