Skip to content

latent.registry.flows

Flow registry with caching for CLI discovery and execution.

Provides auto-discovery of @flow-decorated functions from the project's flows/ directory, an in-memory registry with disk caching, and smart type resolution for CLI argument parsing.

Classes

FlowEntry

FlowEntry(name: str, module_path: str, function_name: str, description: str = '', tags: list[str] = list(), version: str | None = None, parameters: list[ParameterInfo] = list(), has_catalog: bool = False, has_parameters_yaml: bool = False, _flow_fn: Callable | None = None)

Metadata for a registered flow.

FlowRegistry

FlowRegistry()

In-memory registry of discovered @flow-decorated functions.

ParameterInfo

ParameterInfo(name: str, type_annotation: str, default: Any | None = None, has_default: bool = False, is_optional: bool = False, description: str = '', raw_type: type | None = None)

Metadata for a single flow parameter.

Functions

discover_and_register_flows

discover_and_register_flows(force_import: bool = False) -> dict[str, FlowEntry]

Discover all flows from the user's flows/ directory.

Uses cached registry when possible. Set force_import=True for commands that need the actual _flow_fn references (like latent run).

load_cached_registry

load_cached_registry(workspace_root: Path, flows_dir: Path) -> dict[str, FlowEntry] | None

Load registry from cache if content hash matches.

parse_extra_args

parse_extra_args(args: list[str], entry: FlowEntry) -> dict[str, Any]

Parse CLI --flags and resolve types based on FlowEntry metadata.

resolve_cli_value

resolve_cli_value(value_str: str, param: ParameterInfo) -> Any

Convert a CLI string value to the appropriate Python type.

save_registry_cache

save_registry_cache(workspace_root: Path, flows_dir: Path, flows: dict[str, FlowEntry])

Write registry to cache with content hash.

Methods

FlowRegistry.all

all() -> dict[str, FlowEntry]

FlowRegistry.clear

clear()

FlowRegistry.get

get(name: str) -> FlowEntry | None

FlowRegistry.register

register(name: str, entry: FlowEntry)

Attributes

CACHE_DIR

CACHE_FILE

LEGACY_CACHE_PATH