From ae59fe0ccd4f7e9e9d3d589fa9dc871d6d902e4a Mon Sep 17 00:00:00 2001 From: ewezy Date: Sat, 27 Jan 2024 01:25:45 +0800 Subject: [PATCH] Refactor model image naming convention --- api/pkg/imagebuilder/imagebuilder_test.go | 38 +++++++++---------- .../model_service_imagebuilder.go | 2 +- .../prediction_job_imagebuilder.go | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/api/pkg/imagebuilder/imagebuilder_test.go b/api/pkg/imagebuilder/imagebuilder_test.go index 975750af6..0a0a9b183 100644 --- a/api/pkg/imagebuilder/imagebuilder_test.go +++ b/api/pkg/imagebuilder/imagebuilder_test.go @@ -303,7 +303,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -354,7 +354,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantDeleteJobName: "", - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: config, }, { @@ -416,7 +416,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -445,7 +445,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantDeleteJobName: "", - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: configWithSa, }, { @@ -507,7 +507,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -550,7 +550,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantDeleteJobName: "", - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: Config{ BuildNamespace: testBuildNamespace, BaseImage: cfg.BaseImageConfig{ @@ -633,7 +633,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -681,7 +681,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantDeleteJobName: "", - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: Config{ BuildNamespace: testBuildNamespace, BaseImage: cfg.BaseImageConfig{ @@ -769,7 +769,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), "--cache=true", "--compressed-caching=false", "--snapshot-mode=redo", @@ -819,7 +819,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantDeleteJobName: "", - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: Config{ BuildNamespace: config.BuildNamespace, BaseImage: cfg.BaseImageConfig{ @@ -899,7 +899,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -950,7 +950,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantCreateJob: nil, - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: config, }, { @@ -1011,7 +1011,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -1065,7 +1065,7 @@ func TestBuildImage(t *testing.T) { }, wantCreateJob: nil, wantDeleteJobName: "", - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: config, }, { @@ -1126,7 +1126,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -1229,7 +1229,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -1280,7 +1280,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantDeleteJobName: fmt.Sprintf("%s-%s-%s", project.Name, model.Name, modelVersion.ID), - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: config, }, { @@ -1346,7 +1346,7 @@ func TestBuildImage(t *testing.T) { fmt.Sprintf("--build-arg=BASE_IMAGE=%s", config.BaseImage.ImageName), fmt.Sprintf("--build-arg=MODEL_DEPENDENCIES_URL=%s", modelDependenciesURL), fmt.Sprintf("--build-arg=MODEL_ARTIFACTS_URL=%s/model", testArtifactURI), - fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), + fmt.Sprintf("--destination=%s", fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID)), fmt.Sprintf("--context-sub-path=%s", config.BaseImage.BuildContextSubPath), "--cache=true", "--compressed-caching=false", @@ -1397,7 +1397,7 @@ func TestBuildImage(t *testing.T) { Status: batchv1.JobStatus{}, }, wantDeleteJobName: "", - wantImageRef: fmt.Sprintf("%s/%s-%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), + wantImageRef: fmt.Sprintf("%s/%s/pyfunc-models/%s:%s", config.DockerRegistry, project.Name, model.Name, modelVersion.ID), config: config, }, } diff --git a/api/pkg/imagebuilder/model_service_imagebuilder.go b/api/pkg/imagebuilder/model_service_imagebuilder.go index 5f2fa68e8..cc37c19bb 100644 --- a/api/pkg/imagebuilder/model_service_imagebuilder.go +++ b/api/pkg/imagebuilder/model_service_imagebuilder.go @@ -41,5 +41,5 @@ func (n *modelServiceNameGenerator) generateBuilderJobName(project mlp.Project, // generateDockerImageName generate docker image name of model service func (n *modelServiceNameGenerator) generateDockerImageName(project mlp.Project, model *models.Model) string { - return fmt.Sprintf("%s/%s-%s", n.dockerRegistry, project.Name, model.Name) + return fmt.Sprintf("%s/%s/pyfunc-models/%s", n.dockerRegistry, project.Name, model.Name) } diff --git a/api/pkg/imagebuilder/prediction_job_imagebuilder.go b/api/pkg/imagebuilder/prediction_job_imagebuilder.go index 8c08e6808..6296ad00f 100644 --- a/api/pkg/imagebuilder/prediction_job_imagebuilder.go +++ b/api/pkg/imagebuilder/prediction_job_imagebuilder.go @@ -41,5 +41,5 @@ func (n *predictionJobNameGenerator) generateBuilderJobName(project mlp.Project, // generateDockerImageName generate the name of docker image of prediction job that will be created from given model func (n *predictionJobNameGenerator) generateDockerImageName(project mlp.Project, model *models.Model) string { - return fmt.Sprintf("%s/%s-%s-job", n.dockerRegistry, project.Name, model.Name) + return fmt.Sprintf("%s/%s/batch-jobs/%s", n.dockerRegistry, project.Name, model.Name) }