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

Improved error messages for bindings #9

Merged
merged 11 commits into from
Apr 6, 2021
Merged

Conversation

BenjaminRodenberg
Copy link
Member

@BenjaminRodenberg BenjaminRodenberg commented Dec 3, 2019

Migrated precice/precice#547 here.

Closes #74, closes #7

@BenjaminRodenberg BenjaminRodenberg requested review from MakisH and removed request for MakisH February 11, 2020 17:07
@BenjaminRodenberg
Copy link
Member Author

The implementation of the checks looks good. However, the checks are actually not used. I assume that the relevant code has been removed within a merge or similar?

@BenjaminRodenberg
Copy link
Member Author

The implementation of the checks looks good. However, the checks are actually not used. I assume that the relevant code has been removed within a merge or similar?

precice/precice#547 contains the relevant parts. I will manually move them to this PR.

Copy link
Member Author

@BenjaminRodenberg BenjaminRodenberg left a comment

Choose a reason for hiding this comment

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

I tried import precice from my home directory (note: not python-bindings) and got the following error:

>>> import precice
pTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "precice.pyx", line 12, in init precice
ModuleNotFoundError: No module named 'error_handling'

I assume that error_handling.py has to be added to the module properly, since otherwise it cannot be found. If you import precice from within python-bindings this is no problem, because error_handling.py is on the path.

I tried to run the examples from write_block_vector_data and ran into some more confusing error messages

error_handling.py Outdated Show resolved Hide resolved
@IshaanDesai IshaanDesai marked this pull request as draft May 2, 2020 14:13
@IshaanDesai IshaanDesai changed the title Pythonbindings error messages WIP: Pythonbindings error messages May 2, 2020
@IshaanDesai
Copy link
Member

Need to provide a good error message for: #74

@IshaanDesai IshaanDesai changed the title WIP: Pythonbindings error messages Improved error messages for bindings Dec 8, 2020
@BenjaminRodenberg
Copy link
Member Author

#74 gives an example how we can deal with certain kinds of errors and how we can also test that under certain conditions the correct kind of error is thrown.

@BenjaminRodenberg
Copy link
Member Author

Some more things that we should check (not covered by #74):

  • If we expect an id it should be an int
  • If we expect ids it should be an array_like of ints
  • If we expect a single value it should not be an array_like (non-block operations)

Probably there is much more, but this is what currently comes to my mind.

@IshaanDesai IshaanDesai marked this pull request as ready for review March 23, 2021 09:40
@IshaanDesai
Copy link
Member

At the moment only the existing assertion statements have been made more descriptive. There is scope for adding further checks and this is up for discussion

Copy link
Member Author

@BenjaminRodenberg BenjaminRodenberg left a comment

Choose a reason for hiding this comment

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

Generally helpful error messages. If you want, you can also provide the values that go into the assertion. I'm giving an example below. But this is optional.

cyprecice/cyprecice.pyx Outdated Show resolved Hide resolved
@IshaanDesai IshaanDesai self-requested a review April 6, 2021 14:07
Copy link
Member

@IshaanDesai IshaanDesai left a comment

Choose a reason for hiding this comment

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

Only the following test fails: https://github.com/precice/python-bindings/pull/9/checks?check_run_id=2176968006
Rest from my side this PR is ready to merge.

@BenjaminRodenberg
Copy link
Member Author

Only the following test fails: https://github.com/precice/python-bindings/pull/9/checks?check_run_id=2176968006
Rest from my side this PR is ready to merge.

I think the failing test should have been fixed on develop already. Just merged via 1d76a09 and hope it's working now.

@IshaanDesai IshaanDesai merged commit 2c68630 into develop Apr 6, 2021
@IshaanDesai IshaanDesai deleted the improvedErrorMessages branch April 6, 2021 18:54
@IshaanDesai IshaanDesai mentioned this pull request Apr 7, 2021
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.

Unclear AssertionError when providing points of wrong dimensions Use more descriptive assertions
2 participants