forked from opendatahub-io/data-science-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sdk): handle the node selectors (kubeflow#916)
Handle the node selector info from PipelineConf in compiler. Node selector info in Op level could overide PipelinConf. settings. Signed-off-by: Yihong Wang <yh.wang@ibm.com>
- Loading branch information
Showing
6 changed files
with
236 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
sdk/python/tests/compiler/testdata/node_selector_from_pipeline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2020 kubeflow.org | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from kfp import dsl, components | ||
|
||
|
||
def echo_op(): | ||
return components.load_component_from_text(""" | ||
name: echo | ||
description: echo | ||
implementation: | ||
container: | ||
image: busybox | ||
command: | ||
- sh | ||
- -c | ||
args: | ||
- echo | ||
- Found my node | ||
""")() | ||
|
||
|
||
@dsl.pipeline( | ||
name='node-selector', | ||
description='A pipeline with Node Selector' | ||
) | ||
def node_selector_pipeline( | ||
): | ||
dsl.get_pipeline_conf().set_default_pod_node_selector('kubernetes.io/os', 'linux') | ||
echo_op() | ||
|
||
|
||
if __name__ == '__main__': | ||
from kfp_tekton.compiler import TektonCompiler | ||
TektonCompiler().compile(node_selector_pipeline, __file__.replace('.py', '.yaml')) |
59 changes: 59 additions & 0 deletions
59
sdk/python/tests/compiler/testdata/node_selector_from_pipeline.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright 2021 kubeflow.org | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
name: node-selector | ||
annotations: | ||
tekton.dev/output_artifacts: '{}' | ||
tekton.dev/input_artifacts: '{}' | ||
tekton.dev/artifact_bucket: mlpipeline | ||
tekton.dev/artifact_endpoint: minio-service.kubeflow:9000 | ||
tekton.dev/artifact_endpoint_scheme: http:// | ||
tekton.dev/artifact_items: '{"echo": []}' | ||
sidecar.istio.io/inject: "false" | ||
pipelines.kubeflow.org/big_data_passing_format: $(workspaces.$TASK_NAME.path)/artifacts/$ORIG_PR_NAME/$TASKRUN_NAME/$TASK_PARAM_NAME | ||
pipelines.kubeflow.org/pipeline_spec: '{"description": "A pipeline with Node Selector", | ||
"name": "node-selector"}' | ||
spec: | ||
pipelineSpec: | ||
tasks: | ||
- name: echo | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: | ||
- echo | ||
- Found my node | ||
command: | ||
- sh | ||
- -c | ||
image: busybox | ||
metadata: | ||
labels: | ||
pipelines.kubeflow.org/pipelinename: '' | ||
pipelines.kubeflow.org/generation: '' | ||
pipelines.kubeflow.org/cache_enabled: "true" | ||
annotations: | ||
pipelines.kubeflow.org/component_spec_digest: '{"name": "echo", "outputs": | ||
[], "version": "echo@sha256=e351a00f59eb0eb8d614bb41816020b768770ba7513a5b3c0c7ea5c2efa9c6d6"}' | ||
tekton.dev/template: '' | ||
timeout: 525600m | ||
taskRunSpecs: | ||
- pipelineTaskName: echo | ||
taskPodTemplate: | ||
nodeSelector: | ||
kubernetes.io/os: linux | ||
timeout: 525600m |
48 changes: 48 additions & 0 deletions
48
sdk/python/tests/compiler/testdata/node_selector_from_pipeline_override.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2020 kubeflow.org | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from kfp import dsl, components | ||
|
||
|
||
def echo_op(): | ||
return components.load_component_from_text(""" | ||
name: echo | ||
description: echo | ||
implementation: | ||
container: | ||
image: busybox | ||
command: | ||
- sh | ||
- -c | ||
args: | ||
- echo | ||
- Found my node | ||
""")() | ||
|
||
|
||
@dsl.pipeline( | ||
name='node-selector', | ||
description='A pipeline with Node Selector' | ||
) | ||
def node_selector_pipeline( | ||
): | ||
dsl.get_pipeline_conf().set_default_pod_node_selector('kubernetes.io/os', 'linux') | ||
echo_op().add_node_selector_constraint( | ||
label_name='kubernetes.io/os', | ||
value='windows') | ||
|
||
|
||
if __name__ == '__main__': | ||
from kfp_tekton.compiler import TektonCompiler | ||
TektonCompiler().compile(node_selector_pipeline, __file__.replace('.py', '.yaml')) |
59 changes: 59 additions & 0 deletions
59
sdk/python/tests/compiler/testdata/node_selector_from_pipeline_override.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright 2021 kubeflow.org | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
name: node-selector | ||
annotations: | ||
tekton.dev/output_artifacts: '{}' | ||
tekton.dev/input_artifacts: '{}' | ||
tekton.dev/artifact_bucket: mlpipeline | ||
tekton.dev/artifact_endpoint: minio-service.kubeflow:9000 | ||
tekton.dev/artifact_endpoint_scheme: http:// | ||
tekton.dev/artifact_items: '{"echo": []}' | ||
sidecar.istio.io/inject: "false" | ||
pipelines.kubeflow.org/big_data_passing_format: $(workspaces.$TASK_NAME.path)/artifacts/$ORIG_PR_NAME/$TASKRUN_NAME/$TASK_PARAM_NAME | ||
pipelines.kubeflow.org/pipeline_spec: '{"description": "A pipeline with Node Selector", | ||
"name": "node-selector"}' | ||
spec: | ||
pipelineSpec: | ||
tasks: | ||
- name: echo | ||
taskSpec: | ||
steps: | ||
- name: main | ||
args: | ||
- echo | ||
- Found my node | ||
command: | ||
- sh | ||
- -c | ||
image: busybox | ||
metadata: | ||
labels: | ||
pipelines.kubeflow.org/pipelinename: '' | ||
pipelines.kubeflow.org/generation: '' | ||
pipelines.kubeflow.org/cache_enabled: "true" | ||
annotations: | ||
pipelines.kubeflow.org/component_spec_digest: '{"name": "echo", "outputs": | ||
[], "version": "echo@sha256=e351a00f59eb0eb8d614bb41816020b768770ba7513a5b3c0c7ea5c2efa9c6d6"}' | ||
tekton.dev/template: '' | ||
timeout: 525600m | ||
taskRunSpecs: | ||
- pipelineTaskName: echo | ||
taskPodTemplate: | ||
nodeSelector: | ||
kubernetes.io/os: windows | ||
timeout: 525600m |