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

fix(frontend): fix parsing large workflow graph. Fixes #4179 #4180

Merged

Conversation

radcheb
Copy link
Contributor

@radcheb radcheb commented Jul 8, 2020

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.

@googlebot
Copy link
Collaborator

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 @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@radcheb
Copy link
Contributor Author

radcheb commented Jul 8, 2020

@googlebot I signed it!

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@kubeflow-bot
Copy link

This change is Reviewable

@googlebot googlebot added cla: yes and removed cla: no labels Jul 8, 2020
@Ark-kun
Copy link
Contributor

Ark-kun commented Jul 8, 2020

/ok-to-test

@Ark-kun
Copy link
Contributor

Ark-kun commented Jul 8, 2020

/retest

Copy link
Contributor

@Bobgy Bobgy left a 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

frontend/src/pages/RunDetails.tsx Show resolved Hide resolved
@Bobgy Bobgy added the cherrypick-approved area OWNER approves to cherry pick this PR to current active release branch label Jul 16, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm label Aug 9, 2020
@radcheb radcheb force-pushed the frontend-fix-parse-large-workflow branch from dba46f4 to f63c7a3 Compare August 9, 2020 16:57
@radcheb
Copy link
Contributor Author

radcheb commented Aug 9, 2020

/retest

@radcheb radcheb requested a review from Bobgy August 9, 2020 19:56
@Bobgy
Copy link
Contributor

Bobgy commented Aug 9, 2020

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 |

@radcheb
Copy link
Contributor Author

radcheb commented Aug 10, 2020

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.

@radcheb
Copy link
Contributor Author

radcheb commented Aug 13, 2020

/retest

@radcheb
Copy link
Contributor Author

radcheb commented Aug 13, 2020

/test kubeflow-pipeline-frontend-test

Copy link
Contributor

@Bobgy Bobgy left a 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

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) => {
Copy link
Contributor

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?

Copy link
Contributor Author

@radcheb radcheb Oct 12, 2020

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

zlib.gunzip(compressedBuffer, { windowBits: 15 }, (error, result: Buffer) => {
if (error) {
logger.error('failed to gunzip data ', error);
resolve(undefined);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Comment on lines +675 to +683
expect(getByTestId('graph')).toMatchInlineSnapshot(`
<pre
data-testid="graph"
>
Node node1
Node node1-running-placeholder
Edge node1 to node1-running-placeholder
</pre>
`);
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot removed the lgtm label Oct 12, 2020
@axelborja
Copy link

Thanks @radcheb for this fix !! 👏

@radcheb radcheb requested a review from Bobgy October 13, 2020 15:47
@radcheb
Copy link
Contributor Author

radcheb commented Oct 15, 2020

@Bobgy could you review and merge if it's ok ?

@Bobgy
Copy link
Contributor

Bobgy commented Oct 15, 2020

@Bobgy could you review and merge if it's ok ?

@radcheb Sure, I'll review tomorrow.

Copy link
Contributor

@Bobgy Bobgy left a 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('');
Copy link
Contributor

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()

Copy link
Contributor

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([])

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@k8s-ci-robot k8s-ci-robot removed the lgtm label Oct 16, 2020
@Bobgy
Copy link
Contributor

Bobgy commented Oct 16, 2020

/lgtm
/approve

Really valuable fix!
@racheb Thank you for your contribution!

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 02b0899 into kubeflow:master Oct 16, 2020
@radcheb
Copy link
Contributor Author

radcheb commented Oct 16, 2020

Thanks @Bobgy for accepting and merging. Will this be included in a future release ?

@Bobgy
Copy link
Contributor

Bobgy commented Oct 16, 2020

It's not clear whether we will release 1.0.4 or not. If not, it will come in 1.1.0

@Bobgy Bobgy added the cherrypicked cherry picked to release branch `release-x.y` label Oct 22, 2020
Bobgy pushed a commit to Bobgy/pipelines that referenced this pull request Oct 22, 2020
…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
Bobgy pushed a commit to Bobgy/pipelines that referenced this pull request Oct 22, 2020
…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
Bobgy pushed a commit that referenced this pull request Oct 22, 2020
* 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
@Bobgy
Copy link
Contributor

Bobgy commented Oct 23, 2020

Hi @radcheb, we just released 1.0.4 with your fix!

@axelborja
Copy link

Thanks 🙏

@radcheb
Copy link
Contributor Author

radcheb commented Oct 27, 2020

Hi @radcheb, we just released 1.0.4 with your fix!

Thanks @Bobgy for your assistance and thus this great news.

Jeffwan pushed a commit to Jeffwan/pipelines that referenced this pull request Dec 9, 2020
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherrypick-approved area OWNER approves to cherry pick this PR to current active release branch cherrypicked cherry picked to release branch `release-x.y` cla: yes lgtm ok-to-test size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frontend UI cannot display large workflows
7 participants