Skip to content

Commit

Permalink
Fix v1 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-yaqi committed Aug 19, 2021
1 parent 5b7233d commit 0e3f290
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ spec:
"INT"}, "uri": {"type": "STRING"}}, "inputArtifacts": {}, "outputParameters":
{"output_parameter_one": {"type": "INT", "path": "/tmp/outputs/output_parameter_one/data"}},
"outputArtifacts": {"output_dataset_one": {"schemaTitle": "system.Dataset",
"instanceSchema": "", "metadataPath": "/tmp/outputs/output_dataset_one/data"}}}'}
"instanceSchema": "", "schemaVersion": "0.0.1", "metadataPath": "/tmp/outputs/output_dataset_one/data"}}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
Expand Down Expand Up @@ -200,9 +200,9 @@ spec:
- {name: KFP_V2_IMAGE, value: 'python:3.7'}
- {name: KFP_V2_RUNTIME_INFO, value: '{"inputParameters": {"num_steps": {"type":
"INT"}}, "inputArtifacts": {"dataset": {"metadataPath": "/tmp/inputs/dataset/data",
"schemaTitle": "system.Dataset", "instanceSchema": ""}}, "outputParameters":
"schemaTitle": "system.Dataset", "instanceSchema": "", "schemaVersion": "0.0.1"}}, "outputParameters":
{}, "outputArtifacts": {"model": {"schemaTitle": "system.Model", "instanceSchema":
"", "metadataPath": "/tmp/outputs/model/data"}}}'}
"", "schemaVersion": "0.0.1", "metadataPath": "/tmp/outputs/model/data"}}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ spec:
"INT"}, "uri": {"type": "STRING"}}, "inputArtifacts": {}, "outputParameters":
{"output_parameter_one": {"type": "INT", "path": "/tmp/outputs/output_parameter_one/data"}},
"outputArtifacts": {"output_dataset_one": {"schemaTitle": "system.Dataset",
"instanceSchema": "", "metadataPath": "/tmp/outputs/output_dataset_one/data"}}}'}
"instanceSchema": "", "schemaVersion": "0.0.1", "metadataPath": "/tmp/outputs/output_dataset_one/data"}}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
Expand Down Expand Up @@ -200,9 +200,9 @@ spec:
- {name: KFP_V2_IMAGE, value: 'python:3.7'}
- {name: KFP_V2_RUNTIME_INFO, value: '{"inputParameters": {"num_steps": {"type":
"INT"}}, "inputArtifacts": {"dataset": {"metadataPath": "/tmp/inputs/dataset/data",
"schemaTitle": "system.Dataset", "instanceSchema": ""}}, "outputParameters":
"schemaTitle": "system.Dataset", "instanceSchema": "", "schemaVersion": "0.0.1"}}, "outputParameters":
{}, "outputArtifacts": {"model": {"schemaTitle": "system.Model", "instanceSchema":
"", "metadataPath": "/tmp/outputs/model/data"}}}'}
"", "schemaVersion": "0.0.1", "metadataPath": "/tmp/outputs/model/data"}}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/tests/compiler/compiler_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,33 +487,33 @@ def my_pipeline(memory: str, cpu: str):
template = name_to_template[main_dag_tasks[0]['template']]

self.assertEqual(template['podSpecPatch'], '{"containers": [{"name": "main", "resources": {"requests": {"cpu": "{{inputs.parameters.memory}}"}}}]}')

def test_py_runtime_gpu_request(self):
"""Test GPU request."""

def my_pipeline(nbr_gpus: int, gpu_vendor: str):
some_op().set_gpu_limit(nbr_gpus, gpu_vendor)

workflow = kfp.compiler.Compiler()._create_workflow(my_pipeline)
name_to_template = {template['name']: template for template in workflow['spec']['templates']}
main_dag_tasks = name_to_template[workflow['spec']['entrypoint']]['dag']['tasks']
template = name_to_template[main_dag_tasks[0]['template']]

self.assertEqual(template['podSpecPatch'], '{"containers": [{"name": "main", "resources": {"limits": {"{{inputs.parameters.gpu_vendor}}": "{{inputs.parameters.nbr_gpus}}"}}}]}')

def test_py_runtime_node_selection(self):
"""Test node selection request."""

