Skip to content

Commit 0afb12d

Browse files
authored
Allow system.Model artifacts in the Modelcar format (kubeflow#11674)
This skips uploading the model to S3 when the model URI starts with oci://. Signed-off-by: mprahl <[email protected]>
1 parent 9afe23e commit 0afb12d

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

.github/workflows/kfp-samples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Build and upload the sample Modelcar image to Kind
4040
run: |
41-
docker build -f samples/v2/modelcar_import/Dockerfile -t registry.domain.local/modelcar:test .
41+
docker build -f samples/v2/modelcar/Dockerfile -t registry.domain.local/modelcar:test .
4242
kind --name kfp load docker-image registry.domain.local/modelcar:test
4343
4444
- name: Forward API port

backend/src/v2/component/launcher_v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func uploadOutputArtifacts(ctx context.Context, executorInput *pipelinespec.Exec
484484
localDir, err := LocalPathForURI(outputArtifact.Uri)
485485
if err != nil {
486486
glog.Warningf("Output Artifact %q does not have a recognized storage URI %q. Skipping uploading to remote storage.", name, outputArtifact.Uri)
487-
} else {
487+
} else if !strings.HasPrefix(outputArtifact.Uri, "oci://") {
488488
blobKey, err := opts.bucketConfig.KeyFromURI(outputArtifact.Uri)
489489
if err != nil {
490490
return nil, fmt.Errorf("failed to upload output artifact %q: %w", name, err)

samples/v2/modelcar_import/modelcar_import.py renamed to samples/v2/modelcar/modelcar.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
# normally need to specify `kfp_package_path` in their component definitions.
2525
_KFP_PACKAGE_PATH = os.getenv("KFP_PACKAGE_PATH")
2626

27+
@dsl.component(kfp_package_path=_KFP_PACKAGE_PATH)
28+
def build_model_car(model: dsl.Output[dsl.Model]):
29+
# Simulate pushing the Modelcar to an OCI registry
30+
model.uri = "oci://registry.domain.local/org/repo:v1.0"
2731

2832
@dsl.component(kfp_package_path=_KFP_PACKAGE_PATH)
2933
def get_model_files_list(input_model: dsl.Input[dsl.Model]) -> str:
@@ -59,7 +63,7 @@ def get_model_files_list(input_model: dsl.Input[dsl.Model]) -> str:
5963

6064

6165
@dsl.pipeline(name="pipeline-with-modelcar-model")
62-
def pipeline_modelcar_import(
66+
def pipeline_modelcar_test(
6367
model_uri: str = "oci://registry.domain.local/modelcar:test",
6468
):
6569
model_source_oci_task = dsl.importer(
@@ -68,8 +72,10 @@ def pipeline_modelcar_import(
6872

6973
get_model_files_list(input_model=model_source_oci_task.output).set_caching_options(False)
7074

75+
build_model_car().set_caching_options(False)
76+
7177

7278
if __name__ == "__main__":
7379
compiler.Compiler().compile(
74-
pipeline_func=pipeline_modelcar_import, package_path=__file__ + ".yaml"
80+
pipeline_func=pipeline_modelcar_test, package_path=__file__ + ".yaml"
7581
)

samples/v2/sample_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import parallel_after_dependency
3333
import two_step_pipeline_containerized
3434
import pipeline_with_placeholders
35-
from modelcar_import import modelcar_import
35+
from modelcar import modelcar
3636

3737
_MINUTE = 60 # seconds
3838
_DEFAULT_TIMEOUT = 5 * _MINUTE
@@ -79,7 +79,7 @@ def test(self):
7979
TestCase(
8080
pipeline_func=subdagio.multiple_artifacts_namedtuple.crust),
8181
TestCase(pipeline_func=pipeline_with_placeholders.pipeline_with_placeholders),
82-
TestCase(pipeline_func=modelcar_import.pipeline_modelcar_import),
82+
TestCase(pipeline_func=modelcar.pipeline_modelcar_test),
8383
TestCase(pipeline_func=parallel_consume_upstream.loop_consume_upstream),
8484
TestCase(pipeline_func=parallel_after_dependency.loop_with_after_dependency_set),
8585
]

0 commit comments

Comments
 (0)