-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(csi): support multiple model registries (#508)
* feat(csi): support multiple model registries Signed-off-by: Alessio Pragliola <[email protected]> * chore(csi): add info about the uri in readme Signed-off-by: Alessio Pragliola <[email protected]> * fix(csi): remove unnecessary comment Signed-off-by: Alessio Pragliola <[email protected]> * chore(csi): cleanup after each test + improve log message after uri parsing Signed-off-by: Alessio Pragliola <[email protected]> * chore(csi): remove unnecessary kind external config in CI Signed-off-by: Alessio Pragliola <[email protected]> --------- Signed-off-by: Alessio Pragliola <[email protected]>
- Loading branch information
1 parent
505b00e
commit 2422e85
Showing
8 changed files
with
433 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package constants | ||
|
||
import kserve "github.com/kserve/kserve/pkg/agent/storage" | ||
|
||
const MR kserve.Protocol = "model-registry://" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package modelregistry | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"strings" | ||
|
||
"github.com/kubeflow/model-registry/csi/pkg/constants" | ||
"github.com/kubeflow/model-registry/pkg/openapi" | ||
) | ||
|
||
func NewAPIClient(cfg *openapi.Configuration, storageUri string) *openapi.APIClient { | ||
client := openapi.NewAPIClient(cfg) | ||
|
||
// Parse the URI to retrieve the needed information to query model registry (modelArtifact) | ||
mrUri := strings.TrimPrefix(storageUri, string(constants.MR)) | ||
|
||
tokens := strings.SplitN(mrUri, "/", 3) | ||
|
||
if len(tokens) < 2 { | ||
return client | ||
} | ||
|
||
newCfg := openapi.NewConfiguration() | ||
newCfg.Host = tokens[0] | ||
newCfg.Scheme = cfg.Scheme | ||
|
||
newClient := openapi.NewAPIClient(newCfg) | ||
|
||
if len(tokens) == 2 { | ||
// Check if the model registry service is available | ||
_, _, err := newClient.ModelRegistryServiceAPI.GetRegisteredModels(context.Background()).Execute() | ||
if err != nil { | ||
log.Printf("Falling back to base url %s for model registry service", cfg.Host) | ||
|
||
return client | ||
} | ||
} | ||
|
||
return newClient | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.