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(backend): remove content disposition http header from artifact download #70

Conversation

gregsheremeta
Copy link

@gregsheremeta gregsheremeta commented Aug 9, 2024

Description of your changes:
Remove content disposition http header from artifact download. This header prevents an artifact from being previewed/rendered in an iframe.

Fixes: https://issues.redhat.com/browse/RHOAIENG-11136

Checklist:

@dsp-developers
Copy link

Commit Checker results:

**NOTE**: These are the results of the commit checker scans. 
If these are not commits from upstream kfp, then please ensure
you adhere to the commit checker formatting
commitchecker verson unknown
Validating 1 commits between bbfb5897533403b38ad8956424931868c103b0b0...0494b12a68e70bf3e3d9935b16d41241d9dcebde

UPSTREAM commit 0494b12 has invalid summary DO NOT MERGE - testing removal of content disposition.

UPSTREAM commits are validated against the following regular expression:
  ^UPSTREAM: (revert: )?(([\w.-]+/[\w-.-]+)?: )?(\d+:|<carry>:|<drop>:)

UPSTREAM commit summaries should look like:

  UPSTREAM: <PR number|carry|drop>: description

UPSTREAM commits which revert previous UPSTREAM commits should look like:

  UPSTREAM: revert: <normal upstream format>

Examples of valid summaries:

  UPSTREAM: 12345: A kube fix
  UPSTREAM: <carry>: A carried kube change
  UPSTREAM: <drop>: A dropped kube change
  UPSTREAM: revert: 12345: A kube revert


@dsp-developers
Copy link

A set of new images have been built to help with testing out this PR:
API Server: quay.io/opendatahub/ds-pipelines-api-server:pr-70
DSP DRIVER: quay.io/opendatahub/ds-pipelines-driver:pr-70
DSP LAUNCHER: quay.io/opendatahub/ds-pipelines-launcher:pr-70
Persistence Agent: quay.io/opendatahub/ds-pipelines-persistenceagent:pr-70
Scheduled Workflow Manager: quay.io/opendatahub/ds-pipelines-scheduledworkflow:pr-70
MLMD Server: quay.io/opendatahub/mlmd-grpc-server:latest
MLMD Envoy Proxy: registry.redhat.io/openshift-service-mesh/proxyv2-rhel8:2.3.9-2
UI: quay.io/opendatahub/ds-pipelines-frontend:pr-70

@dsp-developers
Copy link

An OCP cluster where you are logged in as cluster admin is required.

The Data Science Pipelines team recommends testing this using the Data Science Pipelines Operator. Check here for more information on using the DSPO.

To use and deploy a DSP stack with these images (assuming the DSPO is deployed), first save the following YAML to a file named dspa.pr-70.yaml:

apiVersion: datasciencepipelinesapplications.opendatahub.io/v1alpha1
kind: DataSciencePipelinesApplication
metadata:
  name: pr-70
spec:
  dspVersion: v2
  apiServer:
    image: "quay.io/opendatahub/ds-pipelines-api-server:pr-70"
    argoDriverImage: "quay.io/opendatahub/ds-pipelines-driver:pr-70"
    argoLauncherImage: "quay.io/opendatahub/ds-pipelines-launcher:pr-70"
  persistenceAgent:
    image: "quay.io/opendatahub/ds-pipelines-persistenceagent:pr-70"
  scheduledWorkflow:
    image: "quay.io/opendatahub/ds-pipelines-scheduledworkflow:pr-70"
  mlmd:  
    deploy: true  # Optional component
    grpc:
      image: "quay.io/opendatahub/mlmd-grpc-server:latest"
    envoy:
      image: "registry.redhat.io/openshift-service-mesh/proxyv2-rhel8:2.3.9-2"
  mlpipelineUI:
    deploy: true  # Optional component 
    image: "quay.io/opendatahub/ds-pipelines-frontend:pr-70"
  objectStorage:
    minio:
      deploy: true
      image: 'quay.io/opendatahub/minio:RELEASE.2019-08-14T20-37-41Z-license-compliance'

Then run the following:

cd $(mktemp -d)
git clone git@github.com:opendatahub-io/data-science-pipelines.git
cd data-science-pipelines/
git fetch origin pull/70/head
git checkout -b pullrequest 0494b12a68e70bf3e3d9935b16d41241d9dcebde
oc apply -f dspa.pr-70.yaml

More instructions here on how to deploy and test a Data Science Pipelines Application.

…ct download

This header prevents an artifact from being previewed/rendered in an iframe.
Remove it.
@gregsheremeta gregsheremeta force-pushed the remove-content-disposition-header branch from 0494b12 to 2829d61 Compare August 9, 2024 15:51
@dsp-developers
Copy link

Commit Checker results:

**NOTE**: These are the results of the commit checker scans. 
If these are not commits from upstream kfp, then please ensure
you adhere to the commit checker formatting
commitchecker verson unknown
Validating 1 commits between bbfb5897533403b38ad8956424931868c103b0b0...2829d6179ab680edea5091ece13f13b4c01a7dc9

