neofoam.framework.model.spec

ModelSpec — immutable model definition registered once at module import.

Provides the same decorator API as the old ModelInstance but stores only callables; all mutable state lives on ModelRuntime created per instantiate().

neofoam.framework.model.spec.Model(name: str) ModelSpec[source]

Factory: create a named ModelSpec.

class neofoam.framework.model.spec.ModelSpec(name: str)[source]

Bases: object

Immutable model definition. Read-only after module import.

Decorator methods store callables only; execution is delegated to ModelRuntime so that multiple runtimes can coexist independently.

build(func: Callable[[...], list[Any]]) Callable[[...], list[Any]][source]

Register the BUILD function.

Signature: def build(config: MyConfig) -> list[InitStep]

detect(func: Callable[[], bool]) Callable[[], bool][source]

Register the DETECT predicate.

instantiate(case_dir: Path, instance_id: str) ModelRuntime[source]

Create a fresh ModelRuntime for one instance of this spec.

Calls the @load function and wraps the result in a ModelRuntime.

load(func: Callable[[Path, str], Any]) Callable[[Path, str], Any][source]

Register the LOAD function.

Signature: def load(case_dir: Path, instance_id: str) -> SomeConfig

operation(operation_number: str | None = None, depends_on: list[str] | None = None, before: list[str] | None = None, name: str | None = None) Callable[[...], Any][source]

Decorator to register a model operation.

operation_collection(func: Callable[[...], Operations]) Callable[[...], Operations][source]

Decorator for conditional operation dispatch.

register_with(plugin_interface: type) ModelSpec[source]

Register this ModelSpec with a PluginSystem interface.

Creates a dynamic wrapper class whose get_model_instance returns this spec, matching the pattern used by ModelInstance.

resolve(func: Callable[[Any, Any], Any]) Callable[[...], Any][source]

Register the RESOLVE function.

Signature: def resolve(config: MyConfig, ctx: ConfigContext) -> MyConfig

run_detect() bool[source]

Return True if the detect predicate passes (default: True).