Compare commits

...

4 Commits

Author SHA1 Message Date
Gud Boi 61bef6d5f5 Strip `None` values from symcache dict before TOML write
(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code

Note that (again) this patch was orig by @dnks and broken out from
a larger commit which added unnecessary/out-of-scope changes we didn't
end up requiring.
2026-03-11 10:56:22 -04:00
Gud Boi 52e65dbe0d Use `md5` hashed shm keys for macOS compat
Shorten SHM buffer key names to fit Darwin's 31
char filename limit by hashing the `fqme`/content
portion with `md5` and truncating to 8 hex chars.

Deats,
- `.fsp._api`: replace `piker.{actor}[{uuid}].{sym}`
  format with `{uuid[:8]}_{hash}.fsp`
- `.tsp._history`: add `platform.system()` check to
  conditionally shorten `.hist`/`.rt` keys on Darwin
  while keeping the full key format on Linux

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

NOTE that this patch was orig by @dnks and broken out from a larger
commit which added unnecessary/out-of-scope changes we didn't end up
requiring.
2026-03-11 10:56:22 -04:00
Gud Boi 8b3365a249 Check for a `.hist` suffix in shm file names
That is, in-mem history buffer files should have a `.hist` suffix (which
was added back instead of the weird `.h` change from the rebased
8352d89e, initially providing the macos support fix).

I'm pretty sure we can afford the 3 extra chars if we're already
truncating to a max 16 char `key: str = f'{uuid[:8]}_{fqme_hash}'`, per
@goodboy's edit from the original key-truncation approach in the
original original @dnks patch: 75d8582b).
2026-03-11 10:55:04 -04:00
Gud Boi 2ceec5b9c0 gitignore: start a "tina sw" section with `vscode` settings 2026-03-11 10:55:04 -04:00
5 changed files with 34 additions and 8 deletions

4
.gitignore vendored
View File

@ -102,7 +102,6 @@ ENV/
# mypy
.mypy_cache/
.vscode/settings.json
# all files under
.git/
@ -122,6 +121,9 @@ Session.vim
# wtv git hosting service tho?
gitea/
# ------ tina-land ------
.vscode/settings.json
# ------ macOS ------
# Finder metadata
**/.DS_Store

View File

@ -105,6 +105,15 @@ class SymbologyCache(Struct):
def write_config(self) -> None:
def clean_dict_for_toml(d):
'''Remove None values from dict recursively for TOML serialization'''
if isinstance(d, dict):
return {k: clean_dict_for_toml(v) for k, v in d.items() if v is not None}
elif isinstance(d, list):
return [clean_dict_for_toml(item) for item in d if item is not None]
else:
return d
# put the backend's pair-struct type ref at the top
# of file if possible.
cachedict: dict[str, Any] = {
@ -125,7 +134,9 @@ class SymbologyCache(Struct):
dct = cachedict[key] = {}
for key, struct in table.items():
dct[key] = struct.to_dict(include_non_members=False)
raw_dict = struct.to_dict(include_non_members=False)
# Clean None values for TOML compatibility
dct[key] = clean_dict_for_toml(raw_dict)
try:
with self.fp.open(mode='wb') as fp:

View File

@ -200,9 +200,13 @@ def maybe_mk_fsp_shm(
)
# (attempt to) uniquely key the fsp shm buffers
# Use hash for macOS compatibility (31 char limit)
import hashlib
actor_name, uuid = tractor.current_actor().uid
uuid_snip: str = uuid[:16]
key: str = f'piker.{actor_name}[{uuid_snip}].{sym}.{target.name}'
# Create short hash of sym and target name
content = f'{sym}.{target.name}'
content_hash = hashlib.md5(content.encode()).hexdigest()[:8]
key: str = f'{uuid[:8]}_{content_hash}.fsp'
shm, opened = maybe_open_shm_array(
key,

View File

@ -32,6 +32,7 @@ from __future__ import annotations
from datetime import datetime
from functools import partial
from pathlib import Path
import platform
from pprint import pformat
from types import ModuleType
from typing import (
@ -1380,13 +1381,20 @@ async def manage_history(
service: str = name.rstrip(f'.{mod.name}')
fqme: str = mkt.get_fqme(delim_char='')
key: str = f'piker.{service}[{uuid[:16]}].{fqme}'
# use a short hash of the `fqme` to deal with macOS
# file-name-len limit..
if platform.system() == 'Darwin':
import hashlib
fqme_hash: str = hashlib.md5(fqme.encode()).hexdigest()[:8]
key: str = f'{uuid[:8]}_{fqme_hash}'
# (maybe) allocate shm array for this broker/symbol which will
# be used for fast near-term history capture and processing.
hist_shm, opened = maybe_open_shm_array(
size=_default_hist_size,
append_start_index=_hist_buffer_start,
key=f'piker.{service}[{uuid[:16]}].{fqme}.hist',
key=f'{key}.hist',
# use any broker defined ohlc dtype:
dtype=getattr(mod, '_ohlc_dtype', def_iohlcv_fields),
@ -1405,7 +1413,7 @@ async def manage_history(
rt_shm, opened = maybe_open_shm_array(
size=_default_rt_size,
append_start_index=_rt_buffer_start,
key=f'piker.{service}[{uuid[:16]}].{fqme}.rt',
key=f'{key}.rt',
# use any broker defined ohlc dtype:
dtype=getattr(mod, '_ohlc_dtype', def_iohlcv_fields),

View File

@ -214,7 +214,8 @@ async def increment_history_view(
hist_chart: ChartPlotWidget = ds.hist_chart
hist_viz: Viz = ds.hist_viz
# viz: Viz = ds.viz
assert 'hist' in hist_viz.shm.token['shm_name']
# Ensure the "history" shm-buffer is what's reffed.
assert hist_viz.shm.token['shm_name'].endswith('.hist')
# name: str = hist_viz.name
# TODO: seems this is more reliable at keeping the slow