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

give name of function inside incorrect parameters error #538

Closed
wants to merge 20 commits into from

Conversation

WaylonWalker
Copy link
Contributor

@WaylonWalker WaylonWalker commented Oct 3, 2020

Description

This is a quick and simple step towards the right direction to resolve #495.

Development notes

I ran kedro new, and broke one of the nodes. There is a comparison of the current error and the updated error below. This error is also inspected by the test framework.

Current Error

Does not give much information to what node caused the TypeError. While this is generally easy to figure out on small pipelines, larger pipelines can be quite intense to figure out where the error came from. Any additional information would be greatly appreciated.

image

Updated Error

The updated error will give the name of the function for full functions, but does not provide better messaging for lambdas.

image

Feedback

  • Is the format of the message ok?
  • Is there any potential that the passed in function would not have a func.__code__.co_name method?

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change and added my name to the list of supporting contributions in the RELEASE.md file
  • Added tests to cover my changes
  • This PR is on my personal behalf and does not represent any employer

NOTE No new tests were created, only modification of existing tests.

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

  • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.

  • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorised to submit this contribution on behalf of the original creator(s) or their licensees.

  • I certify that the use of this contribution as authorised by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

@WaylonWalker WaylonWalker marked this pull request as ready for review October 3, 2020 17:26
@laisbsc laisbsc requested review from limdauto and lorenabalan and removed request for idanov October 6, 2020 13:40
@@ -337,15 +337,15 @@ def dummy_func_args(**kwargs):
[
(
inconsistent_input_size,
r"Inputs of function expected \[\'input1\'\], but got \[\'A\', \'B\'\]",
r"Inputs of function 'identity' expected \[\'input1\'\], but got \[\'A\', \'B\'\]",
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks nicer. Can we add some tests for lambda and partial when they are passed as the callable to the node? Not sure if it'll be as pretty.

@WaylonWalker
Copy link
Contributor Author

WaylonWalker commented Oct 7, 2020

@lorenabalan any ideas how to get tests passing? For some reason 58636d9 was only failing on 3.8. It appeared to match exactly to me besides the escape characters.

@lorenabalan
Copy link
Contributor

Actually looking at the test cases, I would argue the error message looks more complicated now - addresses in memory are not that user-friendly. Could we instead factor out and leverage the same logic we have in Node._func_name? 😃

@WaylonWalker
Copy link
Contributor Author

I am not sure that my change should be causing a seg fault in the memory profiler tests???

Could you rerun tests and see if it persists?

I think I got it cleaned up, and it looks much better, than for the _func_name suggestion @lorenabalan!

@WaylonWalker
Copy link
Contributor Author

Thanks for re-running! Tests are passing. @lorenabalan how does the updated format look? I like that it matches up with other kedro function naming methods.

Personally I am not sure that I like that there are more than one place figuring out how to name a function, but that would have started touching more things than I preferred to do from my end without first discussing.

@lorenabalan
Copy link
Contributor

Thanks for re-running! Tests are passing. @lorenabalan how does the updated format look? I like that it matches up with other kedro function naming methods.

The format looks good to me - maybe could be Inputs of "this_func_name" function instead of Inputs of "this_func_name" in the error message but that's a minor point.

Personally I am not sure that I like that there are more than one place figuring out how to name a function, but that would have started touching more things than I preferred to do from my end without first discussing.

Yeah I agree - looking through the code base, I also found this variation of the implementation. 😅 The decorators are going to be deprecated in 0.17.0 so I'm not that worried about that one, it just illustrates that we don't have a consistent way to handle it. Could we factor out the logic from _func_name into a helper function _get_readable_func_name or smth, to call in both places (in _func_name and in _validate_inputs)? And only warn about update_wrapper in Node._func_name.

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.

better error messages when wrong number of inputs is passed
2 participants