🟢 config/conf.toml for updated UI font size and graphics throttle
🛠️ piker/cli/__init__.py -> Changed transport from UDP to TCP in service manager 🛠️ piker/data/_symcache.py -> Added recursive dict cleaning for TOML serialization 🛠️ piker/fsp/_api.py -> Hash-based key for shared memory buffers (macOS compatibility) 🛠️ piker/tsp/__init__.py -> Hash-based key for history buffers for macOS compatibility 🛠️ piker/ui/_display.py -> Modified SHM name assertion for macOS compatibilitymacos_fixes_2025
							parent
							
								
									db77d7ab29
								
							
						
					
					
						commit
						61edb5cb19
					
				|  | @ -4,9 +4,11 @@ tsdb.host = 'localhost' | |||
| tsdb.grpc_port = 5995 | ||||
| 
 | ||||
| [ui] | ||||
| # set custom font + size which will scale entire UI | ||||
| # set custom font + size which will scale entire UI~ | ||||
| # font_size = 16 | ||||
| # font_size = 32 | ||||
| # font_name = 'Monospaced' | ||||
| 
 | ||||
| # colorscheme = 'default'  # UNUSED | ||||
| # graphics.update_throttle = 60  # Hz  # TODO | ||||
| # graphics.update_throttle = 120  # Hz  #PENDING TODO | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,20 @@ | |||
| #!/usr/bin/env bash | ||||
| # macOS wrapper for piker to handle missing XDG_RUNTIME_DIR | ||||
| 
 | ||||
| # Set up runtime directory for macOS if not already set | ||||
| if [ -z "$XDG_RUNTIME_DIR" ]; then | ||||
|     # Use macOS standard temp directory with user-specific subdirectory | ||||
|     export XDG_RUNTIME_DIR="/tmp/piker-runtime-$(id -u)" | ||||
| 
 | ||||
|     # Create the directory if it doesn't exist | ||||
|     if [ ! -d "$XDG_RUNTIME_DIR" ]; then | ||||
|         mkdir -p "$XDG_RUNTIME_DIR" | ||||
|         # Set proper permissions (only user can access) | ||||
|         chmod 700 "$XDG_RUNTIME_DIR" | ||||
|     fi | ||||
| 
 | ||||
|     echo "Set XDG_RUNTIME_DIR to: $XDG_RUNTIME_DIR" | ||||
| fi | ||||
| 
 | ||||
| # Run piker with all passed arguments | ||||
| exec uv run piker "$@" | ||||
|  | @ -183,8 +183,8 @@ def pikerd( | |||
|                 registry_addrs=regaddrs, | ||||
|                 loglevel=loglevel, | ||||
|                 debug_mode=pdb, | ||||
|                 enable_transports=['uds'], | ||||
|                 # enable_transports=['tcp'], | ||||
|                 # enable_transports=['uds'], | ||||
|                 enable_transports=['tcp'], | ||||
|             ) as service_mngr, | ||||
|         ): | ||||
|             assert service_mngr | ||||
|  |  | |||
|  | @ -92,6 +92,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] = { | ||||
|  | @ -112,7 +121,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: | ||||
|  |  | |||
|  | @ -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, | ||||
|  |  | |||
|  | @ -1257,13 +1257,17 @@ async def manage_history( | |||
|     service: str = name.rstrip(f'.{mod.name}') | ||||
|     fqme: str = mkt.get_fqme(delim_char='') | ||||
| 
 | ||||
|     # Create a short hash of the fqme for macOS compatibility | ||||
|     import hashlib | ||||
|     fqme_hash = hashlib.md5(fqme.encode()).hexdigest()[:8] | ||||
| 
 | ||||
|     # (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'{uuid[:8]}_{fqme_hash}.h', | ||||
| 
 | ||||
|         # use any broker defined ohlc dtype: | ||||
|         dtype=getattr(mod, '_ohlc_dtype', def_iohlcv_fields), | ||||
|  | @ -1282,7 +1286,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'{uuid[:8]}_{fqme_hash}.r', | ||||
| 
 | ||||
|         # use any broker defined ohlc dtype: | ||||
|         dtype=getattr(mod, '_ohlc_dtype', def_iohlcv_fields), | ||||
|  |  | |||
|  | @ -212,7 +212,9 @@ 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'] | ||||
|     # NOTE: Changed for macOS compatibility with shortened shm names | ||||
|     # assert 'hist' in hist_viz.shm.token['shm_name'] | ||||
|     assert hist_viz.shm.token['shm_name'].endswith('.h') | ||||
|     # name: str = hist_viz.name | ||||
| 
 | ||||
|     # TODO: seems this is more reliable at keeping the slow | ||||
|  |  | |||
|  | @ -0,0 +1,20 @@ | |||
| #!/usr/bin/env bash | ||||
| # macOS wrapper for pikerd to handle missing XDG_RUNTIME_DIR | ||||
| 
 | ||||
| # Set up runtime directory for macOS if not already set | ||||
| if [ -z "$XDG_RUNTIME_DIR" ]; then | ||||
|     # Use macOS standard temp directory with user-specific subdirectory | ||||
|     export XDG_RUNTIME_DIR="/tmp/piker-runtime-$(id -u)" | ||||
| 
 | ||||
|     # Create the directory if it doesn't exist | ||||
|     if [ ! -d "$XDG_RUNTIME_DIR" ]; then | ||||
|         mkdir -p "$XDG_RUNTIME_DIR" | ||||
|         # Set proper permissions (only user can access) | ||||
|         chmod 700 "$XDG_RUNTIME_DIR" | ||||
|     fi | ||||
| 
 | ||||
|     echo "Set XDG_RUNTIME_DIR to: $XDG_RUNTIME_DIR" | ||||
| fi | ||||
| 
 | ||||
| # Run pikerd with all passed arguments | ||||
| exec uv run pikerd "$@" | ||||
		Loading…
	
		Reference in New Issue