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().
- class neofoam.framework.model.spec.ModelSpec(name: str)[source]¶
Bases:
objectImmutable 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]
- 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_instancereturns this spec, matching the pattern used by ModelInstance.