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

test(sdk): add test for local execution of None default parameter #localexecution #10339

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

connor-mccarthy
Copy link
Member

@connor-mccarthy connor-mccarthy commented Dec 20, 2023

Description of your changes:
Adds a test for local execution of optional parameters (e.g., my_comp(x: Optional[str] = None).

Checklist:

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

@connor-mccarthy connor-mccarthy changed the title test(sdk): add test for None default parameter #localexecution test(sdk): add test for local execution of None default parameter #localexecution Dec 20, 2023
@google-oss-prow google-oss-prow bot added size/M and removed size/XL labels Jan 3, 2024
@connor-mccarthy connor-mccarthy marked this pull request as ready for review January 3, 2024 19:31
@connor-mccarthy
Copy link
Member Author

/assign @chensun

output_parameters[float_output_key] = int(
output_parameters[float_output_key])
for int_output_key in int_output_keys:
# avoid KeyError when the user never writes to the dsl.OutputPath
Copy link
Member

Choose a reason for hiding this comment

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

#10338 should be merged into the same PR then, so the fix and test are together.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. My mistake. This was my rebase error; I included this file in the wrong PR. Fixed now.


@dsl.component
def my_comp(string: Optional[str] = None):
assert string is None
Copy link
Member

Choose a reason for hiding this comment

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

This component by itself is wrong--the input parameter cannot accept any other input values.
I think a more proper way to test optional default value would be move assert outside component implementation:

@dsl.component
def my_comp(string: Optional[str] = None) -> str:
    return 'default' if string is None else 'non-default'

task = my_comp()
self.assertEqual(task.outputs, 'default')

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. Fixed.

Copy link
Member

@chensun chensun left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

thanks!

Copy link
Member Author

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

Thanks for the good catches. Will wait to merge until after #10338 to avoid competing changes.


@dsl.component
def my_comp(string: Optional[str] = None):
assert string is None
Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. Fixed.

output_parameters[float_output_key] = int(
output_parameters[float_output_key])
for int_output_key in int_output_keys:
# avoid KeyError when the user never writes to the dsl.OutputPath
Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. My mistake. This was my rebase error; I included this file in the wrong PR. Fixed now.

@connor-mccarthy
Copy link
Member Author

/retest

Copy link
Member

@chensun chensun 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 Jan 5, 2024
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chensun

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

Copy link

@connor-mccarthy: 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
kfp-kubernetes-execution-tests 4c56b53 link false /test kfp-kubernetes-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

@chensun chensun 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 Jan 5, 2024
@google-oss-prow google-oss-prow bot merged commit ca5f97d into kubeflow:master Jan 5, 2024
27 of 28 checks passed
stijntratsaertit pushed a commit to stijntratsaertit/kfp that referenced this pull request Feb 16, 2024
petethegreat pushed a commit to petethegreat/pipelines that referenced this pull request Mar 27, 2024
petethegreat pushed a commit to petethegreat/pipelines that referenced this pull request Mar 29, 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.

2 participants