Skip to content

Removed interface factory - #333

Merged
rozyczko merged 7 commits into
release-3.0from
294-remove-if
Oct 22, 2026
Merged

rozyczko merged 7 commits into
release-3.0from
294-remove-if

Conversation

@rozyczko

@rozyczko rozyczko commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Code:

  • Removed InterfaceFactory and associated logic.
    This change moved the calculator ownership into the technique specific libraries, allowing a clear separation of responsibilities.

  • Removed Parameter's callback keyword and value_no_call_back

  • Dropped AnalysisBase(interface=...) and made AnalysisBase arguments keyword-only.

Documentation:

  • Added a detailed new user guide page, external-calculators.md, explaining how to connect an external calculator to an EasyScience model and Fitter. With diagrams, examples, and best practices for integration and fit control.

Cleanup:

  • Removed a number of legacy examples.

@rozyczko rozyczko added [scope] enhancement Adds/improves features (major.MINOR.patch) [area] fitting Umbrella for fitting related work [priority] high Should be prioritized soon labels Oct 16, 2026
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.96%. Comparing base (bdc119f) to head (801d28d).
⚠️ Report is 2 commits behind head on release-3.0.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##           release-3.0     #333      +/-   ##
===============================================
- Coverage        94.08%   93.96%   -0.13%     
===============================================
  Files               50       48       -2     
  Lines             4094     3946     -148     
===============================================
- Hits              3852     3708     -144     
+ Misses             242      238       -4     
Flag Coverage Δ
unittests 93.96% <100.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/easyscience/fitting/engine_base.py 100.00% <ø> (ø)
src/easyscience/fitting/fitter.py 96.03% <ø> (ø)
src/easyscience/job/analysis.py 100.00% <100.00%> (ø)
src/easyscience/variable/descriptor_base.py 95.74% <ø> (ø)
src/easyscience/variable/parameter.py 95.22% <ø> (-0.03%) ⬇️

@rozyczko
rozyczko marked this pull request as ready for review October 16, 2026 12:12
@rozyczko

rozyczko commented Oct 21, 2026 •

Copy link
Copy Markdown
Member Author

Thinking about Model with fit function being the only thing passed. This means Fitter would treat Model as callable (if the second argument - fit_function wasn't defined). But I assume the whole point here is to have Model be pure state only.
The calculator is in the library and it READS the model. If ModelBase got a fit_function slot, the model would hold a reference to a calculator again. We just removed this coupling!

The model would have to know its calculator and have to reach a backend. Either the model stores a calculator reference, which is exactly what we have removed, or it must find it through (hidden) global state.
This would break the "pure state" contract.

I mean... we could easily do it: Fitter(fit_object, fit_function=None). When no callable function is given, we'd use the model itself if it is callable, otherwise raise a TypeError saying a fit function is required.

So from the user POV this is easier, but internally, it introduces things we wanted to be removed in the first place.

Also, a model may have many fit functions (e.g. in reflectometry my model would have separete callables per channel and per resolution function). A single method per model won't be abnle to describe that.

Serialization - we would have to explicitly skip the calculator slot and from_dict would decode an empty, calculator-free model. You'd have to reattach it. Smells bad.

Currently, the model stays pure state. The fitter knows only get_fit_parameters() and a callable. Fitter can easily be tested with a lambda.

@rozyczko
rozyczko requested a review from damskii9992 October 21, 2026 18:57
Comment thread docs/docs/user-guide/external-calculators.md Outdated

@damskii9992 damskii9992 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just some tests that needs to be removed. But otherwise this LGTM.

Comment thread tests/unit/job/test_job.py Outdated
Comment thread tests/unit/variable/test_parameter.py Outdated
Comment thread tests/unit/variable/test_parameter.py Outdated
@rozyczko
rozyczko merged commit 51868a9 into release-3.0 Oct 22, 2026
28 checks passed
@rozyczko
rozyczko deleted the 294-remove-if branch October 22, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[area] fitting Umbrella for fitting related work [priority] high Should be prioritized soon [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants