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): Support setting cpu/memory requests. #9121

Merged
merged 3 commits into from
Apr 11, 2023

Conversation

chensun
Copy link
Member

@chensun chensun commented Apr 7, 2023

Description of your changes:

Checklist:

@google-oss-prow
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from chensun. For more information see the Kubernetes Code Review Process.

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

@chensun chensun force-pushed the resource-requests branch from 0eadd76 to 95529f8 Compare April 7, 2023 20:47
@chensun chensun marked this pull request as ready for review April 10, 2023 21:19
@chensun
Copy link
Member Author

chensun commented Apr 10, 2023

/assign @connor-mccarthy

Copy link
Member

@connor-mccarthy connor-mccarthy left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks, @chensun.


if self.container_spec is None:
raise ValueError(
'There is no container specified in implementation')
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to convert this to a more user-facing message indicating that cpu can only be set on single-step components, not pipelines used as a component?

Copy link
Member

Choose a reason for hiding this comment

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

Also, maybe it makes sense to move this shared check into the validate method (or a separate validation method) for DRY code? Not sure what's best, but want to mention it.

@google-oss-prow google-oss-prow bot added lgtm and removed lgtm labels Apr 10, 2023
@chensun chensun force-pushed the resource-requests branch from c6cb0af to 6c4cdc3 Compare April 10, 2023 22:23
Copy link
Member

@connor-mccarthy connor-mccarthy left a comment

Choose a reason for hiding this comment

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

/lgtm

@@ -246,6 +246,13 @@ def set_caching_options(self, enable_caching: bool) -> 'PipelineTask':
self._task_spec.enable_caching = enable_caching
return self

def _ensure_container_spec_exists(self) -> None:
Copy link
Member

@connor-mccarthy connor-mccarthy Apr 10, 2023

Choose a reason for hiding this comment

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

Micro improvement suggestion: Could also use a method_name: str param to which you pass self.set_memory_limit.__name__ from within .set_memory_limit()(or whatever the method is) to include the method name in the error message.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't really reference self.func from within the same func. Opted to use inspect to achieve the same goal.

Copy link
Member

Choose a reason for hiding this comment

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

SG. inspect works!

Here's what I had in mind. Curious, where did things break down?

class Cls:
    def method(self):
        self.printer(self.method.__name__)

    def printer(self, name):
        print(name)

Cls().method()
>>> 'method'

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, that works, I thought I tried the same and got the error but maybe I missed something else.
Anyway, I think I'll keep the inspect approach in favor of there's less effort for the caller to pass in values.

@google-oss-prow google-oss-prow bot added the lgtm label Apr 10, 2023
@google-oss-prow google-oss-prow bot removed the lgtm label Apr 10, 2023
@google-oss-prow
Copy link

@chensun: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
kubeflow-pipelines-sdk-execution-tests ad49045 link true /test kubeflow-pipelines-sdk-execution-tests

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.

Copy link
Member

@connor-mccarthy connor-mccarthy left a comment

Choose a reason for hiding this comment

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

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Apr 11, 2023
@chensun
Copy link
Member Author

chensun commented Apr 11, 2023

kubeflow-pipelines-sdk-execution-tests failure is known issue unrelated to the change, and it's expected to be resolved by next backend release. Merge as-is.

@chensun chensun merged commit a6ef77b into kubeflow:master Apr 11, 2023
@chensun chensun deleted the resource-requests branch April 11, 2023 06:35
rd-pong pushed a commit to rd-pong/pipelines that referenced this pull request Apr 26, 2023
* Support setting cpu/memory requests.

* address review comments

* address review comments
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.

2 participants