Skip to content

Commit

Permalink
Fixed Kubeflow sample test (#1096)
Browse files Browse the repository at this point in the history
* Fixed Kubeflow sample test

* Fixed the artifact-finding logic in `get_artifact_in_minio`.
It was just taking the first artifact before.
Now it properly searches the artifact by name.
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Apr 6, 2019
1 parent b36c7bc commit c938247
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/sample-test/run_kubeflow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def main():
# target, predicted, count
cm_tar_path = './confusion_matrix.tar.gz'
cm_filename = 'mlpipeline-ui-metadata.json'
utils.get_artifact_in_minio(workflow_json, 'confusionmatrix', cm_tar_path)
utils.get_artifact_in_minio(workflow_json, 'confusion-matrix', cm_tar_path)
tar_handler = tarfile.open(cm_tar_path)
tar_handler.extractall()

Expand Down
10 changes: 6 additions & 4 deletions test/sample-test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@

# Parse the workflow json to obtain the artifacts for a particular step.
# Note: the step_name could be the key words.
def get_artifact_in_minio(workflow_json, step_name, output_path):
def get_artifact_in_minio(workflow_json, step_name, output_path, artifact_name='mlpipeline-ui-metadata'):
s3_data = {}
minio_access_key = 'minio'
minio_secret_key = 'minio123'
try:
for key in workflow_json['status']['nodes'].keys():
if step_name in workflow_json['status']['nodes'][key]['name']:
s3_data = workflow_json['status']['nodes'][key]['outputs']['artifacts'][0]['s3']
for node in workflow_json['status']['nodes'].values():
if step_name in node['name']:
for artifact in node['outputs']['artifacts']:
if artifact['name'] == artifact_name:
s3_data = artifact['s3']
minio_client = Minio(s3_data['endpoint'], access_key=minio_access_key, secret_key=minio_secret_key, secure=False)
data = minio_client.get_object(s3_data['bucket'], s3_data['key'])
with open(output_path, 'wb') as file:
Expand Down

0 comments on commit c938247

Please sign in to comment.