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

Testing/Sample - Made checking confusion matrix data more robust #1196

Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 9 additions & 8 deletions test/sample-test/run_kubeflow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import argparse
import os
import io
import json
import tarfile
from datetime import datetime
Expand Down Expand Up @@ -107,14 +108,14 @@ def main():
# confusion matrix should show three columns for the flower data
# target, predicted, count
cm_tar_path = './confusion_matrix.tar.gz'
cm_filename = 'mlpipeline-ui-metadata.json'
utils.get_artifact_in_minio(workflow_json, 'confusion-matrix', cm_tar_path)
tar_handler = tarfile.open(cm_tar_path)
tar_handler.extractall()

with open(cm_filename, 'r') as f:
cm_data = json.load(f)
utils.add_junit_test(test_cases, 'confusion matrix format', (len(cm_data['outputs'][0]['schema']) == 3), 'the column number of the confusion matrix output is not equal to three')
utils.get_artifact_in_minio(workflow_json, 'confusion-matrix', cm_tar_path, 'mlpipeline-ui-metadata')
with tarfile.open(cm_tar_path) as tar_handle:
file_handles = tar_handle.getmembers()
assert len(file_handles) == 1

with tar_handle.extractfile(file_handles[0]) as f:
cm_data = json.load(io.TextIOWrapper(f))
utils.add_junit_test(test_cases, 'confusion matrix format', (len(cm_data['outputs'][0]['schema']) == 3), 'the column number of the confusion matrix output is not equal to three')

###### Delete Job ######
#TODO: add deletion when the backend API offers the interface.
Expand Down
16 changes: 8 additions & 8 deletions test/sample-test/run_xgboost_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ def main():
# confusion matrix should show three columns for the flower data
# target, predicted, count
cm_tar_path = './confusion_matrix.tar.gz'
cm_filename = 'mlpipeline-ui-metadata.json'
utils.get_artifact_in_minio(workflow_json, 'confusion-matrix', cm_tar_path)
tar_handler = tarfile.open(cm_tar_path)
tar_handler.extractall()

with open(cm_filename, 'r') as f:
cm_data = f.read()
utils.add_junit_test(test_cases, 'confusion matrix format', (len(cm_data) > 0), 'the confusion matrix file is empty')
utils.get_artifact_in_minio(workflow_json, 'confusion-matrix', cm_tar_path, 'mlpipeline-ui-metadata')
with tarfile.open(cm_tar_path) as tar_handle:
file_handles = tar_handle.getmembers()
assert len(file_handles) == 1

with tar_handle.extractfile(file_handles[0]) as f:
cm_data = f.read()
gaoning777 marked this conversation as resolved.
Show resolved Hide resolved
utils.add_junit_test(test_cases, 'confusion matrix format', (len(cm_data) > 0), 'the confusion matrix file is empty')

###### Delete Job ######
#TODO: add deletion when the backend API offers the interface.
Expand Down