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

improve %load_node support full node syntax #3633

Merged
merged 30 commits into from
Feb 26, 2024

Conversation

noklam
Copy link
Contributor

@noklam noklam commented Feb 19, 2024

Description

Fix #3629

Development notes

2 main changes:

  1. Refactor to use a NodeBoundArguments, which inherit from inspect.BoundArguments. . This allow the helper function to return a proper data structure for testing. The structure will also be useful for generating all the necessary text so our tests can focus on testing on the data structure, not the exact string.
  2. Using BoundArguments, we can easily generate the necessary function signature according to the node function, the only thing we need to do is taking care of the "*args" to handle a specific edge case.

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • 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 in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
…ect instead of generate string for cells directly

Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
… element

Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
@noklam
Copy link
Contributor Author

noklam commented Feb 19, 2024

@lrcouto It's ready for test, I have refactor the logic and manual tested and unit tests are all passed.

lrcouto and others added 6 commits February 20, 2024 15:06
Signed-off-by: lrcouto <laurarccouto@gmail.com>
Signed-off-by: lrcouto <laurarccouto@gmail.com>
Signed-off-by: lrcouto <laurarccouto@gmail.com>
Signed-off-by: lrcouto <laurarccouto@gmail.com>
Signed-off-by: lrcouto <laurarccouto@gmail.com>
@lrcouto
Copy link
Contributor

lrcouto commented Feb 21, 2024

@astrojuanlu here's the issue I mentioned today at standup.

image

This function at inspect.BoundNode has a docstring that contains *args and **kwargs. Sphinx is considering the * characters to be a bold text tag that was opened and not closed, and I can't change the docstring since it's on an external lib. =p

@lrcouto lrcouto marked this pull request as ready for review February 22, 2024 16:20
@noklam
Copy link
Contributor Author

noklam commented Feb 22, 2024

Was the issue Sphinx is trying to render that method in docs? Can we somehow suppress this, tbh there is not much value to document the class in the API docs, we can even convert it to a private class _NodeBoundArguments if it helps.

Signed-off-by: lrcouto <laurarccouto@gmail.com>
…ithub.com:kedro-org/kedro into noklam/improve-load-node-support-full-node-syntax
Signed-off-by: lrcouto <laurarccouto@gmail.com>
@lrcouto
Copy link
Contributor

lrcouto commented Feb 23, 2024

Was the issue Sphinx is trying to render that method in docs? Can we somehow suppress this, tbh there is not much value to document the class in the API docs, we can even convert it to a private class _NodeBoundArguments if it helps.

I think it is. I've been trying to find a way to either suppress warnings from external libraries, or suppress this specific warning, but I don't think I can do that without ignoring the whole file. I'll try to see if converting it to a private class helps.

Signed-off-by: lrcouto <laurarccouto@gmail.com>
@lrcouto
Copy link
Contributor

lrcouto commented Feb 23, 2024

Converted NodeBoundArguments to private and that solved this specific instance of the problem. It'd still be a good idea to find a more permanent solution for this issue though.

@noklam
Copy link
Contributor Author

noklam commented Feb 23, 2024

@lrcouto Great! I think we have seen this issue in the past, I don't really remember how we solved it, maybe @AhdraMeraliQB or @astrojuanlu knows more? The solution is to not use some of the autodoc that trigger upstream dependencies, turning into private class is sufficient for now.

@noklam
Copy link
Contributor Author

noklam commented Feb 23, 2024

Tagging @DmitriiDeriabinQB and @ankatiyar for review

@astrojuanlu
Copy link
Member

The other @DimedS :)

@astrojuanlu
Copy link
Member

The way I've usually solved it is by committing the template generated by sphinx.ext.autosummary during the docs building process and removing the classes or properties I don't want to have documented. Sphinx will then abstain from overwriting the file.

Good that you solved the problem for now 👍🏽 I don't think this was expected to be public API anyway?

Copy link
Member

@astrojuanlu astrojuanlu left a comment

Choose a reason for hiding this comment

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

Tested this, and it works!

Copy link
Contributor

@ankatiyar ankatiyar left a comment

Choose a reason for hiding this comment

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

Tested manually. Thanks @noklam and @lrcouto :D

@lrcouto lrcouto enabled auto-merge (squash) February 26, 2024 15:44
@lrcouto lrcouto merged commit ffc2683 into main Feb 26, 2024
34 checks passed
@lrcouto lrcouto deleted the noklam/improve-load-node-support-full-node-syntax branch February 26, 2024 15:52
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.

%load_node support full Kedro Node syntax, with better *args, **kwargs handling
4 participants