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(sdk): add default value for inputs #7405

Merged
merged 5 commits into from
Mar 23, 2022

Conversation

ji-yaqi
Copy link
Contributor

@ji-yaqi ji-yaqi commented Mar 11, 2022

Description of your changes:
Add default value for inputs, if it's specified.

Removed some already-broken deprecated tests for unit tests to pass.

@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

@ji-yaqi
Copy link
Contributor Author

ji-yaqi commented Mar 14, 2022

/test kubeflow-pipelines-samples-v2

sdk/python/kfp/deprecated/notebook/_magic.py Outdated Show resolved Hide resolved
@@ -20,13 +20,9 @@
from collections import OrderedDict
from typing import Callable, Dict, List, Optional

from deprecated.sphinx import deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Looks like shutil, kfp.deprecated.components, and kfp.deprecated.dsl are also unused imports. Thoughts on removing those as well?

@@ -378,6 +374,8 @@ def build_python_component(
add_files=add_files)

logging.info('Building and pushing container image.')

from kfp.deprecated.containers._container_builder import ContainerBuilder
Copy link
Member

Choose a reason for hiding this comment

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

Does moving this import to the top level per pylint c0415 import-outside-toplevel cause any issues?

return task_factory_function


@deprecated(
Copy link
Member

Choose a reason for hiding this comment

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

Does removing something like this require changes to our release notes/changelog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, adding to the release notes. Thanks

"format": {
"defaultValue": "csv",
"parameterType": "STRING"
},
Copy link
Member

Choose a reason for hiding this comment

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

This is a behavior change. Previously we "hide" this to workaround Vertex Pipelines backend's lack of support for optional inputs. Can we test submitting this and see if that limitation is gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried and worked on Optional inputs and xgboost examples.

continue

if type_utils.is_parameter_type(input_spec.type):
component_spec.input_definitions.parameters[
input_name].parameter_type = type_utils.get_parameter_type(
input_spec.type)
if input_spec.default is not None:
Copy link
Member

Choose a reason for hiding this comment

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

Not an issue with this PR, but I do realize this is not a universal solution for all default values. Because default value could be None:
e.g.:

@component
def my_component(some_input: Optional[str] = None):
    print(some_input)

The way we support this is to not passing the parameter at all (not showing up in component spec input definitions), so that it pick up the default value from the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, does unset behave the same as setting it to None? If they are the same, then probably it's okay here?

input_dict_parameter:
parameterType: STRUCT
message:
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why do we see such diffs? Does that mean the order is nondeterministic? Or the order depends on the specific version of a protobuf library?

/cc @connor-mccarthy

Copy link
Member

Choose a reason for hiding this comment

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

It appears only dsl.Condition and dsl.ParallelFor compilation steps produce non-deterministically ordered YAML.

I feel reasonably confident that this is not attributed to the actual "write yaml" code, but rather to how these conditions/loops are represented in the in-memory IR. I see we're using a defaultdict(set) here to store this data and I think the use of set could explain the non-determinism.

This probably warrants another PR to investigate: swapping out the defaultdict(set) for defaultdict(list) (and updating downstream methods from .add to .append) to see if this resolves the issue.

Copy link
Member

Choose a reason for hiding this comment

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

I think we might need to bring back sort_keys=True when exporting json/yaml. Not blocking this PR though.

@ji-yaqi
Copy link
Contributor Author

ji-yaqi commented Mar 22, 2022

/test kubeflow-pipelines-samples-v2

@ji-yaqi
Copy link
Contributor Author

ji-yaqi commented Mar 22, 2022

/retest-required

@chensun
Copy link
Member

chensun commented Mar 22, 2022

/lgtm

Thanks, Yaqi!

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

@ji-yaqi
Copy link
Contributor Author

ji-yaqi commented Mar 23, 2022

/test kubeflow-pipelines-samples-v2

@google-oss-prow google-oss-prow bot merged commit 0412328 into kubeflow:master Mar 23, 2022
abaland pushed a commit to abaland/pipelines that referenced this pull request May 29, 2022
* fix(sdk): add default value for inputs

* merge conflict

* release

* fix sample
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.

3 participants