-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(backend/sdk):Add download_to_workspace option to dsl.importer #12353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -715,6 +715,12 @@ func downloadArtifacts(ctx context.Context, executorInput *pipelinespec.Executor | |
| for _, artifact := range artifactList.Artifacts { | ||
| // Iterating through the artifact list allows for collected artifacts to be properly consumed. | ||
| inputArtifact := artifact | ||
| // Skip downloading if the artifact is flagged as already present in the workspace | ||
| if inputArtifact.GetMetadata() != nil { | ||
| if v, ok := inputArtifact.GetMetadata().GetFields()["_kfp_workspace"]; ok && v.GetBoolValue() { | ||
| continue | ||
| } | ||
| } | ||
| localPath, err := LocalPathForURI(inputArtifact.Uri) | ||
| if err != nil { | ||
| glog.Warningf("Input Artifact %q does not have a recognized storage URI %q. Skipping downloading to local path.", name, inputArtifact.Uri) | ||
|
|
@@ -858,6 +864,20 @@ func getPlaceholders(executorInput *pipelinespec.ExecutorInput) (placeholders ma | |
| key := fmt.Sprintf(`{{$.inputs.artifacts['%s'].uri}}`, name) | ||
| placeholders[key] = inputArtifact.Uri | ||
|
|
||
| // If the artifact is marked as already in the workspace, map to the workspace path | ||
| // with the same shape as LocalPathForURI, but rebased under the workspace mount. | ||
| if inputArtifact.GetMetadata() != nil { | ||
| if v, ok := inputArtifact.GetMetadata().GetFields()["_kfp_workspace"]; ok && v.GetBoolValue() { | ||
| localPath, lerr := LocalWorkspacePathForURI(inputArtifact.Uri) | ||
| if lerr != nil { | ||
| return nil, fmt.Errorf("failed to get local workspace path for input artifact %q: %w", name, lerr) | ||
| } | ||
| key = fmt.Sprintf(`{{$.inputs.artifacts['%s'].path}}`, name) | ||
| placeholders[key] = localPath | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you update This is because the placeholder replacement logic is much less strict and we need |
||
| continue | ||
| } | ||
| } | ||
|
|
||
| localPath, err := LocalPathForURI(inputArtifact.Uri) | ||
| if err != nil { | ||
| // Input Artifact does not have a recognized storage URI | ||
|
|
@@ -1010,6 +1030,21 @@ func retrieveArtifactPath(artifact *pipelinespec.RuntimeArtifact) (string, error | |
| } | ||
| } | ||
|
|
||
| // LocalWorkspacePathForURI returns the local workspace path for a given artifact URI. | ||
| // It preserves the same path shape as LocalPathForURI, but rebases it under the | ||
| // workspace artifacts directory: /kfp-workspace/.artifacts/... | ||
| func LocalWorkspacePathForURI(uri string) (string, error) { | ||
| if strings.HasPrefix(uri, "oci://") { | ||
| return "", fmt.Errorf("failed to generate workspace path for URI %s: OCI not supported for workspace artifacts", uri) | ||
| } | ||
| localPath, err := LocalPathForURI(uri) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| // Rebase under the workspace mount, stripping the leading '/' | ||
| return filepath.Join(WorkspaceMountPath, ".artifacts", strings.TrimPrefix(localPath, "/")), nil | ||
| } | ||
|
|
||
| func prepareOutputFolders(executorInput *pipelinespec.ExecutorInput) error { | ||
| for name, parameter := range executorInput.GetOutputs().GetParameters() { | ||
| dir := filepath.Dir(parameter.OutputFile) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.