Skip to content

Refactor SemOptimizer API#299

Merged
Maximilian-Stefan-Ernst merged 28 commits intoStructuralEquationModels:develfrom
alyst:refactor_semopt_api
Feb 8, 2026
Merged

Refactor SemOptimizer API#299
Maximilian-Stefan-Ernst merged 28 commits intoStructuralEquationModels:develfrom
alyst:refactor_semopt_api

Conversation

@alyst
Copy link
Contributor

@alyst alyst commented Jan 27, 2026

Extracted from #245 -- moving all engine-specific code (types) into extensions for modularity and leaner API, updating docstrings to make all optimizer help available for the user.

Requires #245 to be merged first.

@alyst alyst mentioned this pull request Jan 27, 2026
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 46.75325% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.83%. Comparing base (8b0f880) to head (1f8d2a9).
⚠️ Report is 87 commits behind head on devel.

Files with missing lines Patch % Lines
src/optimizer/abstract.jl 17.64% 14 Missing ⚠️
ext/SEMProximalOptExt/ProximalAlgorithms.jl 36.84% 12 Missing ⚠️
src/frontend/fit/SemFit.jl 0.00% 6 Missing ⚠️
ext/SEMNLOptExt/NLopt.jl 88.00% 3 Missing ⚠️
src/optimizer/optim.jl 57.14% 3 Missing ⚠️
src/frontend/fit/summary.jl 0.00% 2 Missing ⚠️
src/optimizer/Empty.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #299      +/-   ##
==========================================
- Coverage   72.94%   71.83%   -1.11%     
==========================================
  Files          50       51       +1     
  Lines        2218     2223       +5     
==========================================
- Hits         1618     1597      -21     
- Misses        600      626      +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

alyst added 6 commits January 27, 2026 12:45
It is a simple and intuitive syntax and avoids declaring new types.
Also allow specifying default constraint tolerance as `constraint_tol`.
@alyst alyst force-pushed the refactor_semopt_api branch from fe23e46 to 8dacd43 Compare January 27, 2026 20:52
@alyst alyst marked this pull request as ready for review January 27, 2026 20:55
@alyst
Copy link
Contributor Author

alyst commented Jan 27, 2026

Rebased to the current devel

@Maximilian-Stefan-Ernst
Copy link
Collaborator

I opened alyst#4 to try to streamline the access of the docs a bit further - let me know what you think.

@alyst
Copy link
Contributor Author

alyst commented Feb 3, 2026

@Maximilian-Stefan-Ernst I've merged your PR into my branch, thank you!
I think I've fixed the remaining parts:

  • added SemOptimizer_impltype(engine) which just returns the type for the engine, so the optimizer_engine_doc() can be defined just once.
  • added the SemOptimizerResult abstract basic optimization wrapper type for all engines. The engines have to implement it. It expects the optimizer to be always present.
    It does not add much overhead for Optim.jl engine and allows nice cleanups for NLoptl, Proximal
  • fixed the generation of the docs for the extensions
  • renamed SemOptimizerName to SemOptimizerMyopt in the tutorial

@alyst
Copy link
Contributor Author

alyst commented Feb 4, 2026

@Maximilian-Stefan-Ernst Thank you for another review round! Is there anything else except optimizer_engine_type to tweak?

@Maximilian-Stefan-Ernst
Copy link
Collaborator

Thanks a lot for this great set of changes! Once the last remaining comments are addressed, I would merge it.

Alexey Stukalov and others added 19 commits February 4, 2026 18:33
use SemOptimizer(engine = :NLopt) instead of SemOptimizerNLopt()
as this is a more universal scheme
optimizer_engine(): add docstring
internal method returning the type that implements SemOptimizer{engine}
update docs to use SemOptimizer
- enable docstrings from extensions
- fix references to ext. docstrings
temporary until the links are fixed

Co-authored-by: Maximilian Ernst <34346372+Maximilian-Stefan-Ernst@users.noreply.github.com>
@alyst alyst force-pushed the refactor_semopt_api branch from 2f5f464 to 5cdcbb1 Compare February 5, 2026 03:57
@alyst
Copy link
Contributor Author

alyst commented Feb 5, 2026

I've addressed the last changes + a few other things:

  • Since we have sem_optimizer_subtype(), we actually don't need to define SemOptimizer(Val{E}, ...) ctor for each engine, the generic SemOptimizer(val::Val{E}, ...) = sem_optimizer_subtype(val)(...) works just fine
  • Some small tweaks to docs
  • Remaining formatting fixes
  • Some definitions moved around to maintain a natural order

I have cleaned up the commit history and force-pushed branch, but here's the patch of what's has changed since your last code review: compare.patch

@alyst
Copy link
Contributor Author

alyst commented Feb 6, 2026

@Maximilian-Stefan-Ernst I've tweaked the FormatCheck to run in the context of the PR, rather then its target, because it looks like it was checking out incorrect commit (that's why false alarms and incorrect suggestions).
I think there are no security concerns for running the format checker in the PR context.

Fixes the format checking, because when run in pull_request_target,
it does not check out the correct commit
@alyst alyst force-pushed the refactor_semopt_api branch from afd8ee2 to 1f8d2a9 Compare February 6, 2026 00:52
@Maximilian-Stefan-Ernst
Copy link
Collaborator

Thanks a lot! Loks great, also the changes to the docs. I already merged the FormatCheck changes into main, so they take effect now.

@Maximilian-Stefan-Ernst Maximilian-Stefan-Ernst merged commit 90a8009 into StructuralEquationModels:devel Feb 8, 2026
3 of 6 checks passed
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.

2 participants