Skip to content

Commit 0e0b1d2

Browse files
committed
Correct Runtime Artifact custom path logic/testing.
Signed-off-by: agoins <[email protected]>
1 parent 7982e30 commit 0e0b1d2

File tree

6 files changed

+554
-22
lines changed

6 files changed

+554
-22
lines changed

backend/src/v2/component/launcher_v2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,10 @@ func mergeRuntimeArtifacts(src, dst *pipelinespec.RuntimeArtifact) {
945945
}
946946
}
947947
}
948+
949+
if src.CustomPath != nil && *src.CustomPath != "" {
950+
dst.CustomPath = src.CustomPath
951+
}
948952
}
949953

950954
func getExecutorOutputFile(path string) (*pipelinespec.ExecutorOutput, error) {

backend/src/v2/metadata/converter.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func toMLMDArtifact(runtimeArtifact *pipelinespec.RuntimeArtifact) (*pb.Artifact
116116
Properties: make(map[string]*pb.Value),
117117
CustomProperties: make(map[string]*pb.Value),
118118
}
119+
// If runtime artifact is set with a custom path, add this path to the custom properties map.
120+
if runtimeArtifact.CustomPath != nil {
121+
artifact.CustomProperties["custom_path"] = stringMLMDValue(*runtimeArtifact.CustomPath)
122+
}
119123

120124
if runtimeArtifact.Metadata != nil {
121125
for k, v := range runtimeArtifact.Metadata.Fields {
@@ -177,13 +181,20 @@ func toRuntimeArtifact(artifact *pb.Artifact) (*pipelinespec.RuntimeArtifact, er
177181
errorF := func(err error) (*pipelinespec.RuntimeArtifact, error) {
178182
return nil, fmt.Errorf("failed to convert MLMD artifact to RuntimeArtifact: %w", err)
179183
}
184+
// Retrieve custom_path value from artifact.CustomProperties, if present.
185+
var customPathStr string
186+
if artifact.CustomProperties != nil {
187+
customPath := artifact.CustomProperties["custom_path"]
188+
customPathStr = customPath.GetStringValue()
189+
}
180190

181191
rta := &pipelinespec.RuntimeArtifact{
182192
Name: strconv.FormatInt(artifact.GetId(), 10),
183193
Uri: artifact.GetUri(),
184194
Metadata: &structpb.Struct{
185195
Fields: make(map[string]*structpb.Value),
186196
},
197+
CustomPath: &customPathStr,
187198
}
188199

189200
propertiesToMetadata := func(properties map[string]*pb.Value) error {

sdk/python/kfp/dsl/types/artifact_types.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def path(self) -> str:
9191

9292
@path.setter
9393
def path(self, path: str) -> None:
94-
self._set_custom_path(path)
94+
self._set_path(path)
9595

9696
def _get_path(self) -> Optional[str]:
9797
if self.custom_path:
@@ -112,23 +112,28 @@ def _get_path(self) -> Optional[str]:
112112
# uri == path for local execution
113113
return self.uri
114114

115+
def _set_path(self, path: str) -> None:
116+
self.uri = convert_local_path_to_remote_path(path)
117+
115118
@property
116119
def custom_path(self) -> str:
120+
return self._get_custom_path()
121+
122+
@custom_path.getter
123+
def custom_path(self):
117124
return self._custom_path
118125

119126
def _get_custom_path(self) -> str:
120127
return self._custom_path
121128

122-
def _set_path(self, path: str) -> None:
123-
self.uri = convert_local_path_to_remote_path(path)
124-
125-
def _set_custom_path(self, value: str) -> None:
126-
self._custom_path = value
127-
128129
@custom_path.setter
129130
def custom_path(self, value: str):
130131
self._custom_path = value
131132

133+
def set_path(self, path: str) -> None:
134+
# If user specified a custom path, use it instead of the default path.
135+
self._custom_path = path
136+
132137

133138
def convert_local_path_to_remote_path(path: str) -> str:
134139
if path.startswith(_GCS_LOCAL_MOUNT_PREFIX):

0 commit comments

Comments
 (0)