-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(frontend): fix parsing large workflow graph. Fixes #4179 #4180
fix(frontend): fix parsing large workflow graph. Fixes #4179 #4180
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Hi @radcheb. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
/ok-to-test |
/retest |
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.
Thank you @radcheb for the contribution!
Just one comment. The implementation looks great!
/lgtm
dba46f4
to
f63c7a3
Compare
/retest |
The failed tests had an error building frontend image. Step #2 - "frontend": Failed to compile. 14886 Step #2 - "frontend": 14887 Step #2 - "frontend": /src/frontend/src/lib/Utils.tsx 14888 Step #2 - "frontend": TypeScript error in /src/frontend/src/lib/Utils.tsx(379,5): 14889 Step #2 - "frontend": Cannot find name 'reject'. TS2304 14890 Step #2 - "frontend": 14891 Step #2 - "frontend": 377 | } catch (err) { 14892 Step #2 - "frontend": 378 | logger.error('Error decoding compressedNodes!', err); 14893 Step #2 - "frontend": > 379 | reject(err); 14894 Step #2 - "frontend": | ^ 14895 Step #2 - "frontend": 380 | } 14896 Step #2 - "frontend": 381 | } 14897 Step #2 - "frontend": 382 | |
Ok, thanks @Bobgy for your response, I look at it. |
/retest |
/test kubeflow-pipeline-frontend-test |
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.
Thank you! all looking good at high level
/lgtm
Read through code thoroughly and only left some nit picking
frontend/src/lib/Utils.tsx
Outdated
export async function decodeCompressedNodes(compressedNodes: string): Promise<object> { | ||
return new Promise<object>(resolve => { | ||
const compressedBuffer = Buffer.from(compressedNodes, 'base64'); | ||
zlib.gunzip(compressedBuffer, { windowBits: 15 }, (error, result: Buffer) => { |
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.
nit: what does the windowBits: 15
mean?
Can we avoid the magic number?
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.
Sorry forgot to remove it, fixed here: e93a060
frontend/src/lib/Utils.tsx
Outdated
zlib.gunzip(compressedBuffer, { windowBits: 15 }, (error, result: Buffer) => { | ||
if (error) { | ||
logger.error('failed to gunzip data ', error); | ||
resolve(undefined); |
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.
nit: a more common practice is to reject when there's an error, but it's up to you whether you want to change
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're right, I will reject here and catch error in RunDetails.
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.
Done in 5b46a4d
@@ -167,6 +168,9 @@ describe('RunDetails', () => { | |||
// Hide expected warning messages | |||
warnSpy = jest.spyOn(Utils.logger, 'warn').mockImplementation(); | |||
|
|||
// Mock decodeCompressedNodes to avoid dequeuing chained promises | |||
decodeCompressedNodesSpy = jest.spyOn(Utils, 'decodeCompressedNodes').mockImplementation(); |
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.
nit: decodeCompressedNodes
itself is very important to test in this test case, because otherwise we are not verifying this feature end to end.
I understand you may be blocked by sth. You can put a TODO comment here too if you cannot figure out by yourself.
If you'd want to try testing it. Here are my ideas:
I'm not sure how zlib
will trigger the callback, I guess if simply await is not enough, we can use setTimeout
to explicitly wait some long time period so zlib
can decompress.
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.
Well, I already unit tested decodeCompressedNodes
in Utils.test.tsx.
The setTimeout
trick will work for sure but not so elegant.
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 test the wait and it works, thanks for the hint: 8491c5c
expect(getByTestId('graph')).toMatchInlineSnapshot(` | ||
<pre | ||
data-testid="graph" | ||
> | ||
Node node1 | ||
Node node1-running-placeholder | ||
Edge node1 to node1-running-placeholder | ||
</pre> | ||
`); |
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! now it's showing readable content
Thanks @radcheb for this fix !! 👏 |
@Bobgy could you review and merge if it's ok ? |
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.
Thank you @radcheb for your perseverance!
This looks awesome!
There's one last minor mistake to fix, otherwise all good!
/lgtm
await new Promise(resolve => setTimeout(resolve, 500)); | ||
jest.useFakeTimers(); | ||
|
||
expect(tree).toMatchSnapshot(''); |
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.
this should be
expect(getByTestId('graph')).toMatchInlineSnapshot()
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.
actually, I'm not sure whether graph
will actually render, if not you can also just assert something like
expect(getAllByTestId('graph')).toEqual([])
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.
Yes in this case the graph should be empty, I will use your second suggestion.
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.
Well getAllByTestId
didn't work since it requires at least one element in the list, it was rather queryAllByTestId
who did the job.
/lgtm Really valuable fix! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Bobgy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks @Bobgy for accepting and merging. Will this be included in a future release ? |
It's not clear whether we will release 1.0.4 or not. If not, it will come in 1.1.0 |
…ubeflow#4180) * frontend: add large pipeline example to mocked data * add util function decodeCompressedNodes * decode compressedNodes in workflow if node is empty and compressedNodes exit * fix decodeCompressedNodes * prettify code * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * add util function decodeCompressedNodes * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * reformat code * update jest snapshot to add compressed node case * fix tests * reformat code * update RunDetails snapshot * remove dupplicate test code * RunDetails: remove compressedNodes after decoding it * reformat decodeCompressedNodes + add failure case test * decodeCompressedNodes returns undefined on error * RunDetails decodeCompressedNodes test: snapshot same as single node graph * do not wait for decodeCompressedNodes + debug print workflow * fix Run load + refresh snapshot * format code * Fix one-node compressed workflow graph + update snapshot * reformat code * rename large pipeline name * fix decompressNodes to work in browser * fix test * fix tests * remove some of the console.log * clean code * address comments * address comments: wait for zlib instead of mocking decodeCompressedNodes * address comments: decodeCompressedNodes reject in case of error + catch error on run load * address comments
…ubeflow#4180) * frontend: add large pipeline example to mocked data * add util function decodeCompressedNodes * decode compressedNodes in workflow if node is empty and compressedNodes exit * fix decodeCompressedNodes * prettify code * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * add util function decodeCompressedNodes * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * reformat code * update jest snapshot to add compressed node case * fix tests * reformat code * update RunDetails snapshot * remove dupplicate test code * RunDetails: remove compressedNodes after decoding it * reformat decodeCompressedNodes + add failure case test * decodeCompressedNodes returns undefined on error * RunDetails decodeCompressedNodes test: snapshot same as single node graph * do not wait for decodeCompressedNodes + debug print workflow * fix Run load + refresh snapshot * format code * Fix one-node compressed workflow graph + update snapshot * reformat code * rename large pipeline name * fix decompressNodes to work in browser * fix test * fix tests * remove some of the console.log * clean code * address comments * address comments: wait for zlib instead of mocking decodeCompressedNodes * address comments: decodeCompressedNodes reject in case of error + catch error on run load * address comments
* frontend: add large pipeline example to mocked data * add util function decodeCompressedNodes * decode compressedNodes in workflow if node is empty and compressedNodes exit * fix decodeCompressedNodes * prettify code * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * add util function decodeCompressedNodes * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * reformat code * update jest snapshot to add compressed node case * fix tests * reformat code * update RunDetails snapshot * remove dupplicate test code * RunDetails: remove compressedNodes after decoding it * reformat decodeCompressedNodes + add failure case test * decodeCompressedNodes returns undefined on error * RunDetails decodeCompressedNodes test: snapshot same as single node graph * do not wait for decodeCompressedNodes + debug print workflow * fix Run load + refresh snapshot * format code * Fix one-node compressed workflow graph + update snapshot * reformat code * rename large pipeline name * fix decompressNodes to work in browser * fix test * fix tests * remove some of the console.log * clean code * address comments * address comments: wait for zlib instead of mocking decodeCompressedNodes * address comments: decodeCompressedNodes reject in case of error + catch error on run load * address comments
Hi @radcheb, we just released 1.0.4 with your fix! |
Thanks 🙏 |
…ubeflow#4180) * frontend: add large pipeline example to mocked data * add util function decodeCompressedNodes * decode compressedNodes in workflow if node is empty and compressedNodes exit * fix decodeCompressedNodes * prettify code * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * add util function decodeCompressedNodes * Frontend:test Utils decodeCompressedNodes * test RunDetails page render compressed grah * reformat code * update jest snapshot to add compressed node case * fix tests * reformat code * update RunDetails snapshot * remove dupplicate test code * RunDetails: remove compressedNodes after decoding it * reformat decodeCompressedNodes + add failure case test * decodeCompressedNodes returns undefined on error * RunDetails decodeCompressedNodes test: snapshot same as single node graph * do not wait for decodeCompressedNodes + debug print workflow * fix Run load + refresh snapshot * format code * Fix one-node compressed workflow graph + update snapshot * reformat code * rename large pipeline name * fix decompressNodes to work in browser * fix test * fix tests * remove some of the console.log * clean code * address comments * address comments: wait for zlib instead of mocking decodeCompressedNodes * address comments: decodeCompressedNodes reject in case of error + catch error on run load * address comments
Description of your changes:
Fixes #4179
Checklist:
The title for your pull request (PR) should follow our title convention. Learn more about the pull request title convention used in this repository.
Do you want this pull request (PR) cherry-picked into the current release branch?
If yes, use one of the following options:
(Recommended.) Ask the PR approver to add the
cherrypick-approved
label to this PR. The release manager adds this PR to the release branch in a batch update.