Refactor/spec runtime api cleanup#287
Open
HenningScheufler wants to merge 14 commits into
Open
Conversation
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.
|
Deployed test documentation to https://exasim-project.com/NeoFOAM/Build_PR_287 |
22 tasks
…/spec-runtime-api-cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.