-
Notifications
You must be signed in to change notification settings - Fork 26
Vmec constructor -> Factory for error handling during initialization. #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
00cbf09 to
5eefaa0
Compare
9a284bb to
cf513ab
Compare
5eefaa0 to
e582b31
Compare
cf513ab to
84f3707
Compare
84f3707 to
7cab8ad
Compare
e582b31 to
c7640f1
Compare
c7640f1 to
40b8df7
Compare
7cab8ad to
1c1ef4b
Compare
Merge activity
|
1c1ef4b to
410e7f9
Compare
## Issue The Vmec constructor had absl::CHECK calls in the constructor, which terminated not just the vmecpp execution but also the python wrapper process when mgrid file loading failed, without an Exception or error message that the user could handle. ## Proposed solution ### TLDR Init method for mgrid loading ### Long version The PR refactors the `Vmec` constructor to do pure, exception free initialization (Ignoring the possibility of a memory allocation error from std::vector) and moves all sources of exceptions to places where we can report an `absl::Status`. It removes the magnetic response table constructor of Vmec, and all mgrid related initialization is instead handled in `InitMgrid`, a new method that returns the completion status. **The downside** is, that `Vmec(indata)` does no longer produce a valid object for free-boundary input files. Instead, the mgrid load is finalized during the first call to `run()` if any file IO is required. **Positive** is that the error handling is now correct for missing, invalid mgrid files, wrong resolutions etc. and returns error codes/Python exceptions instead of terminating. A long term better API would be: #244
## Issue The Vmec constructor had absl::CHECK calls in the constructor, which terminated not just the vmecpp execution but also the python wrapper process when mgrid file loading failed, without an Exception or error message that the user could handle. ## Proposed solution ### TLDR Init method for mgrid loading ### Long version The PR refactors the `Vmec` constructor to do pure, exception free initialization (Ignoring the possibility of a memory allocation error from std::vector) and moves all sources of exceptions to places where we can report an `absl::Status`. It removes the magnetic response table constructor of Vmec, and all mgrid related initialization is instead handled in `InitMgrid`, a new method that returns the completion status. **The downside** is, that `Vmec(indata)` does no longer produce a valid object for free-boundary input files. Instead, the mgrid load is finalized during the first call to `run()` if any file IO is required. **Positive** is that the error handling is now correct for missing, invalid mgrid files, wrong resolutions etc. and returns error codes/Python exceptions instead of terminating. A long term better API would be: #244
410e7f9 to
1e2a5df
Compare
7b9f562 to
cedeccc
Compare
1e2a5df to
610173e
Compare

Building a Factory function is complicated by the current situation with move/copy assignment operators.
Revisit once this is resolved.
#164