def verify(run: kfp_server_api.ApiRun, mlmd_connection_config, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) verify_tasks(t, tasks)
def verify(run: kfp_server_api.ApiRun, mlmd_connection_config, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) pprint(tasks) output_artifact = tasks['output-artifact'] output = [ a for a in output_artifact.outputs.artifacts if a.name == 'Output' ][0] pprint(output) host = os.environ['MINIO_SERVICE_SERVICE_HOST'] port = os.environ['MINIO_SERVICE_SERVICE_PORT'] minio = Minio(f'{host}:{port}', access_key='minio', secret_key='minio123', secure=False) bucket, key = output.uri[len('minio://'):].split('/', 1) print(f'bucket={bucket} key={key}') response = minio.get_object(bucket, key) data = response.read().decode('UTF-8') t.assertEqual(data, 'firstsecond\nfirstsecond\nfirstsecond')
def verify_with_specific_pipeline_root(run: kfp_server_api.ApiRun, mlmd_connection_config, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) verify_tasks(t, tasks) verify_artifacts(t, tasks, 'minio://mlpipeline/override/artifacts')
def verify(run, mlmd_connection_config, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) t.assertEqual(17, tasks['add-3'].outputs.parameters['sum'], 'add result should be 17')
def verify(run: kfp_server_api.ApiRun, mlmd_connection_config, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) pprint(tasks) roc_visualization = tasks['roc-visualization'] output = [ a for a in roc_visualization.outputs.artifacts if a.name == 'mlpipeline_ui_metadata' ][0] pprint(output) t.assertEqual( roc_visualization.get_dict()['outputs']['artifacts'][0]['name'], 'mlpipeline_ui_metadata')
def verify(mlmd_connection_config, run: kfp_server_api.ApiRun, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') # Verify MLMD state client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) task_names = [*tasks.keys()] t.assertEqual(task_names, ['echo-msg', 'print-file', 'download-from-gcs']) for task in task_names: pprint(f'======= {task} =======') pprint(tasks.get(task).get_dict()) t.assertEqual( tasks.get('echo-msg').inputs.parameters.get('msg'), 'exit!', )
def verify(run: kfp_server_api.ApiRun, mlmd_connection_config, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) # uncomment to debug # pprint(tasks) vis = tasks['create-tensorboard-visualization'] pprint(vis) mlpipeline_ui_metadata = vis.outputs.artifacts[0] t.assertEqual(mlpipeline_ui_metadata.name, 'mlpipeline-ui-metadata') # download artifact content storage_client = storage.Client() blob = storage.Blob.from_string(mlpipeline_ui_metadata.uri, storage_client) data = blob.download_as_text(storage_client) data = json.loads(data) t.assertTrue(data["outputs"][0]["source"]) # source is a URI that is generated differently each run data["outputs"][0]["source"] = "<redacted>" t.assertEqual( { "outputs": [{ "type": "tensorboard", "source": "<redacted>", "image": "gcr.io/deeplearning-platform-release/tf2-cpu.2-3:latest", "pod_template_spec": { "spec": { "containers": [{ "env": [{ "name": "AWS_ACCESS_KEY_ID", "valueFrom": { "secretKeyRef": { "name": "mlpipeline-minio-artifact", "key": "accesskey" } } }, { "name": "AWS_SECRET_ACCESS_KEY", "valueFrom": { "secretKeyRef": { "name": "mlpipeline-minio-artifact", "key": "secretkey" } } }, { "name": "AWS_REGION", "value": "minio" }, { "name": "S3_ENDPOINT", "value": "minio-service:9000" }, { "name": "S3_USE_HTTPS", "value": "0" }, { "name": "S3_VERIFY_SSL", "value": "0" }] }] } } }] }, data)
def verify(run: kfp_server_api.ApiRun, mlmd_connection_config, **kwargs): t = unittest.TestCase() t.maxDiff = None # we always want to see full diff t.assertEqual(run.status, 'Succeeded') client = KfpMlmdClient(mlmd_connection_config=mlmd_connection_config) tasks = client.get_tasks(run_id=run.id) task_names = [*tasks.keys()] t.assertCountEqual(task_names, ['preprocess', 'train'], 'task names') pprint(tasks) preprocess = tasks['preprocess'] train = tasks['train'] pprint(preprocess.get_dict()) t.assertEqual( { 'inputs': { 'parameters': { 'message': 'message', } }, 'name': 'preprocess', 'outputs': { 'artifacts': [{ 'metadata': { 'display_name': 'output_dataset_one' }, 'name': 'output_dataset_one', 'type': 'system.Dataset' }, { 'metadata': { 'display_name': 'output_dataset_two_path' }, 'name': 'output_dataset_two_path', 'type': 'system.Dataset' }], 'parameters': { 'output_bool_parameter_path': True, 'output_dict_parameter_path': { "A": 1, "B": 2 }, 'output_list_parameter_path': ["a", "b", "c"], 'output_parameter_path': 'message' } }, 'type': 'system.ContainerExecution', 'state': Execution.State.COMPLETE, }, preprocess.get_dict(), ) t.assertEqual( { 'inputs': { 'artifacts': [{ 'metadata': { 'display_name': 'output_dataset_one' }, 'name': 'dataset_one_path', 'type': 'system.Dataset' }, { 'metadata': { 'display_name': 'output_dataset_two_path' }, 'name': 'dataset_two', 'type': 'system.Dataset' }], 'parameters': { 'input_bool': True, 'input_dict': { "A": 1.0, "B": 2.0, }, 'input_list': ["a", "b", "c"], 'message': 'message' } }, 'name': 'train', 'outputs': { 'artifacts': [{ 'metadata': { 'display_name': 'model', 'accuracy': 0.9, }, 'name': 'model', 'type': 'system.Model' }], }, 'type': 'system.ContainerExecution', 'state': Execution.State.COMPLETE, }, train.get_dict(), )