-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fix: lambda python functions not rendering correctly on flowchart #851
Conversation
Signed-off-by: Tynan DeBold <[email protected]>
Signed-off-by: Tynan DeBold <[email protected]>
Signed-off-by: Tynan DeBold <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this PR contains the work for this PR that is not merged in main
yet - would be great if you could remove those changes in this PR to avoid confusion. Thank you!
…x/lambda-python-functions-on-flowchart Signed-off-by: Tynan DeBold <[email protected]>
Done now. |
Signed-off-by: Tynan DeBold <[email protected]>
This looks right on the tree view and metadata side panel to me but looks kind of funky when I search for it... Outside the scope of this PR, but related: did we ever get a ticket created to change these |
RELEASE.md
Outdated
@@ -6,6 +6,10 @@ Please follow the established format: | |||
- Include the ID number for the related PR (or PRs) in parentheses | |||
--> | |||
|
|||
## Bug fixes and other changes | |||
|
|||
- Fix lambda Python functions not rendering correctly on flowchart. (#851) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix lambda Python functions not rendering correctly on flowchart. (#851) | |
- Fix lambda and partial Python functions not rendering correctly on flowchart. (#851) |
The same fix here will work for both cases :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one. Updated!
src/utils/index.js
Outdated
}; | ||
|
||
export const replaceMatches = (str) => { | ||
if (str && str.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: what is this conditional for here? I sort of understand the zero-length string case but not the case where bool(str)
would evaluate to False - when does that occur?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't have that check you'd get this error: TypeError: Cannot read property 'length' of undefined
. I've changed it now to this str?.length > 0
which does the same thing: first checks if there's a string, and if so, proceed to find the length.
Signed-off-by: Tynan DeBold <[email protected]>
Signed-off-by: Tynan DeBold <[email protected]>
Signed-off-by: Tynan DeBold <[email protected]>
Good catch on the search. I need to update it, but it's a bit tricky since we're putting these partial and lambda names between Can we use something else instead of these to make it easier for ourselves, like a |
…x/lambda-python-functions-on-flowchart Signed-off-by: Tynan DeBold <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Tynan DeBold <[email protected]>
def _strip_tags(name: str) -> str: | ||
return name.replace("<", "<").replace(">", ">") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the solve for this is to leave the <>
in place in the backend and then change it to use the HTML entities only where we need it in the frontend.
@@ -124,7 +131,9 @@ const NodeListRow = memo( | |||
'pipeline-nodelist__row__label--disabled': disabled, | |||
} | |||
)} | |||
dangerouslySetInnerHTML={{ __html: label }} | |||
dangerouslySetInnerHTML={{ | |||
__html: replaceMatches(label, stringsToReplace), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the <>
here so we can still use dangerouslySetInnerHTML
without a problem, specifically when searching.
Signed-off-by: Tynan DeBold <[email protected]>
width: 20px; | ||
height: 20px; | ||
z-index: 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You couldn't click the X
icon to clear the search. This fixes that.
README.md
Outdated
@@ -35,6 +35,7 @@ Kedro-Viz is an interactive development tool for building data science pipelines | |||
- 🔎 Highly interactive, filterable and searchable | |||
- 🔬 Focus mode for modular pipeline visualisation | |||
- 📊 Rich metadata side panel to display parameters, plots, etc. | |||
- 📊 Supports [plotly](https://plotly.com/javascript/) charts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rashidakanchwala curious why this made it in here?
Signed-off-by: Tynan DeBold <[email protected]>
…thub.com/kedro-org/kedro-viz into fix/lambda-python-functions-on-flowchart Signed-off-by: Tynan DeBold <[email protected]>
…x/lambda-python-functions-on-flowchart Signed-off-by: Tynan DeBold <[email protected]>
On the main branch, searching for something with I tried to fix that in this ticket but it turned into a bigger issue. I'll create a separate bug report for that and leave this one here. Update: related ticket here: #854 |
…:kedro-org/kedro-viz into fix/lambda-python-functions-on-flowchart
Signed-off-by: Tynan DeBold <[email protected]>
…thub.com/kedro-org/kedro-viz into fix/lambda-python-functions-on-flowchart Signed-off-by: Tynan DeBold <[email protected]>
…x/lambda-python-functions-on-flowchart Signed-off-by: Tynan DeBold <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @tynandebold . approving it since we will look at the <> bug in another ticket :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is definitely in a much better shape now!
one small thing I noticed ( sorry to be a pain) - when searching for the lambda function with a <
, the search results displayed gets weird ( some characters gets wiped out):
I think this could potentially be tied to having replaced <lambda
with <partial>
? ( though I am not sure at all - this might require a bit of further poke around to find a workaround for that.)
Good eye. I think that's to be expected at this point, which will be solved by the solution for this bug ticket. In the current version, if you have a If you're comfortable with that, would be great if we can approve this now and iterate on the fix in the linked ticket above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw the ticket you mentioned above, all good 👍
May I suggest to add in an end-2-end test in the upcoming PR for #854 to ensure we capture any errors with the search case for Lambda functions ( since this seems to be a use case that could be easily prone to errors)? 😆
Given that we are looking into releasing soon, it might be worth to release first before merging this in so this can be released alongside the fix for the search (#854 ) as one complete fix? ( totally up to the team)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely good to get this merged, thanks for doing all the iteration on it!
If it turns out the search thing is hard to fix then honestly I think it's fine if we just drop the <>
altogether and call it plain lambda
or partial
everywhere. Also the number of people who will be searching for a lambda function in the is very small. So would be good to fix but not a biggy at all I think.
Good to know. I'll add this comment to the context of the other ticket I created. I do think it'll be a pain to solve and we'd be wise to just drop |
Description
Fixes #817.
Development notes
I'm no longer using
_strip_tags
in the backend, so the<>
come through to the frontend. I've create areplaceMatches()
utility function and added that to thenode-list-row.js
file to ensure both<lambda>
and<partial>
will render viadangerouslySetInnerHTML
.QA notes
I've added a lambda node so this can be tested. Open the Gitpod URL and expand the
Ingestion
modular pipeline. You'll see the lambda function there.Checklist
RELEASE.md
file