Skip to content

Commit

Permalink
Refactor model image naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlycoconuts committed Jan 30, 2024
1 parent e97330c commit b92a3ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions api/pkg/imagebuilder/imagebuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
},
}
Expand Down
2 changes: 1 addition & 1 deletion api/pkg/imagebuilder/model_service_imagebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion api/pkg/imagebuilder/prediction_job_imagebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit b92a3ce

Please sign in to comment.