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 load_component_from_* #6822

Merged
merged 5 commits into from
Oct 29, 2021
Merged

Conversation

ji-yaqi
Copy link
Contributor

@ji-yaqi ji-yaqi commented Oct 27, 2021

No description provided.

"""Loads component from file.

Args:
file_path: A string containing path to the file. The file could be YAML file or a zip file with a 'component.yaml' file inside.
Copy link
Member

Choose a reason for hiding this comment

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

The file could be YAML file or a zip file with a 'component.yaml' file inside.

Sorry, I may have mislead you. I think we should add the zip support so it's fully backward compatible.

(Earlier I was talking about v1 compiler can produce zip files, because KFP UI support uploading zip, and we don't need to do it for v2)

def compile(self,
pipeline_func,
package_path,
type_check: bool = True,
pipeline_conf: Optional[dsl.PipelineConf] = None):
"""Compile the given pipeline function into workflow yaml.
Args:
pipeline_func: Pipeline functions with @dsl.pipeline decorator.
package_path: The output workflow tar.gz file path. for example,
"~/a.tar.gz"
type_check: Whether to enable the type check or not, default: True.
pipeline_conf: PipelineConf instance. Can specify op transforms, image
pull secrets and other pipeline-level configuration options. Overrides
any configuration that may be set by the pipeline.
"""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Synced offline, will add this feature if requested.

with open(file_path, 'rb') as component_stream:
return load_component_from_text(component_stream)

def load_component_from_url(url: str, auth=None) -> base_component.BaseComponent:
Copy link
Member

Choose a reason for hiding this comment

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

nit: Add docstring for public method, also type annotate auth (do we expect a string or what? I was not familiar with this usage).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added doc strings. auth should be Any type here, depending on the URL request.

- {outputPath: output1}
""")

class YamlComponentTest(parameterized.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

nit: seems like you are not using parameterized, so maybe change this to unittest?

def test_load_component_from_text(self):
component = yaml_component.load_component_from_text(SAMPLE_YAML)
self.assertEqual(component.component_spec.name, 'component_1')
self.assertEqual(component._component_inputs, {'input1'})
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe check outputs and container as well?

@ji-yaqi
Copy link
Contributor Author

ji-yaqi commented Oct 29, 2021

/test kubeflow-pipelines-samples-v2

@google-oss-robot
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 ji-yaqi merged commit f1bb852 into kubeflow:master Oct 29, 2021
@ji-yaqi ji-yaqi deleted the load_component branch October 29, 2021 05:30
abaland pushed a commit to abaland/pipelines that referenced this pull request May 29, 2022
* feat(sdk): add load_component_from_*

* address comments'
:

* update release notes
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