-
Notifications
You must be signed in to change notification settings - Fork 2
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
Interface re-design: state and Lux model #22
Conversation
Introducing the Lux model for parameters and state
Thank you. Looks like an accurate summary. |
I'm not sure the |
did we agree on |
Should |
@CedricTravelletti -- a first complete draft of the interface is ready. It would be good if you can take do an iteration to see if you spot any problems, in particular am I inconsistent anywhere with what we agreed? Am I missing key points? Please note that I've removed a fair bit of text from the docs and instead started drafting inline docs and added links to those. I think this will make the interface definition section much easier to read. @tjjarvinen and/or @CedricTravelletti
I think to complete this PR only the following is missing:
Everything else, including polishing the documentation, can be postponed to future PRs. It would be good to agree on the function prototypes and merge so that progress can be made in other packages. |
@cortner Thanks! I will take a pass at it during this week. I am also working on adding examples that demonstate the cases we want to adress (stateful, parametrizable, ...). No strong opinions on |
Ongoing TODO List
|
Just having a chat with @tjjarvinen -- we are recommending the following set_parameters!(calc, ps) -> calc_new
set_state!(calc, st) -> calc_new both can but need not be mutating. The caller should not assume that |
@cortner @tjjarvinen Thanks! I think what you did looks great. On my side I think this is ready for merge, and adding more examples for the new functionalities becomes a separate issue. I just fixed the tests to include the now required |
I think we do need to clarify in the documentation that the |
I fixed some issues. I try to finish my review asap. There are still couple of issues I need to check. |
I agree with @tjjarvinen on #16 |
For my part this is in a good shape and ready for a merge. The only question I have is: are we providing defaults for |
personally I prefer to keep them undefined - force implementers to provide it. |
I have no hard preference here. The only small thing is that, if we define defaults, then high-level interface code that use the old version would work straight. If we don't, then they would need an update. |
I'll wait for others to comment. I just find it very odd to provide a default when different communities use different units and each are equally legitimate... |
I agree with @cortner on this one, plus I do not see how we could provide defaults that cover all potential realistic cases. Apart from this, I think we are ready for merge. |
@mfherbst @rkurchin @jgreener64 -- could at least two of you approve this PR please so we can go ahead and merge it? |
I haven't looked at the code in detail, but the overall changes here look good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay !
No blockers from my end, just some nits.
@@ -45,7 +45,7 @@ macro generate_interface(expr) | |||
|
|||
calculator_type = nothing | |||
try | |||
calculator_type = get_calculator_type(expr) | |||
calculator_type = get_calculator_type(expr, type) | |||
catch _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to be more specific here. Catch all can lead to very hard to debug error suppressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you asking to specify which exception to catch? I don't have too strong a view here but I guess the message could be more specific, i.e. it should state what test fails and then print the exception so one can see during debugging what went wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I'm worried about the exception catching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tjjarvinen or @CedricTravelletti -- not sure which of you wrote this, but can you please push a fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are now missing the context here. What that code actually does is
try
calculator_type = get_calculator_type(expr, type)
catch _
error("Could not determine calculators type")
end
Or basically it wraps an error with a better description on what is happening, so that it is easier to debug. Rather than throwing an error message that user does not understand where it comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfherbst --- can you please comment. Personally it would be enough for me to just give a better error message, e.g. to say explicitly exactly what failed. This is something that cannot currently be seen from "Could not determine calculators type". But maybe you had more in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is a good start. My main worry is that someone makes a typo in the implementation of their calculator thereby triggering an exception at macro evaluation. Instead of standard error message they see this and line numbers and stack trace now point at the wrong spot. If that's not the case I'm ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I improved the error message. It now suggest that there is a typo in function definition related to the calculator type.
This should be now clear enough error
try
calculator_type = get_calculator_type(expr, type)
catch _
error("Possible typo (or other issue) in function definition. Could not determine the calculators type.")
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tjjarvinen - thanks for trying to fix this. I'm not convinced though that this addresses @mfherbst concern. Maybe he can comment. Maybe what could be done is to do @error
instead of error
and then rethrow the exception. That way the developer can see the stacktrace and see what went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a lot better now. I've taken the liberty to merge this to not have this drag on too long. I've opened #23.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
Thanks for merging. Can somebody update the version and register? (I'm on my phone...) |
UnitfulAtomic does not have version bound yet. It is also only used in the example, so it is not needed either. That is a one thing that missed the review. It does block registration of new version though... Note to @mfherbst, as you are doing the registration. |
This PR is an overhaul of the interface to accomodate for state and other advanced uses of calculators. It supersedes #12 .
Conclusions from the last meeting are summarized below. Please feel free to edit them.
Summary of the conslusions
ftype(system, calculator)
, with defaults. The floating point type is that of the system passed.compute
for multiple outputs:compute
DiffResults.jl
: Allow the Forces type to contain the container that should contains where we should write.