Skip to content

Commit

Permalink
Add s3 artifact service type as option in mlflow service
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlycoconuts committed Sep 9, 2024
1 parent 5c36417 commit d85b94b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 8 additions & 5 deletions api/pkg/client/mlflow/mlflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"fmt"
"net/http"

"cloud.google.com/go/storage"

"github.com/caraml-dev/mlp/api/pkg/artifact"
)

Expand All @@ -25,14 +23,20 @@ type mlflowService struct {

func NewMlflowService(httpClient *http.Client, config Config) (Service, error) {
var artifactService artifact.Service
var err error
// TODO: To consider removing since it doesn't make sense to have nop artifact service
if config.ArtifactServiceType == "nop" {
artifactService = artifact.NewNopArtifactClient()
} else if config.ArtifactServiceType == "gcs" {
api, err := storage.NewClient(context.Background())
artifactService, err = artifact.NewGcsArtifactClient()
if err != nil {
return &mlflowService{}, fmt.Errorf("failed initializing gcs for mlflow delete package")
}
artifactService = artifact.NewGcsArtifactClient(api)
} else if config.ArtifactServiceType == "s3" {
artifactService, err = artifact.NewS3ArtifactClient()
if err != nil {
return &mlflowService{}, fmt.Errorf("failed initializing s3 for mlflow delete package")
}
} else {
return &mlflowService{}, fmt.Errorf("invalid artifact service type")
}
Expand Down Expand Up @@ -115,7 +119,6 @@ func (mfs *mlflowService) searchRunData(RunID string) (SearchRunResponse, error)
}

func (mfs *mlflowService) DeleteExperiment(ctx context.Context, ExperimentID string, deleteArtifact bool) error {

relatedRunData, err := mfs.searchRunsForExperiment(ExperimentID)
if err != nil {
return err
Expand Down
10 changes: 10 additions & 0 deletions api/pkg/client/mlflow/mlflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ func TestNewMlflowService(t *testing.T) {
},
},
},
{
name: "Mlflow Service with s3 Artifact",
artifactType: "s3",
expectedError: nil,
expectedResult: &mlflowService{
API: &httpClient,
Config: Config{TrackingURL: "", ArtifactServiceType: "s3"},
ArtifactService: &artifact.S3ArtifactClient{},
},
},
{
name: "Mlflow Service with nop Artifact",
artifactType: "nop",
Expand Down

0 comments on commit d85b94b

Please sign in to comment.