@gregsheremeta gregsheremeta changed the title DO NOT MERGE - testing removal of content disposition remove content disposition http header from artifact download Aug 9, 2024
@gregsheremeta gregsheremeta changed the title remove content disposition http header from artifact download fix(backend): remove content disposition http header from artifact download Aug 9, 2024
@diegolovison
Copy link

What is going to happen to those who wish to download the file?
IMHO, the info should come from the dashboard, if they wish to display or download.
By default, if the parameter is not presented, the attachment; filename will be presented in the response.

@dsp-developers
Copy link

Change to PR detected. A new PR build was completed.
A set of new images have been built to help with testing out this PR:
API Server: quay.io/opendatahub/ds-pipelines-api-server:pr-70
DSP DRIVER: quay.io/opendatahub/ds-pipelines-driver:pr-70
DSP LAUNCHER: quay.io/opendatahub/ds-pipelines-launcher:pr-70
Persistence Agent: quay.io/opendatahub/ds-pipelines-persistenceagent:pr-70
Scheduled Workflow Manager: quay.io/opendatahub/ds-pipelines-scheduledworkflow:pr-70
MLMD Server: quay.io/opendatahub/mlmd-grpc-server:latest
MLMD Envoy Proxy: registry.redhat.io/openshift-service-mesh/proxyv2-rhel8:2.3.9-2
UI: quay.io/opendatahub/ds-pipelines-frontend:pr-70

@andrewballantyne
Copy link
Member

andrewballantyne commented Aug 9, 2024

What is going to happen to those who wish to download the file? IMHO, the info should come from the dashboard, if they wish to display or download. By default, if the parameter is not presented, the attachment; filename will be presented in the response.

The lack of the direct content disposition property doesn't change what you can do it changes what it will do by default.

Our goal in the UI will be to show content, not download it (when applicable). But there is some content that won't be showable in a "nice way" -- such as say Model Artifacts. Those will download. Basically the removal here is leaving it up the source to decide what to do.

When we display content in a new tab, and you wanted it downloaded (ie HTML page) you can right click and say "save as..." (or equiv wording depending on your browser).

@diegolovison
Copy link

When we display content in a new tab, and you want it downloaded

How about the name of the file? Is it going to match what was saved?

Copy link
Member

@DharmitD DharmitD left a comment

Choose a reason for hiding this comment

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

/lgtm

@andrewballantyne
Copy link
Member

When we display content in a new tab, and you want it downloaded

How about the name of the file? Is it going to match what was saved?

This is defined by your browser implementation. The content will be whatever you decide and is prefilled with whatever the browser decides.

Example for the STRAT behind this feature:
image

document.title
'[RHOAISTRAT-247] Implement artifacts API in Data Science Pipelines Backend - Red Hat Issue Tracker'

Milage may vary -- we'd need to test specific named resources to see. Your HTML resource can set this value, not sure about other resources. Not sure there is much we can do here ... we'll have to see once we get some use-cases going and determining the expectation / desires. This change is needed to show anything in the Dashboard though, so it may be a loss for the larger gain. Again, we'll need to test this out from the Dashboard perspective.

@diegolovison
Copy link

diegolovison commented Aug 9, 2024

I am creating a cluster to test this PR. Give me a few minutes.

@diegolovison
Copy link

If we merge this PR, the user won't know the file name that was stored.
For each pipeline step, they will need to remember and set a name for the file. Each step can have multiple outputs as well.

Here is a pipeline example:

@dsl.component....
def fn1...
    with open(iris_dataset.path, "w") as f:
        df.to_csv(f)

@dsl.component....
def fn2....
    with open(normalized_iris_dataset.path, "w") as f:
        df.to_csv(f)

@dsl.component....
def fn3....
    with open(model.path, "wb") as f:
        pickle.dump(clf, f)

@gregsheremeta
Copy link
Author

Apparently the content disposition inline could be used to do that. Ref: https://stackoverflow.com/questions/1741353/how-to-set-response-filename-without-forcing-save-as-dialog

@gregsheremeta
Copy link
Author

/hold

@andrewballantyne how do you want to proceed?

@HumairAK
Copy link

/unhold
/lgtm
/approve

Copy link

openshift-ci bot commented Aug 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: HumairAK

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

@openshift-merge-bot openshift-merge-bot bot merged commit d0ee4ca into opendatahub-io:master Aug 12, 2024
3 checks passed
@dsp-developers
Copy link

Commit Checker results:

**NOTE**: These are the results of the commit checker scans. 
If these are not commits from upstream kfp, then please ensure
you adhere to the commit checker formatting
commitchecker verson unknown
Validating 0 commits between d0ee4ca4524ece9f201581345ef791a1d4ee8e68...2829d6179ab680edea5091ece13f13b4c01a7dc9

@andrewballantyne
Copy link
Member

@andrewballantyne how do you want to proceed?

For posterity, we discussed it and want to move forward with this API change and see about solving this purely from the UI.

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.

6 participants