piphi-runtime-kit-python 0.4.4__py3-none-any.whl → 0.4.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,15 +3,25 @@ from __future__ import annotations
3
3
  """Opinionated beginner-friendly starter helpers for PiPhi runtimes."""
4
4
 
5
5
  from dataclasses import dataclass, field
6
+ from pathlib import Path
6
7
  from typing import Any
7
8
 
8
- from .config_sync import ConfigSyncCoordinator
9
+ import httpx
10
+
11
+ from .config_sync import (
12
+ DEFAULT_RUNTIME_VOLUME_DIR,
13
+ ConfigSyncCoordinator,
14
+ RuntimeConfigRehydrateResult,
15
+ SnapshotApplyCallable,
16
+ rehydrate_runtime_configs,
17
+ )
9
18
  from .context import RuntimeContext
10
19
  from .events import DEFAULT_CORE_BASE_URL as DEFAULT_EVENTS_CORE_BASE_URL, EventClient
11
20
  from .health import build_runtime_diagnostics_response, build_runtime_health_response
21
+ from .lifespan import DEFAULT_CORE_CLIENT_TIMEOUT_SECONDS
12
22
  from .registry import RuntimeRegistry
13
23
  from .telemetry import DEFAULT_CORE_BASE_URL as DEFAULT_TELEMETRY_CORE_BASE_URL, TelemetryClient
14
- from ..schemas import RuntimeEntitiesResponse
24
+ from ..schemas import RuntimeConfig, RuntimeConfigSnapshot, RuntimeEntitiesResponse
15
25
 
16
26
 
17
27
  @dataclass(slots=True)
@@ -92,6 +102,37 @@ class RuntimeStarter:
92
102
  commands=commands,
93
103
  )
94
104
 
105
+ async def rehydrate_configs(
106
+ self,
107
+ *,
108
+ client: httpx.AsyncClient,
109
+ apply_snapshot: SnapshotApplyCallable,
110
+ config_model: type[RuntimeConfig] = RuntimeConfig,
111
+ snapshot_model: type[Any] = RuntimeConfigSnapshot,
112
+ timeout_seconds: float = DEFAULT_CORE_CLIENT_TIMEOUT_SECONDS,
113
+ snapshot_path: str | Path | None = None,
114
+ snapshot_volume_dir: str | Path = DEFAULT_RUNTIME_VOLUME_DIR,
115
+ raise_core_errors: bool = False,
116
+ ) -> RuntimeConfigRehydrateResult:
117
+ """Load startup configs from the mounted snapshot and then Core.
118
+
119
+ This is the recommended starter-level entry point. Integration authors
120
+ provide their typed config model and apply callback; the starter supplies
121
+ the shared runtime context and Core base URL.
122
+ """
123
+ return await rehydrate_runtime_configs(
124
+ runtime_context=self.runtime,
125
+ client=client,
126
+ apply_snapshot=apply_snapshot,
127
+ config_model=config_model,
128
+ snapshot_model=snapshot_model,
129
+ core_base_url=self.core_base_url,
130
+ timeout_seconds=timeout_seconds,
131
+ snapshot_path=snapshot_path,
132
+ snapshot_volume_dir=snapshot_volume_dir,
133
+ raise_core_errors=raise_core_errors,
134
+ )
135
+
95
136
 
96
137
  def build_entities_response(
97
138
  *,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: piphi-runtime-kit-python
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: PiPhi Network runtime integration helpers
5
5
  Keywords: piphi,runtime,integration,iot
6
6
  Author-Email: KelvinSan <support@piphi.network>
@@ -1,7 +1,7 @@
1
- piphi_runtime_kit_python-0.4.4.dist-info/METADATA,sha256=itnYk2BZoSxO2w_x--KH4i937xkqhT4_HT5GZZKy-cA,30849
2
- piphi_runtime_kit_python-0.4.4.dist-info/WHEEL,sha256=Z36eTX6lG3PITRleSd5hAZHCcz52yg3c0JQVxKBbLW0,90
3
- piphi_runtime_kit_python-0.4.4.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
- piphi_runtime_kit_python-0.4.4.dist-info/licenses/LICENSE,sha256=pS6szQI4X7qAin1ODdoDp-XwZvsFy6ZZ28-JAwGHgzo,1070
1
+ piphi_runtime_kit_python-0.4.6.dist-info/METADATA,sha256=yQj3dR1JQDK4GyTFWfgoV7uGAHYUd2Qg1V_TXjNQujg,30849
2
+ piphi_runtime_kit_python-0.4.6.dist-info/WHEEL,sha256=Z36eTX6lG3PITRleSd5hAZHCcz52yg3c0JQVxKBbLW0,90
3
+ piphi_runtime_kit_python-0.4.6.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
+ piphi_runtime_kit_python-0.4.6.dist-info/licenses/LICENSE,sha256=pS6szQI4X7qAin1ODdoDp-XwZvsFy6ZZ28-JAwGHgzo,1070
5
5
  piphi_runtime_kit_python/__init__.py,sha256=nw9We1D1bN6aucvw2mlgux3rs4znSIH-RyagYSbDgWE,6866
6
6
  piphi_runtime_kit_python/adapters/__init__.py,sha256=3jBhPZSBN3Qo7MKHlxAol2jPU3cK23BXHR2oTlircsw,361
7
7
  piphi_runtime_kit_python/adapters/fastapi.py,sha256=1QcOBYprg6AmQVrkI8g61NIelBB_7BTbdvNaMvG2-s8,2098
@@ -20,9 +20,9 @@ piphi_runtime_kit_python/runtime/identity.py,sha256=cth0_QHR9R5LTdp-6DPD1IhM8cYJ
20
20
  piphi_runtime_kit_python/runtime/lifespan.py,sha256=mVSdZZAS66xlcnlzAwkztFjzw_l2pyLrJqULJsb0Ezk,2850
21
21
  piphi_runtime_kit_python/runtime/mqtt.py,sha256=JKMN5zxg1BcOidu7TaYnuRD3HuoAJ_WcvXMTTSlAteo,6069
22
22
  piphi_runtime_kit_python/runtime/registry.py,sha256=8rKLCWt1_0SlDm3TepEUGDliOhVEDTv_zYR0kxLpSHM,3373
23
- piphi_runtime_kit_python/runtime/starter.py,sha256=j5C4GOOcRHNLJ-HYu8fmf3bE00baDOzAfuq1MefT-Jg,4651
23
+ piphi_runtime_kit_python/runtime/starter.py,sha256=VECNCPAleIrDoaA1AEXX7Jp5RFNtjNWkKthIGkOGRIM,6234
24
24
  piphi_runtime_kit_python/runtime/state.py,sha256=4xvQGTT59DF9rXHAtM3kDyV_UGg2a9tLPvGiCp_PFMc,674
25
25
  piphi_runtime_kit_python/runtime/tasks.py,sha256=gMd-2K96jMU8tCPvI12xdWxuyNt5gsLDss2QWOoM94k,1241
26
26
  piphi_runtime_kit_python/runtime/telemetry.py,sha256=RN6SFrhmAZ7aJLyioQMBzJEFsxQgOjjA1pV5qNeaR4E,4279
27
27
  piphi_runtime_kit_python/schemas.py,sha256=9jlsfmvz-O2YeoB0SVopXY7NhFlb1zgynez0NXEZkVE,9849
28
- piphi_runtime_kit_python-0.4.4.dist-info/RECORD,,
28
+ piphi_runtime_kit_python-0.4.6.dist-info/RECORD,,