Skip to content

Commit

Permalink
Support absolute path as lora adapter artifact path (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffwan authored Jan 8, 2025
1 parent 5228a8a commit 9d0a888
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions pkg/controller/modeladapter/modeladapter_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"time"

modelv1alpha1 "github.com/aibrix/aibrix/api/model/v1alpha1"
Expand Down Expand Up @@ -588,12 +589,16 @@ func (r *ModelAdapterReconciler) modelAdapterExists(host, modelName string) (boo

// Separate method to load the LoRA adapter
func (r *ModelAdapterReconciler) loadModelAdapter(host string, instance *modelv1alpha1.ModelAdapter) error {
artifactURL, err := extractHuggingFacePath(instance.Spec.ArtifactURL)
if err != nil {
// Handle error, e.g., log it and return
klog.ErrorS(err, "Invalid artifact URL", "artifactURL", artifactURL)
return err
artifactURL := instance.Spec.ArtifactURL
if strings.HasPrefix(instance.Spec.ArtifactURL, "huggingface://") {
artifactURL, err := extractHuggingFacePath(instance.Spec.ArtifactURL)
if err != nil {
// Handle error, e.g., log it and return
klog.ErrorS(err, "Invalid artifact URL", "artifactURL", artifactURL)
return err
}
}
// TODO: extend to other artifacts

payload := map[string]string{
"lora_name": instance.Name,
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/modeladapter/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func validateModelAdapter(instance *modelv1alpha1.ModelAdapter) error {
return nil
}

// validateArtifactURL checks if the ArtifactURL has a valid schema (s3://, gcs://, huggingface://, https://)
// validateArtifactURL checks if the ArtifactURL has a valid schema (s3://, gcs://, huggingface://, https://, /)
func validateArtifactURL(artifactURL string) error {
allowedSchemes := []string{"s3://", "gcs://", "huggingface://", "hf://"}
allowedSchemes := []string{"s3://", "gcs://", "huggingface://", "hf://", "/"}
for _, scheme := range allowedSchemes {
if strings.HasPrefix(artifactURL, scheme) {
return nil
Expand Down

0 comments on commit 9d0a888

Please sign in to comment.