Add the fluksio CLI: serve, enroll, worker

`pip install fluksio && fluksio serve` on a machine with no Docker, no
database and no configuration — which is the case this is for: a node on
a cluster where ports cannot be opened. It makes its data directory, its
key and an admin account, prints the password once, and serves. Pairing
is `fluksio enroll <code> --portal …`, doing what the Settings screen
does through the same function, before the engine starts and without one
running — a machine nobody can route to has no browser pointed at it
either. The portal serves the dashboard, so nothing is served here.

Two things had to give way. `fastapi[standard]` pulls a cloud CLI that
wants sentry-sdk 2.x while we pinned below it — no pip resolution
existed, so the pin is lifted, which the comment beside it had been
waiting for and which also lets the Python cap go. And `uv` is now a
dependency rather than something to find on PATH: the Modules screen is
how a data scientist installs torch, and it was quietly falling back to
the engine's own interpreter.

The CLI imports nothing from the engine before it has set DATA_DIR — the
settings are built on the first import of core.config, and reaching it
early put the database in the working directory. There is a test for
that now, because the failure is silent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-21 22:51:13 +02:00
co-authored by Claude Opus 5
parent 73eeec29b1
commit dffdfce9e4
15 changed files with 1811 additions and 197 deletions
+43
View File
@@ -0,0 +1,43 @@
"""The Fluksio engine.
Inside a node, ``import fluksio`` is not this package: the worker installs a
reporter of its own under that name before any node code runs, so what a node
gets is :mod:`fluksio_worker.worker_main`'s ``emit`` and ``save_artifact``.
The stubs below stand in the same place everywhere else, and say so rather
than failing as a missing attribute.
Nothing is imported from the rest of the package here. Every ``from fluksio.x
import y`` in the engine passes through this module, and an import cycle or a
second of start-up cost would both begin here.
"""
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _version
from typing import Any
try:
__version__ = _version("fluksio")
except PackageNotFoundError: # pragma: no cover - a checkout that was never installed
__version__ = "0.0.0+unknown"
_OUTSIDE = (
"fluksio.{name}() only works inside a node: the worker running it installs "
"the real one. There is nothing to {verb} out here."
)
def emit(**ports: Any) -> None:
"""Publish values on a node's declared output ports, mid-run."""
raise RuntimeError(_OUTSIDE.format(name="emit", verb="emit to"))
def save_artifact(
source: Any, name: str = "", media_type: str = "application/octet-stream"
) -> dict[str, Any]:
"""Put bytes in the artifact store and return a reference to them."""
raise RuntimeError(_OUTSIDE.format(name="save_artifact", verb="save to"))
def load_artifact(ref: dict[str, Any]) -> bytes:
"""Read back what an artifact reference points at."""
raise RuntimeError(_OUTSIDE.format(name="load_artifact", verb="load from"))