Skip to content

[Core] Enable analysis stage without solver#14318

Open
rubenzorrilla wants to merge 12 commits intomasterfrom
core/analysis-stage-wo-solver
Open

[Core] Enable analysis stage without solver#14318
rubenzorrilla wants to merge 12 commits intomasterfrom
core/analysis-stage-wo-solver

Conversation

@rubenzorrilla
Copy link
Copy Markdown
Member

📝 Description

Description

This PR enables running AnalysisStage without requiring a solver by introducing a Null Object pattern as more clean alternative to #14150.

Previously, _CreateSolver() was expected to always return a valid solver and raised an exception otherwise. This prevented the implementation of analysis stages that do not require a solver. A PythonNullSolver is added and used as the default solver in the base AnalysisStage. This allows solver calls to be executed unconditionally while safely performing no-ops when no solver is required.

With this change:

  • Solver becomes optional by design.
  • The execution pipeline remains unchanged (no more changes in AnalysisStage).
  • No additional branching (i.e., if solver is not None) is introduced

In short, only change is that solver is now always present (real or "null").

Implementation details

  • Added python_null_solver.py containing PythonNullSolver and its singleton instance PYTHON_NULL_SOLVER to enforce statelessness and avoid allocations.
  • Modified AnalysisStage._CreateSolver() to return PYTHON_NULL_SOLVER by default
  • Kept lazy initialization in _GetSolver()
  • Added _HasSolver() utility method to distinguish between real and null solver
  • PythonNullSolver dynamically handles any method via __getattr__, returning a no-op callable. This enables dynamic handling of Python solver interface (just in case this changes in the future).
  • Keeps full backward compatibility for existing solver-based stages overriding the _CreateSolver() method.

Tests have been added accordingly.

@loumalouomega
Copy link
Copy Markdown
Member

CI is failing

@rubenzorrilla
Copy link
Copy Markdown
Member Author

CI is failing

It is because I also took the chance to remove the 5 years old deprecated handling of output processes outside the corresponding output_processes block. Some old tests were relying on it (something I didn't expect to happen...). I'll do this in a separate PR.

@rubenzorrilla rubenzorrilla requested a review from a team as a code owner March 25, 2026 23:40
@loumalouomega
Copy link
Copy Markdown
Member

Once Ci passes ping me and I will approve

Copy link
Copy Markdown
Member

@roigcarlo roigcarlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 . But not to the CI

@rubenzorrilla rubenzorrilla requested a review from a team as a code owner March 27, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants