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

feat(sdk): Add in ability to override the template handler for a BaseOp. #4955

Closed
wants to merge 2 commits into from

Conversation

alexlatchford
Copy link
Contributor

Description of your changes:

Argo has some great functionality the SDK doesn't expose by default. In particular, we're interested in using the PodSecurityContext and podSpecPatch functionality but needing to get in an upstream PR to leverage the functionality seems a little slow so wondering if this is an approach is something maintainers would consider.

No cherry-picking required.


Example usage:

from typing import Dict
from kfp.compiler._op_to_template import _op_to_template
from kfp.dsl._container_op import BaseOp, ContainerOp

def my_template_handler(op: BaseOp) -> Dict:
    template = _op_to_template(op)
    # See https://argoproj.github.io/argo/fields/#podsecuritycontext
    template['securityContext'] = {"fsGroup": 2000}
    return template

...

op = ContainerOp(...)
op.set_template_handler(my_template_handler)

Going to guess this may not pass review given a desire to hide away the underlying scheduler but open to improving this as needed.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alexlatchford
To complete the pull request process, please assign ark-kun after the PR has been reviewed.
You can assign the PR to them by writing /assign @ark-kun in a comment when ready.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

@alexlatchford: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
kubeflow-pipelines-tfx-python36 576f10c link /test kubeflow-pipelines-tfx-python36

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@Ark-kun
Copy link
Contributor

Ark-kun commented Jan 14, 2021

We have plans to implement ResourceOp on top of ContainerOp. It's also the way that Argo implements this internally - just a container with the executor which calls kubectl.
This might give you more flexibility and portability.

We have some reservations regarding exposing Argo-specific structures and types (e.g. Template) in the public SDK surface.

What do you think?

@Ark-kun Ark-kun self-assigned this Jan 14, 2021
@Ark-kun Ark-kun self-requested a review January 14, 2021 10:27
@alexlatchford
Copy link
Contributor Author

We have plans to implement ResourceOp on top of ContainerOp. It's also the way that Argo implements this internally - just a container with the executor which calls kubectl.
This might give you more flexibility and portability.

Maybe I'm lacking a little knowledge here about ResourceOp but my understanding was that functionality was for creating additional resources whereas podSpecPatch and podSecurityContext would modify existing steps?

I guess taking a step back from an end user perspective what we're trying to achieve is:

  1. Skirt this bug which means AWS IAM role tokens are mounted as root, we want to leverage podSecurityContext to force volume mounts to have a specific fsGroup to force them to be readable as non-root users. Currently all of our pipeline steps which interact with AWS resources need to run as root 😅
  2. We have some larger pipelines wanting to be run atop KFP and dynamically set the resources of containers at runtime to fit data partitions we don't know sizes until then will save us some significant compute costs, we're thinking podSpecPatch is the desired approach from Argo to achieve that.

I'd be happy with a ResourceOp solution if it can hit these goals 😄

We have some reservations regarding exposing Argo-specific structures and types (e.g. Template) in the public SDK surface.

Makes sense, looking at the API I suspected this to be a blocker 😄

@chensun chensun force-pushed the master branch 2 times, most recently from 7542f0e to 44d22a6 Compare February 12, 2021 09:23
@Bobgy
Copy link
Contributor

Bobgy commented Apr 2, 2021

/assign @chensun @neuromage

@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Mar 2, 2022
@rimolive
Copy link
Member

Closing this PR. No activity for more than a year.

/close

@stale stale bot removed the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Mar 24, 2024
Copy link

@rimolive: Closed this PR.

In response to this:

Closing this PR. No activity for more than a year.

/close

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.

@google-oss-prow google-oss-prow bot closed this Mar 24, 2024
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.

7 participants