Skip to content

Refactor/spec runtime api cleanup#287

Open
HenningScheufler wants to merge 14 commits into
stack/python_archfrom
refactor/spec-runtime-api-cleanup
Open

Refactor/spec runtime api cleanup#287
HenningScheufler wants to merge 14 commits into
stack/python_archfrom
refactor/spec-runtime-api-cleanup

Conversation

@HenningScheufler
Copy link
Copy Markdown
Collaborator

No description provided.

The attr-defined ignore is no longer needed — mypy now reports it as
unused. Pre-commit was failing across the tree because of it.
The `solve` verb suggested a side-effectful action; `sort` better
describes the pure topological ordering the protocol returns.

Updates the Protocol and the NetworkxTopologicalSorter impl, plus the
four call sites: graph/validator.py, graph/operations_dag.py,
initialization/execution.py, and the test in test_graph_module.py.
Adds framework/graph/dag_resolver.py with DAGResolver,
CyclicDependencyError, MissingDependencyError, and the
collect_tagged_ops / infer_target_scope / build_global_graph /
sort_global / rebuild_builder helpers used by the new operation-graph
resolution path.

Adds an Operation.before field so model operations can declare
"must-run-before" constraints alongside depends_on; the resolver edges
out from name -> before_target. Default is an empty list.

Moves build_dependency_digraph from framework/graph/builder.py into
validator.py (its only caller) and deletes builder.py. Updates
framework/graph/__init__.py to export the new dag_resolver symbols and
to source build_dependency_digraph from validator.
Aligns the field with Python naming conventions and with the
'runtime' resource name already used by InitResult and the lazy-init
callers. Updates the one production caller in initialization/execution.py
and the three test assertions in test_initialization/test_execution.py.
The init() helper produced 'resource' category InitSteps but its name
collided with the unrelated StagedInit variable conventionally also
called 'init'. Renames the function to lazy() to describe what it
actually does (defers construction until the lazy-init phase).

Adds operator() — same shape as field()/model() but with the
'operators.' prefix — completing the four-quadrant
field/operator/model/lazy taxonomy.

Renames InitializerBuilder.add_initializer() to add_resource() to align
with the underlying category name.

Updates initialization/__init__.py exports and the test_helpers /
test_staged_init call sites.
…chitecture

Introduces ModelSpec/ModelRuntime and SolverSpec/SolverRuntime as the new
framework API, and removes the old Model/Solver/Simulation/Domain/
CouplingInterface classes in the same change. No API-coexistence window.

ModelSpec/SolverSpec are immutable definitions registered once at module
import; the corresponding Runtime objects hold all mutable per-instance
state, allowing multiple solver runs to coexist without shared state.

Shared helper modules:
- config_injection.py: discovers BaseConfig parameters in operation
  signatures and resolves them from runtime.config (handles both direct
  instances and SimpleNamespace bundles).
- dependency_resolver.py: resolves Depends() markers and Annotated
  Context markers with scope-aware caching (time_step/iteration/operation).

Restructures Operation to use OperationMetadata as the single source of
truth for name, numbering, dependencies, and visualisation hints.
OperationNumber gains __str__; OperationMetadata gains an optional
'before' field for run-before ordering alongside depends_on.

staged_init.LoadResult.validate() now calls the real validate_models()
instead of raising NotImplementedError; optional_models are registered
as ModelRuntime instances in ConfigContext with duplicate-key detection.

Adds the dummy_solver integration suite (configs, four model variants,
init pipeline, end-to-end tests) as the reference example of the new API.

Removed:
- framework/model.py, solver.py, simulation.py, couplingInterface.py,
  domain.py, solver_factory.py
- their unit tests in test/framework/components/
- old-API integration tests under test/framework/integration/
The neon_pde build dependency is not required by the framework refactor;
removing it lets `uv sync` succeed in environments without the NeoN C++
submodule available.

Wraps the neofoam_bindings import in try/except so the package can be
imported in pure-Python contexts (e.g. running framework tests without
a built C++ stack). Callers that actually need the bindings still fail
at use-site.
@github-actions
Copy link
Copy Markdown

Deployed test documentation to https://exasim-project.com/NeoFOAM/Build_PR_287

@HenningScheufler HenningScheufler changed the base branch from refactor/spec-runtime-replacement to stack/python_arch May 23, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant