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: Update visualization v2 to output HTML and Markdown. Partial #3970 #6349

Merged
merged 5 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions samples/test/metrics_visualization_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
ClassificationMetrics,
Metrics,
)
from kfp.dsl.io_types import Markdown
from kfp.dsl.io_types import HTML

# In tests, we install a KFP package from the PR under test. Users should not
# normally need to specify `kfp_package_path` in their component definitions.
Expand Down Expand Up @@ -113,9 +115,27 @@ def iris_sgdclassifier(test_samples_fraction: float, metrics: Output[Classificat
confusion_matrix(train_y, predictions).tolist() # .tolist() to convert np array to list.
)

@component(
kfp_package_path='git+https://github.com/kubeflow/pipelines#egg=kfp&subdirectory=sdk/python'
zijianjoy marked this conversation as resolved.
Show resolved Hide resolved
)
def html_visualization(html_artifact: Output[HTML]):
html_content = '<!DOCTYPE html><html><body><h1>Hello world</h1></body></html>'
with open(html_artifact.path, 'w') as f:
f.write(html_content)

@component(
kfp_package_path='git+https://github.com/kubeflow/pipelines#egg=kfp&subdirectory=sdk/python'
)
def markdown_visualization(markdown_artifact: Output[Markdown]):
markdown_content = '## Hello world \n\n Markdown content'
with open(markdown_artifact.path, 'w') as f:
f.write(markdown_content)

@dsl.pipeline(
name='metrics-visualization-pipeline')
def metrics_visualization_pipeline():
wine_classification_op = wine_classification()
iris_sgdclassifier_op = iris_sgdclassifier(test_samples_fraction=0.3)
digit_classification_op = digit_classification()
html_visualization_op = html_visualization()
markdown_visualization_op = markdown_visualization()
2 changes: 1 addition & 1 deletion samples/test/metrics_visualization_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def verify(run: kfp_server_api.ApiRun, mlmd_connection_config, **kwargs):
task_names = [*tasks.keys()]
t.assertCountEqual(
task_names,
['wine-classification', 'iris-sgdclassifier', 'digit-classification'],
['wine-classification', 'iris-sgdclassifier', 'digit-classification', 'html-visualization', 'markdown-visualization'],
zijianjoy marked this conversation as resolved.
Show resolved Hide resolved
'task names'
)

Expand Down