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

ORM: Return None in get_function_source_code instead of excepting #5730

Merged
merged 1 commit into from
Oct 30, 2022

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Oct 28, 2022

Fixes #5726

The FunctionCalculationMixin which is used for the nodes of process functions has the function get_function_source_code which will raise FileNotFoundError if the source code file does not exist in the repository. This will happen typically for functions defined in an interactive shell where the inspect package cannot determine the source code.

The docstring erroneously said that None would be returned, but even worse it said that the absolute filepath would be returned, whereas it was supposed to give the source code as a string.

The docstring is fixed and the method now returns None if the source code file doesn't exist instead of raising.

@sphuber sphuber requested a review from bosonie October 28, 2022 13:23
The `FunctionCalculationMixin` which is used for the nodes of process
functions has the function `get_function_source_code` which will raise
`FileNotFoundError` if the source code file does not exist in the
repository. This will happen typically for functions defined in an
interactive shell where the `inspect` package cannot determine the
source code.

The docstring erroneously said that `None` would be returned, but even
worse it said that the absolute filepath would be returned, whereas it
was supposed to give the source code as a string.

The docstring is fixed and the method now returns `None` if the source
code file doesn't exist instead of raising.
@sphuber sphuber force-pushed the fix/5762/get-function-source-code branch from 3be9628 to 722a0ba Compare October 28, 2022 13:24
@sphuber sphuber merged commit 500a9cc into aiidateam:main Oct 30, 2022
@sphuber sphuber deleted the fix/5762/get-function-source-code branch October 30, 2022 17:23
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.

get_function_source_code gives FileNotFoundError when calcfunction is not in a file.
2 participants