def my_pipeline(constrain_type: str, constrain_value: str):
some_op().add_node_selector_constraint(constrain_type, constrain_value)

workflow = kfp.compiler.Compiler()._create_workflow(my_pipeline)
name_to_template = {template['name']: template for template in workflow['spec']['templates']}
main_dag_tasks = name_to_template[workflow['spec']['entrypoint']]['dag']['tasks']
template = name_to_template[main_dag_tasks[0]['template']]

self.assertEqual(template['podSpecPatch'], '{"nodeSelector": [{"{{inputs.parameters.constrain_type}}": "{{inputs.parameters.constrain_value}}"}]}')


def test_py_retry_policy_invalid(self):
def my_pipeline():
Expand Down
18 changes: 9 additions & 9 deletions sdk/python/tests/compiler/testdata/uri_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
pipelines.kubeflow.org/pipeline_compilation_time: '2021-08-07T00:27:52.329848'
pipelines.kubeflow.org/pipeline_spec: '{"inputs": [{"default": "Hello world!",
"name": "text", "optional": true, "type": "String"}, {"default": "gs://my-bucket/my-output-dir",
"name": "pipeline-root"}, {"default": "pipeline/uri-artifact-pipeline",
"name": "pipeline-name"}], "name": "uri-artifact-pipeline"}'
"name": "pipeline-root"}, {"default": "pipeline/uri-artifact-pipeline", "name":
"pipeline-name"}], "name": "uri-artifact-pipeline"}'
pipelines.kubeflow.org/v2_pipeline: "true"
labels:
pipelines.kubeflow.org/v2_pipeline: "true"
Expand Down Expand Up @@ -154,8 +154,8 @@ spec:
- {name: KFP_V2_IMAGE, value: 'google/cloud-sdk:slim'}
- {name: KFP_V2_RUNTIME_INFO, value: '{"inputParameters": {}, "inputArtifacts":
{"input_gcs_path": {"metadataPath": "/tmp/inputs/input_gcs_path/data", "schemaTitle":
"system.Artifact", "instanceSchema": ""}}, "outputParameters": {}, "outputArtifacts":
{}}'}
"system.Artifact", "instanceSchema": "", "schemaVersion": "0.0.1"}}, "outputParameters":
{}, "outputArtifacts": {}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
Expand Down Expand Up @@ -221,8 +221,8 @@ spec:
- {name: KFP_V2_IMAGE, value: 'google/cloud-sdk:slim'}
- {name: KFP_V2_RUNTIME_INFO, value: '{"inputParameters": {}, "inputArtifacts":
{"input_gcs_path": {"metadataPath": "/tmp/inputs/input_gcs_path/data", "schemaTitle":
"system.Artifact", "instanceSchema": ""}}, "outputParameters": {}, "outputArtifacts":
{}}'}
"system.Artifact", "instanceSchema": "", "schemaVersion": "0.0.1"}}, "outputParameters":
{}, "outputArtifacts": {}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
Expand Down Expand Up @@ -288,8 +288,8 @@ spec:
- {name: KFP_V2_IMAGE, value: 'google/cloud-sdk:slim'}
- {name: KFP_V2_RUNTIME_INFO, value: '{"inputParameters": {}, "inputArtifacts":
{"input_gcs_path": {"metadataPath": "/tmp/inputs/input_gcs_path/data", "schemaTitle":
"system.Artifact", "instanceSchema": ""}}, "outputParameters": {}, "outputArtifacts":
{}}'}
"system.Artifact", "instanceSchema": "", "schemaVersion": "0.0.1"}}, "outputParameters":
{}, "outputArtifacts": {}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
Expand Down Expand Up @@ -408,7 +408,7 @@ spec:
- {name: KFP_V2_RUNTIME_INFO, value: '{"inputParameters": {"text": {"type":
"STRING"}}, "inputArtifacts": {}, "outputParameters": {}, "outputArtifacts":
{"output_gcs_path": {"schemaTitle": "system.Artifact", "instanceSchema":
"", "metadataPath": "/tmp/outputs/output_gcs_path/data"}}}'}
"", "schemaVersion": "0.0.1", "metadataPath": "/tmp/outputs/output_gcs_path/data"}}}'}
envFrom:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
Expand Down

0 comments on commit 0e3f290

Please sign in to comment.