Skip to content
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

Properly handle compute errors raised in berny optimization procedure #301

Closed

Conversation

coltonbh
Copy link
Contributor

@coltonbh coltonbh commented May 19, 2021

Description

Closes #300 .

Changelog description

Handle gradient computation errors correctly inside of BernyProcedure.compute() method

Note on decisions

  • Updated the .compute() call signature to reflect the possibility of returning a FailedOperation. While the OptimizationResult object may have success=False, it still requires trajectory and energies attributes, both of which cannot be None, and if a gradient computation fails on its first iteration it is not possible to create any AtomicResult or energies values; thus it is not possible to return an OptimizationResult object, even with success=False set on the object.

Open Questions

  • Is it necessary to declare types in the function signature using the "" employed previously in this method? Seems more canonical to declare return types without "" values unless they are the class being defined in a @classmethod. I have followed the convention already in the code but would consider updating it to remove the "" if allowed.

Status

  • [ x] Code base linted
  • [ x] Ready to go

@coltonbh
Copy link
Contributor Author

Another one for ya @loriab :)

@codecov
Copy link

codecov bot commented May 19, 2021

Codecov Report

Merging #301 (0490362) into master (cf5fdc5) will decrease coverage by 10.96%.
The diff coverage is 96.15%.

@coltonbh coltonbh force-pushed the feature-berny-handle-failed-operation branch from f658463 to d033280 Compare May 19, 2021 20:55
@coltonbh coltonbh force-pushed the feature-berny-handle-failed-operation branch from 9bac4b8 to 364f9df Compare May 19, 2021 21:25
@coltonbh
Copy link
Contributor Author

@loriab wanted to check in on this now that I'm back to developing a bit. Old PR--possible to merge in? This fixes basic error handling that was incorrect inside the berny procedure.

Thanks!

@loriab
Copy link
Collaborator

loriab commented Jun 23, 2022

Is it necessary to declare types in the function signature using the "" employed previously in this method? Seems more canonical to declare return types without "" values unless they are the class being defined in a https://github.com/classmethod. I have followed the convention already in the code but would consider updating it to remove the "" if allowed.

The "" types in function signatures are a legacy of (1) mypy being fired up for these repos only every year or two and (2) Sphinx docs not being able to do anything with signature types at the time of documentation. Without quick feedback on typing right/wrong, it was easiest to use the harmless strings. Now that #362 modernizes docs to use types from signature, I'm all for starting to convert to non-"" types. Once docs links are clean enough, we can turn on warnings-to-errors and nitpicky so that the docs build does some type checks (at least that imports work).

@loriab loriab added the Bug Something isn't working label Jun 23, 2022
Comment on lines +106 to +108
input_data = OptimizationInput(**input_data)

ret = qcng.compute_procedure(input_data, "berny", raise_error=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
input_data = OptimizationInput(**input_data)
ret = qcng.compute_procedure(input_data, "berny", raise_error=False)
input_model = OptimizationInput(**input_data)
ret = qcng.compute_procedure(input_model, "berny", raise_error=False)

"model" for pydantic obj and "data" for dict is my convention. but my aim is merely a dummy commit to trigger CI.

Copy link
Collaborator

@loriab loriab left a comment

Choose a reason for hiding this comment

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

I've hit this too. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] berny optimization procedure fails to capture compute errors correctly
2 participants