Export FLOWS and build from the top-level fluksio package
A test of the declarations had to import them from fluksio.sdk while the guide teaches `from fluksio import ...`. The worker's inert module gets the same two names so a module importing them still loads inside a node. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QgG6TJw5qBZzaLghQSRVrq
This commit is contained in:
@@ -4,7 +4,8 @@ Two audiences, one import name. In a research repository, ``from fluksio
|
||||
import Port, node, Flow`` is the authoring API: it says which of your existing
|
||||
functions are nodes and which nodes make up a flow, and ``fluksio sync``
|
||||
uploads what it finds. Those names come from :mod:`fluksio.sdk`, which imports
|
||||
nothing but the standard library.
|
||||
nothing but the standard library. ``FLOWS`` and ``build`` come with them, so a
|
||||
test can check the declarations without an engine.
|
||||
|
||||
Inside a node, ``import fluksio`` is not this package at all: the worker
|
||||
installs a reporter of its own under that name before any node code runs, so
|
||||
@@ -24,7 +25,7 @@ from importlib.metadata import PackageNotFoundError
|
||||
from importlib.metadata import version as _version
|
||||
from typing import Any
|
||||
|
||||
from fluksio.sdk import Flow, Port, node, use
|
||||
from fluksio.sdk import FLOWS, Flow, Port, build, node, use
|
||||
|
||||
try:
|
||||
__version__ = _version("fluksio")
|
||||
@@ -32,8 +33,10 @@ except PackageNotFoundError: # pragma: no cover - a checkout that was never ins
|
||||
__version__ = "0.0.0+unknown"
|
||||
|
||||
__all__ = [
|
||||
"FLOWS",
|
||||
"Flow",
|
||||
"Port",
|
||||
"build",
|
||||
"emit",
|
||||
"load_artifact",
|
||||
"node",
|
||||
|
||||
@@ -364,3 +364,15 @@ def test_a_node_in_a_script_run_directly_is_refused_at_sync_not_at_import():
|
||||
flow.document()
|
||||
with pytest.raises(SyncError, match="run directly"):
|
||||
flow.shims()
|
||||
|
||||
|
||||
def test_the_registry_and_the_builder_come_with_the_authoring_import():
|
||||
"""A test of the declarations needs no second import path."""
|
||||
import fluksio
|
||||
import fluksio.sdk
|
||||
|
||||
flow = a_flow()
|
||||
|
||||
assert fluksio.FLOWS is fluksio.sdk.FLOWS
|
||||
assert fluksio.FLOWS["train"] is flow
|
||||
assert fluksio.build(flow) == fluksio.sdk.build(flow)
|
||||
|
||||
Reference in New Issue
Block a user