Skip to content

Commit 8d018af

Browse files
authored
feat(sdk)!: stop auto-populating metrics as dag output (kubeflow#11362)
* feat(sdk)!: stop auto-populating metrics as dag output Signed-off-by: Chen Sun <[email protected]> * add release note Signed-off-by: Chen Sun <[email protected]> --------- Signed-off-by: Chen Sun <[email protected]>
1 parent f8973d2 commit 8d018af

File tree

5 files changed

+11
-137
lines changed

5 files changed

+11
-137
lines changed

sdk/RELEASE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Breaking changes
88

99
## Deprecations
10+
* Deprecate the metrics artifact auto-populating feature. [\#11362](https://github.com/kubeflow/pipelines/pull/11362)
1011

1112
## Bug fixes and other changes
1213

sdk/python/kfp/compiler/pipeline_spec_builder.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,67 +1131,6 @@ def build_task_spec_for_group(
11311131
return pipeline_task_spec
11321132

11331133

1134-
def populate_metrics_in_dag_outputs(
1135-
tasks: List[pipeline_task.PipelineTask],
1136-
task_name_to_parent_groups: Mapping[str,
1137-
List[compiler_utils.GroupOrTaskType]],
1138-
task_name_to_component_spec: Mapping[str, pipeline_spec_pb2.ComponentSpec],
1139-
pipeline_spec: pipeline_spec_pb2.PipelineSpec,
1140-
) -> None:
1141-
"""Populates metrics artifacts in DAG outputs.
1142-
1143-
Args:
1144-
tasks: The list of tasks that may produce metrics outputs.
1145-
task_name_to_parent_groups: The dict of task name to parent groups.
1146-
Key is the task's name. Value is a list of ancestor groups including
1147-
the task itself. The list of a given op is sorted in a way that the
1148-
farthest group is the first and the task itself is the last.
1149-
task_name_to_component_spec: The dict of task name to ComponentSpec.
1150-
pipeline_spec: The pipeline_spec to update in-place.
1151-
"""
1152-
for task in tasks:
1153-
component_spec = task_name_to_component_spec[task.name]
1154-
1155-
# Get the tuple of (component_name, task_name) of all its parent groups.
1156-
parent_components_and_tasks = [('_root', '')]
1157-
# skip the op itself and the root group which cannot be retrived via name.
1158-
for group_name in task_name_to_parent_groups[task.name][1:-1]:
1159-
parent_components_and_tasks.append(
1160-
(utils.sanitize_component_name(group_name),
1161-
utils.sanitize_task_name(group_name)))
1162-
# Reverse the order to make the farthest group in the end.
1163-
parent_components_and_tasks.reverse()
1164-
1165-
for output_name, artifact_spec in \
1166-
component_spec.output_definitions.artifacts.items():
1167-
1168-
if artifact_spec.artifact_type.WhichOneof(
1169-
'kind'
1170-
) == 'schema_title' and artifact_spec.artifact_type.schema_title in [
1171-
artifact_types.Metrics.schema_title,
1172-
artifact_types.ClassificationMetrics.schema_title,
1173-
]:
1174-
unique_output_name = f'{task.name}-{output_name}'
1175-
1176-
sub_task_name = task.name
1177-
sub_task_output = output_name
1178-
for component_name, task_name in parent_components_and_tasks:
1179-
group_component_spec = (
1180-
pipeline_spec.root if component_name == '_root' else
1181-
pipeline_spec.components[component_name])
1182-
group_component_spec.output_definitions.artifacts[
1183-
unique_output_name].CopyFrom(artifact_spec)
1184-
group_component_spec.dag.outputs.artifacts[
1185-
unique_output_name].artifact_selectors.append(
1186-
pipeline_spec_pb2.DagOutputsSpec
1187-
.ArtifactSelectorSpec(
1188-
producer_subtask=sub_task_name,
1189-
output_artifact_key=sub_task_output,
1190-
))
1191-
sub_task_name = task_name
1192-
sub_task_output = unique_output_name
1193-
1194-
11951134
def modify_pipeline_spec_with_override(
11961135
pipeline_spec: pipeline_spec_pb2.PipelineSpec,
11971136
pipeline_name: Optional[str],
@@ -1494,14 +1433,6 @@ def build_spec_by_group(
14941433
pipeline_spec.deployment_spec.update(
14951434
json_format.MessageToDict(deployment_config))
14961435

1497-
# Surface metrics outputs to the top.
1498-
populate_metrics_in_dag_outputs(
1499-
tasks=group.tasks,
1500-
task_name_to_parent_groups=task_name_to_parent_groups,
1501-
task_name_to_component_spec=task_name_to_component_spec,
1502-
pipeline_spec=pipeline_spec,
1503-
)
1504-
15051436

15061437
def modify_task_for_ignore_upstream_failure(
15071438
task: pipeline_task.PipelineTask,

sdk/python/test_data/components/output_metrics.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Description: Dummy component that outputs metrics with a random accuracy.
44
# Outputs:
55
# metrics: system.Metrics
6-
# output-metrics-metrics: system.Metrics
76
components:
87
comp-output-metrics:
98
executorLabel: exec-output-metrics
@@ -27,7 +26,7 @@ deploymentSpec:
2726
- -c
2827
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
2928
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
30-
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.7.0'\
29+
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
3130
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
3231
$0\" \"$@\"\n"
3332
- sh
@@ -56,10 +55,6 @@ root:
5655
artifactSelectors:
5756
- outputArtifactKey: metrics
5857
producerSubtask: output-metrics
59-
output-metrics-metrics:
60-
artifactSelectors:
61-
- outputArtifactKey: metrics
62-
producerSubtask: output-metrics
6358
tasks:
6459
output-metrics:
6560
cachingOptions:
@@ -74,9 +69,5 @@ root:
7469
artifactType:
7570
schemaTitle: system.Metrics
7671
schemaVersion: 0.0.1
77-
output-metrics-metrics:
78-
artifactType:
79-
schemaTitle: system.Metrics
80-
schemaVersion: 0.0.1
8172
schemaVersion: 2.1.0
82-
sdkVersion: kfp-2.7.0
73+
sdkVersion: kfp-2.9.0

sdk/python/test_data/pipelines/lightweight_python_functions_with_outputs.yaml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# first_number: int
66
# second_message: str
77
# second_number: int
8-
# Outputs:
9-
# output-named-tuple-metrics: system.Metrics
108
components:
119
comp-add-numbers:
1210
executorLabel: exec-add-numbers
@@ -81,7 +79,7 @@ deploymentSpec:
8179
- -c
8280
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
8381
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
84-
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.7.0'\
82+
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
8583
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
8684
$0\" \"$@\"\n"
8785
- sh
@@ -110,7 +108,7 @@ deploymentSpec:
110108
- -c
111109
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
112110
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
113-
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.7.0'\
111+
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
114112
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
115113
$0\" \"$@\"\n"
116114
- sh
@@ -139,7 +137,7 @@ deploymentSpec:
139137
- -c
140138
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
141139
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
142-
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.7.0'\
140+
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
143141
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
144142
$0\" \"$@\"\n"
145143
- sh
@@ -168,7 +166,7 @@ deploymentSpec:
168166
- -c
169167
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
170168
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
171-
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.7.0'\
169+
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
172170
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
173171
$0\" \"$@\"\n"
174172
- sh
@@ -196,12 +194,6 @@ pipelineInfo:
196194
name: functions-with-outputs
197195
root:
198196
dag:
199-
outputs:
200-
artifacts:
201-
output-named-tuple-metrics:
202-
artifactSelectors:
203-
- outputArtifactKey: metrics
204-
producerSubtask: output-named-tuple
205197
tasks:
206198
add-numbers:
207199
cachingOptions:
@@ -274,11 +266,5 @@ root:
274266
parameterType: STRING
275267
second_number:
276268
parameterType: NUMBER_INTEGER
277-
outputDefinitions:
278-
artifacts:
279-
output-named-tuple-metrics:
280-
artifactType:
281-
schemaTitle: system.Metrics
282-
schemaVersion: 0.0.1
283269
schemaVersion: 2.1.0
284-
sdkVersion: kfp-2.7.0
270+
sdkVersion: kfp-2.9.0

sdk/python/test_data/pipelines/pipeline_with_metrics_outputs.yaml

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
# PIPELINE DEFINITION
22
# Name: pipeline-with-metrics-outputs
3-
# Outputs:
4-
# output-metrics-2-metrics: system.Metrics
5-
# output-metrics-metrics: system.Metrics
63
components:
74
comp-for-loop-2:
85
dag:
9-
outputs:
10-
artifacts:
11-
output-metrics-2-metrics:
12-
artifactSelectors:
13-
- outputArtifactKey: metrics
14-
producerSubtask: output-metrics-2
156
tasks:
167
output-metrics-2:
178
cachingOptions:
@@ -24,12 +15,6 @@ components:
2415
parameters:
2516
pipelinechannel--loop-item-param-1:
2617
parameterType: NUMBER_INTEGER
27-
outputDefinitions:
28-
artifacts:
29-
output-metrics-2-metrics:
30-
artifactType:
31-
schemaTitle: system.Metrics
32-
schemaVersion: 0.0.1
3318
comp-output-metrics:
3419
executorLabel: exec-output-metrics
3520
outputDefinitions:
@@ -60,7 +45,7 @@ deploymentSpec:
6045
- -c
6146
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
6247
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
63-
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.7.0'\
48+
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
6449
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
6550
$0\" \"$@\"\n"
6651
- sh
@@ -91,7 +76,7 @@ deploymentSpec:
9176
- -c
9277
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
9378
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
94-
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.7.0'\
79+
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
9580
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
9681
$0\" \"$@\"\n"
9782
- sh
@@ -114,16 +99,6 @@ pipelineInfo:
11499
name: pipeline-with-metrics-outputs
115100
root:
116101
dag:
117-
outputs:
118-
artifacts:
119-
output-metrics-2-metrics:
120-
artifactSelectors:
121-
- outputArtifactKey: output-metrics-2-metrics
122-
producerSubtask: for-loop-2
123-
output-metrics-metrics:
124-
artifactSelectors:
125-
- outputArtifactKey: metrics
126-
producerSubtask: output-metrics
127102
tasks:
128103
for-loop-2:
129104
componentRef:
@@ -141,15 +116,5 @@ root:
141116
name: comp-output-metrics
142117
taskInfo:
143118
name: output-metrics
144-
outputDefinitions:
145-
artifacts:
146-
output-metrics-2-metrics:
147-
artifactType:
148-
schemaTitle: system.Metrics
149-
schemaVersion: 0.0.1
150-
output-metrics-metrics:
151-
artifactType:
152-
schemaTitle: system.Metrics
153-
schemaVersion: 0.0.1
154119
schemaVersion: 2.1.0
155-
sdkVersion: kfp-2.7.0
120+
sdkVersion: kfp-2.9.0

0 commit comments

Comments
 (0)