Compare commits
No commits in common. "main" and "v1.0.4" have entirely different histories.
22
api.go
22
api.go
|
@ -26,18 +26,6 @@ func (e MlflowApiError) Error() string {
|
||||||
return fmt.Sprint("Request Error " + string(e.ErrorCode) + ": " + e.ErrorDesc)
|
return fmt.Sprint("Request Error " + string(e.ErrorCode) + ": " + e.ErrorDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
type MlflowApiErrorNotFound MlflowApiError
|
|
||||||
|
|
||||||
func (e MlflowApiErrorNotFound) Error() string {
|
|
||||||
return fmt.Sprint("Request Error 404 " + string(e.ErrorCode) + ": " + e.ErrorDesc)
|
|
||||||
}
|
|
||||||
|
|
||||||
type MlflowApiError400 MlflowApiError
|
|
||||||
|
|
||||||
func (e MlflowApiError400) Error() string {
|
|
||||||
return fmt.Sprint("Request Error 400 " + string(e.ErrorCode) + ": " + e.ErrorDesc)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Timestamp int64
|
type Timestamp int64
|
||||||
|
|
||||||
func (t *Timestamp) Time() time.Time {
|
func (t *Timestamp) Time() time.Time {
|
||||||
|
@ -79,15 +67,7 @@ func apiReadReply(resp *http.Response, err error, ref any) error {
|
||||||
fmt.Println("Error when parsing reply: ", err2.Error(), "\n", string(body))
|
fmt.Println("Error when parsing reply: ", err2.Error(), "\n", string(body))
|
||||||
return err2
|
return err2
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
switch resp.StatusCode {
|
|
||||||
case 400:
|
|
||||||
return MlflowApiError400(err)
|
|
||||||
case 404:
|
|
||||||
return MlflowApiErrorNotFound(err)
|
|
||||||
default:
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(body, &ref)
|
err = json.Unmarshal(body, &ref)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package mlflow
|
package mlflow
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ApiURI string `json:"apiUrl,omitempty" yaml:"apiUri,omitempty"`
|
ApiURI string
|
||||||
IgnoreSSL bool `json:"ignoreSSL,omitempty" yaml:"ignoreSSL,omitempty"`
|
IgnoreSSL bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
package mlflow
|
package mlflow
|
||||||
|
|
||||||
import (
|
import "encoding/json"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"sort"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ModelVersionStatus string
|
type ModelVersionStatus string
|
||||||
|
|
||||||
|
@ -51,8 +46,8 @@ type CreateRegisteredModelResponse struct {
|
||||||
type ModelVersion struct {
|
type ModelVersion struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Version string `json:"version,omitempty"`
|
Version string `json:"version,omitempty"`
|
||||||
CreationTimestamp TimestampMs `json:"creation_timestamp,omitempty"`
|
CreationTimestamp Timestamp `json:"creation_timestamp,omitempty"`
|
||||||
LastUpdateTimestamp TimestampMs `json:"last_update_timestamp,omitempty"`
|
LastUpdateTimestamp Timestamp `json:"last_update_timestamp,omitempty"`
|
||||||
UserId string `json:"user_id,omitempty"`
|
UserId string `json:"user_id,omitempty"`
|
||||||
CurrentStage string `json:"current_stage,omitempty"`
|
CurrentStage string `json:"current_stage,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
|
@ -65,78 +60,6 @@ type ModelVersion struct {
|
||||||
Aliases []string `json:"aliases,omitempty"`
|
Aliases []string `json:"aliases,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ref *ModelVersion) GetTag(key string) *ModelVersionTag {
|
|
||||||
for _, tag := range ref.Tags {
|
|
||||||
if tag.Key == key {
|
|
||||||
return &tag
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ref *ModelVersion) IsEqual(target *ModelVersion) bool {
|
|
||||||
vRef := reflect.ValueOf(*ref)
|
|
||||||
vTarget := reflect.ValueOf(*target)
|
|
||||||
|
|
||||||
typeOfV := vRef.Type()
|
|
||||||
values := make([]interface{}, vRef.NumField())
|
|
||||||
for i := 0; i < vRef.NumField(); i++ {
|
|
||||||
values[i] = vRef.Field(i).Interface()
|
|
||||||
refName := typeOfV.Field(i).Name
|
|
||||||
refType := typeOfV.Field(i).Type.String()
|
|
||||||
refVal := vRef.Field(i)
|
|
||||||
|
|
||||||
targetVal := reflect.Indirect(vTarget).FieldByName(refName)
|
|
||||||
|
|
||||||
switch refType {
|
|
||||||
case "string", "mlflow.ModelVersionStatus":
|
|
||||||
if refVal.String() != targetVal.String() {
|
|
||||||
fmt.Println("NE STRING: ", refType, refName, refVal, targetVal, (refVal.String() == targetVal.String()))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
case "mlflow.TimestampMs":
|
|
||||||
if refVal.Int() != targetVal.Int() {
|
|
||||||
fmt.Println("NE TimestampMs: ", refType, refName, refVal, targetVal, (refVal.Int() == targetVal.Int()))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
case "[]mlflow.ModelVersionTag":
|
|
||||||
sliceRef, _ := refVal.Interface().([]ModelVersionTag)
|
|
||||||
sliceTarget, _ := targetVal.Interface().([]ModelVersionTag)
|
|
||||||
|
|
||||||
if len(sliceRef) != len(sliceTarget) {
|
|
||||||
//fmt.Println("Not equal - len mismatch")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, val := range sliceRef {
|
|
||||||
if tag2 := target.GetTag(val.Key); tag2 == nil || tag2.Value != val.Value {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "[]string":
|
|
||||||
sliceRef, _ := refVal.Interface().([]string)
|
|
||||||
sliceTarget, _ := targetVal.Interface().([]string)
|
|
||||||
sort.Strings(sliceRef)
|
|
||||||
sort.Strings(sliceTarget)
|
|
||||||
if len(sliceRef) != len(sliceTarget) {
|
|
||||||
//fmt.Println("Not equal - len mismatch")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
for xI, xRef := range sliceRef {
|
|
||||||
if xRef != sliceTarget[xI] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
fmt.Println("Unknown: ", refType, refName, refVal, targetVal)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
type RegisteredModel struct {
|
type RegisteredModel struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
CreationTimestamp Timestamp `json:"creation_timestamp,omitempty"`
|
CreationTimestamp Timestamp `json:"creation_timestamp,omitempty"`
|
||||||
|
|
Loading…
Reference in New Issue