SDK: sync and run import the declaring module in a child process

The command line no longer imports a research module, so import-time GPU work
ends with a short-lived child instead of holding a CUDA context for the length
of a followed run. fluksio.sdk.declare starts the child, which writes each
flow's document and shims as JSON; Declared stands in for Flow in sync().
Errors keep their type and message, a child's traceback reaches the user.

Claude-Session: https://claude.ai/code/session_01SSi5AvZ7pFmySK8zy3NPMh
This commit is contained in:
2026-10-28 08:11:14 +01:00
parent 6b8473f207
commit 361ef35d58
8 changed files with 364 additions and 24 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ from pathlib import Path
from typing import Any
from urllib.parse import quote
from fluksio.sdk import MARKER, Flow, SyncError
from fluksio.sdk import MARKER, Declared, Flow, SyncError
__all__ = [
"Client",
@@ -784,7 +784,7 @@ def ignored(directory: Path) -> frozenset[Path]:
def sync(
flows: Iterable[Flow],
flows: Iterable[Flow | Declared],
client: Client,
*,
repo: str = "",
@@ -813,7 +813,7 @@ def sync(
def _sync_one(
target: Flow,
target: Flow | Declared,
client: Client,
origin: dict[str, Any],
*,
@@ -908,7 +908,7 @@ def _moved_code(stored: dict[str, Any] | None, document: dict[str, Any]) -> list
def _refuse_on_drift(
client: Client, target: Flow, definition: dict[str, Any]
client: Client, target: Flow | Declared, definition: dict[str, Any]
) -> dict[str, str]:
"""Stop before overwriting work that was done somewhere else.