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

[Frontend] Node detail view now can show workflow input/output artifacts #2305

Merged
merged 8 commits into from
Oct 15, 2019

Conversation

eterna2
Copy link
Contributor

@eterna2 eterna2 commented Oct 4, 2019

This is part 1 of the PR with reference to #2172 - to show workflow input/output artifacts in the front-end.

cc: @Ark-kun

This PR:

  • Add a new component S3ArtifactLink which renders a <a href> link (supports only s3:// and minio://)
  • Updated DetailsTable:
    • add a new optional valueComponent prop: will wrap the value if provided
    • props is changed from string[][] to Array<[string?, any?]> so that the value need not be a string.
  • Updated StaticNodeDetails to include 2 additional fields: Input Artifacts and Output Artifacts.

The next PR will:

  • update the node backend with a new get artifact API, with additional query params (namely the endpoint, and secrets from the workflow status)
  • this endpoint should also support lookahead (i.e. if flag provided, will head the artifact size, and return either a link to the artifact or the actual content of the artifact if it is small)
  • this endpoint should support artifacts with and w/o gzip
  • It should probably also support partial download with size/length (and maybe offset/start), so that it's possible to visualize the beginning of large table. (@Ark-kun )

Screen Shot 2019-10-04 at 7 49 51 PM

Video can be seen here:
https://drive.google.com/file/d/1GmNrJum20AdW3Bo0xDQJFIOvvMhCF7C_/view


This change is Reviewable

@k8s-ci-robot
Copy link
Contributor

Hi @eterna2. 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.

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 4, 2019

  • new get artifact API, with additional query params

It should probably also support partial download with size/length (and maybe offset/start), so that it's possible to visualize the beginning of large table.

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 4, 2019

There are some frontend unit test errors:

https://travis-ci.com/kubeflow/pipelines/jobs/242030777

@eterna2
Copy link
Contributor Author

eterna2 commented Oct 5, 2019

ok. updated the snapshot to match the current PR.

@eterna2
Copy link
Contributor Author

eterna2 commented Oct 5, 2019

It should probably also support partial download with size/length (and maybe offset/start), so that it's possible to visualize the beginning of large table.
@Ark-kun

question. for ui-metadata it is not an issue, as the data type is specified.

However, for generic artifacts, there is no easy way to know what is the content? other than try/catch with a few possible choices? But probably doable, do a quick scan for number of commas, or common delimiters to differeniate between csv, json, or plain text.

@eterna2 eterna2 force-pushed the eterna2/frontend-artifact-view branch from dcd8b15 to bda3152 Compare October 5, 2019 17:52
@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 7, 2019

However, for generic artifacts, there is no easy way to know what is the content?

This PR will make the type information available to Frontend: #2323

But probably doable, do a quick scan for number of commas, or common delimiters to differeniate between csv, json, or plain text.

I think that's out of scope for this PR. Here we just want to restore the existing functionality. Initially we just want to show short strings. We can truncate the string to, say, 300 bytes and show something like "very long strin...", Size: 32167 bytes, URL: https://.....

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 7, 2019

/ok-to-test

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 9, 2019

  • It should probably also support partial download with size/length (and maybe offset/start), so that it's possible to visualize the beginning of large table. (@Ark-kun )

Note: I was talking about the Frontend server functionality. This partial download feature should not be exposed to the user.

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 9, 2019

Are the artifact links in "clickable" - result in showing/downloading the artifact data?

@eterna2
Copy link
Contributor Author

eterna2 commented Oct 10, 2019

Yup. It opens a new window and shows the data in plain text. I am just using the original get artifact API in the node backend as a HREF link in this PR (just a new window with a GET request).

However to trigger download instead of a new window, I need to add a Content-Disposition header to the API response.

Probably, can add a new query string flag download to set this.

@Bobgy
Copy link
Contributor

Bobgy commented Oct 10, 2019

I'll review this today.

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 10, 2019

However to trigger download instead of a new window, I need to add a Content-Disposition header to the API response.

Probably, can add a new query string flag download to set this.

It's OK. People can always right-click the URL and use "Save as".

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 10, 2019

I'll review this today.

Thank you.

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.

@eterna2 thanks for the contribution!

LGTM to the overall implementation, added some nit comments.

frontend/src/components/S3ArtifactLink.tsx Outdated Show resolved Hide resolved
@@ -68,7 +68,7 @@ export function _populateInfoFromTemplate(info: SelectedNodeInfo, template?: Tem

if (template.inputs) {
info.inputs =
(template.inputs.parameters || []).map(p => [p.name, p.value || '']);
(template.inputs.parameters || []).map(p => [p.name, p.value || ''] as [string, string]);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can you give [string, string] a proper type/interface name and avoid casting here? Avoiding type casting helps with long term maintenance.

Copy link
Contributor

Choose a reason for hiding this comment

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

One way to avoid casting here is

....map((p): [string, string] => [p.name, p.value || '']);

example

What would be even better, we should probably upgrade typescript version to at least 3.5, so it can handle it by default. example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated typescript to 3.6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed issues introduced by the stricter typing by typescript >=3.5.

updated node to LTS 10 - because I notice a few peculiarity:

  • the grpc packages are not found in package-lock.json even thou it specified in package.json (I think is subsequently installed in the post-install step, but I am not sure if it is used in any other places) - so whenever I do a npm i they get included into the lock file. And this result in some issues for node 9.4, as some dependent packages seems to be missing (does not support node 9)? So I have to upgrade the docker images to node 10.

  • Some of packages are not following the semantic versioning faithfully - I have to freeze a couple of packages, as the latest ones breaks the app (when package-lock.json is updated when I upgraded typescript.

Copy link
Contributor

Choose a reason for hiding this comment

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

the grpc packages are not found in package-lock.json even thou it specified in package.json (I think is subsequently installed in the post-install step, but I am not sure if it is used in any other places) - so whenever I do a npm i they get included into the lock file. And this result in some issues for node 9.4, as some dependent packages seems to be missing (does not support node 9)? So I have to upgrade the docker images to node 10.

Thanks for the catch. I think the last committer forgot to update package-lock.json last time, let's just commit them so they are in sync. Besides upgrading to node 10 LTS is definitely a good choice.

Some of packages are not following the semantic versioning faithfully - I have to freeze a couple of packages, as the latest ones breaks the app (when package-lock.json is updated when I upgraded typescript.

Thanks for finding them, the solution sounds good to me.

/**
* A component that renders an artifact link.
*/
const S3ArtifactLink: React.FC<S3Artifact> = (
Copy link
Contributor

Choose a reason for hiding this comment

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

May I ask for a really simple test for this component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added 3 simple test case:

  • invalid artifact (empty bucket or key)
  • s3 artifact
  • minio artifact

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! LGTM

frontend/src/components/S3ArtifactLink.tsx Outdated Show resolved Hide resolved
@Bobgy
Copy link
Contributor

Bobgy commented Oct 10, 2019

Also, for convenience, can you record a video about how this looks like?
There are a lot of tools to do that, maybe you can try https://www.screencastify.com/

@eterna2
Copy link
Contributor Author

eterna2 commented Oct 10, 2019

@Bobgy

List of changes:

  • Renamed S3ArtifactLink to MinioArtifactLink and added unit tests for 3 use cases - invalid, s3, and minio artifacts.
  • Upgraded typescript to 3.6 and fixed issues due to stricter type checking, added config to skip typecheck for material lib (as it breaks with new ts)
  • Upgraded docker image to use node 10 instead of node 9, because grpc is broken in node 9
  • freezed the version for a couple of packages because the latest in semantic version breaks the typechecks
  • add apache-2 LICENSE (his github used apache-2, but npm show ISC) for linear-layout-vector (seems to be a new dependency for react-virtualized)

video can be found at https://drive.google.com/file/d/1GmNrJum20AdW3Bo0xDQJFIOvvMhCF7C_/view

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 10, 2019

/retest

@Bobgy
Copy link
Contributor

Bobgy commented Oct 11, 2019

Hi @eterna2, this is awesome! Thanks a lot for the quick change.

I hope I said this earlier because I didn't expect you to finish the upgrade so fast (which is awesome), but can you separate the following to a separate PR?

  • Upgraded typescript to 3.6 and fixed issues due to stricter type checking, added config to skip typecheck for material lib (as it breaks with new ts)
  • Upgraded docker image to use node 10 instead of node 9, because grpc is broken in node 9
  • freezed the version for a couple of packages because the latest in semantic version breaks the typechecks
  • add apache-2 LICENSE (his github used apache-2, but npm show ISC) for linear-layout-vector (seems to be a new dependency for react-virtualized)

Because this PR is getting too large and upgrading typescript brought too many side effects.

I would recommend finishing this PR without upgrading typescript (just use the pattern I introduced to avoid type casts).

....map((p): [string, string] => [p.name, p.value || '']);

Feel free to talk about your opinions because I can see you've already put a lot of efforts into this. I'm just giving suggestions that can give us more confidence of merging each of your PRs, and maybe sometimes I'm asking too much.

…o extract artifacts. Update view to render artifacts.
@eterna2 eterna2 force-pushed the eterna2/frontend-artifact-view branch 2 times, most recently from 2b7e57f to b6dd275 Compare October 14, 2019 12:18
@eterna2 eterna2 force-pushed the eterna2/frontend-artifact-view branch from b6dd275 to c0f4202 Compare October 14, 2019 12:20
@eterna2
Copy link
Contributor Author

eterna2 commented Oct 14, 2019

ok. fixed most of the minor stuff.

wonders whether do u want to setup an auto-formatter like prettier? Cuz I usually does that, and just auto-format everything as a pre-hook commit.

will fix the unit test and output later.

@Bobgy
Copy link
Contributor

Bobgy commented Oct 14, 2019

Thanks for suggestion, I am also planning on making a standard prettier config.

@eterna2
Copy link
Contributor Author

eterna2 commented Oct 14, 2019

@Bobgy
Ok done with all the changes if I am not wrong.

Just a minor feedback, the unit test fails on node 9 (travis is running node 11, while dockerfile is using node 9) - might want to sync them up, cuz was puzzled by my failing unit tests until I went and look at travis and swapped to 11 (the errors are all datetime format diff with the snapshots).

But this can be specific to my machine thou. I am using wsl in windows.

@Ark-kun
Copy link
Contributor

Ark-kun commented Oct 14, 2019

(travis is running node 11, while dockerfile is using node 9) - might want to sync them up

@Bobgy Which version should we standardize on: 9 ,10, 11 or 12 (In a different PR)? The NodeJS website lists 10 and 12 as LTS releases. Should we try to go with 12?

@Bobgy
Copy link
Contributor

Bobgy commented Oct 15, 2019

@Ark-kun Choosing latest LTS (12) is definitely the best option. I agree we should do it in a separate PR. I will create an issue for it.

@Bobgy
Copy link
Contributor

Bobgy commented Oct 15, 2019

@eterna2, thanks so much for this! This is awesome.

/lgtm
/approve

@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

@Bobgy
Copy link
Contributor

Bobgy commented Oct 15, 2019

/area front-end

@k8s-ci-robot k8s-ci-robot merged commit e8477ff into kubeflow:master Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants