merlin

package
v0.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Method   string
	Endpoint string
	Status   int
	Msg      string
}

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, params ClientParams) (Client, error)

func (Client) ModelVersion

func (c Client) ModelVersion(ctx context.Context, modelID, versionID int64) (ModelVersion, error)

func (Client) Models

func (c Client) Models(ctx context.Context, projectID int64) ([]Model, error)

func (Client) Projects

func (c Client) Projects(ctx context.Context) ([]Project, error)

type ClientParams

type ClientParams struct {
	BaseURL            string
	ServiceAccountJSON []byte
	Timeout            time.Duration
}

type EnvVar

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Label

type Label struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Model

type Model struct {
	ID                 int64           `json:"id"`
	ProjectID          int64           `json:"project_id"`
	MlflowExperimentID int64           `json:"mlflow_experiment_id"`
	Name               string          `json:"name"`
	Type               string          `json:"type"`
	MlflowURL          string          `json:"mlflow_url"`
	Endpoints          []ModelEndpoint `json:"endpoints"`
	CreatedAt          time.Time       `json:"created_at"`
	UpdatedAt          time.Time       `json:"updated_at"`
}

type ModelEndpoint

type ModelEndpoint struct {
	ID              int64             `json:"id"`
	Status          string            `json:"status"` // pending/running/serving/failed/terminated
	URL             string            `json:"url"`
	Rule            ModelEndpointRule `json:"rule"`
	EnvironmentName string            `json:"environment_name"`
	CreatedAt       time.Time         `json:"created_at"`
	UpdatedAt       time.Time         `json:"updated_at"`
}

type ModelEndpointRule

type ModelEndpointRule struct {
	Destinations []ModelEndpointRuleDestination `json:"destinations"`
}

type ModelEndpointRuleDestination

type ModelEndpointRuleDestination struct {
	VersionEndpointID string           `json:"version_endpoint_id"`
	VersionEndpoint   *VersionEndpoint `json:"version_endpoint"`
	Weight            int64            `json:"weight"`
}

type ModelVersion

type ModelVersion struct {
	ID          int64             `json:"id"`
	ModelD      int64             `json:"model_id"`
	MlflowRunID string            `json:"mlflow_run_id"`
	MlflowURL   string            `json:"mlflow_url"`
	Endpoints   []VersionEndpoint `json:"endpoints"`
	Labels      map[string]string `json:"labels"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
}

type Project

type Project struct {
	ID                int64    `json:"id"`
	Name              string   `json:"name"`
	MlflowTrackingURL string   `json:"mlflow_tracking_url"`
	Administrators    []string `json:"administrators"` // List of emails
	Readers           []string `json:"readers"`
	Team              string   `json:"team"`
	Stream            string   `json:"stream"`
	Labels            []Label  `json:"labels"`
	CreatedAt         string   `json:"created_at"`
	UpdatedAt         string   `json:"updated_at"`
}

type Transformer

type Transformer struct {
	Enabled         bool      `json:"enabled"`
	TransformerType string    `json:"transformer_type"`
	Image           string    `json:"image"`
	Command         string    `json:"command"`
	Args            string    `json:"args"`
	EnvVars         []EnvVar  `json:"env_vars"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type URLBuilder

type URLBuilder struct {
	// contains filtered or unexported fields
}

URLBuilder is used to build a URL.

URLBuilderSource should be used to create an instance of URLBuilder.

b, err := httputil.NewURLBuilderSource("https://api.example.com/")
if err != nil {
	// handle error
}

u := b.New().
	Path("/users/{id}/posts").
	PathParam("id", id).
	QueryParam("limit", limit).
	QueryParam("offset", offset).
	URL()

// { id: 123, limit: 10, offset: 120 }
// https://api.example.com/users/123/posts?limit=10&offset=120

r, err := http.NewRequestWithContext(context.Background(), http.MethodGet, u.String(), nil)
if err != nil {
	// handle error
}

// send HTTP request.

func (*URLBuilder) Path

func (u *URLBuilder) Path(p string) *URLBuilder

Path sets the path template for the URL.

Path parameters of the format "{paramName}" are supported and can be substituted using PathParam*.

func (*URLBuilder) PathParam

func (u *URLBuilder) PathParam(name, value string) *URLBuilder

PathParam sets the path parameter name and value which needs to be substituted in the path template. Substitution happens when the URL is built using URLBuilder.URL()

func (*URLBuilder) PathParamInt

func (u *URLBuilder) PathParamInt(name string, value int64) *URLBuilder

PathParamInt sets the path parameter name and value which needs to be substituted in the path template. Substitution happens when the URL is built using URLBuilder.URL()

func (*URLBuilder) PathParams

func (u *URLBuilder) PathParams(params map[string]string) *URLBuilder

PathParams sets the path parameter names and values which need to be substituted in the path template. Substitution happens when the URL is built using URLBuilder.URL()

func (*URLBuilder) QueryParam

func (u *URLBuilder) QueryParam(key string, values ...string) *URLBuilder

QueryParam sets the query parameter with the given values. If a value was previously set, it is replaced.

func (*URLBuilder) QueryParamBool

func (u *URLBuilder) QueryParamBool(key string, value bool) *URLBuilder

QueryParamBool sets the query parameter with the given value. If a value was previously set, it is replaced.

func (*URLBuilder) QueryParamFloat

func (u *URLBuilder) QueryParamFloat(key string, values ...float64) *URLBuilder

QueryParamFloat sets the query parameter with the given values. If a value was previously set, it is replaced.

func (*URLBuilder) QueryParamInt

func (u *URLBuilder) QueryParamInt(key string, values ...int64) *URLBuilder

QueryParamInt sets the query parameter with the given values. If a value was previously set, it is replaced.

func (*URLBuilder) QueryParams

func (u *URLBuilder) QueryParams(params url.Values) *URLBuilder

QueryParams sets the query parameters. If a value was previously set for any of the given parameters, it is replaced.

func (*URLBuilder) URL

func (u *URLBuilder) URL() *url.URL

URL constructs and returns an instance of URL.

The constructed URL has the complete path and query parameters setup. The path parameters are substituted before being joined with the base URL.

type URLBuilderSource

type URLBuilderSource struct {
	// contains filtered or unexported fields
}

URLBuilderSource is used to create URLBuilder instances.

The URLBuilder created using URLBuilderSource will include the base URL and query parameters present on the URLBuilderSource instance.

Ideally, URLBuilderSource instance should be created only once for a given base URL.

func NewURLBuilderSource

func NewURLBuilderSource(baseURL string) (URLBuilderSource, error)

NewURLBuilderSource builds a URLBuilderSource instance by parsing the baseURL.

The baseURL is expected to specify the host. If no scheme is specified, it defaults to http scheme.

func (URLBuilderSource) New

func (b URLBuilderSource) New() *URLBuilder

New creates a new instance of URLBuilder with the base URL and query parameters carried over from URLBuilderSource.

type VersionEndpoint

type VersionEndpoint struct {
	ID              string      `json:"id"`
	VersionID       int64       `json:"version_id"`
	Status          string      `json:"status"` // pending/running/serving/failed/terminated
	URL             string      `json:"url"`
	ServiceName     string      `json:"service_name"`
	EnvironmentName string      `json:"environment_name"`
	MonitoringURL   string      `json:"monitoring_url"`
	Message         string      `json:"message"`
	EnvVars         []EnvVar    `json:"env_vars"`
	Transformer     Transformer `json:"transformer"`
	DeploymentMode  string      `json:"deployment_mode"` // serverless/raw_deployment
	CreatedAt       time.Time   `json:"created_at"`
	UpdatedAt       time.Time   `json:"updated_at"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL