Documentation
¶
Overview ¶
Copyright 2021 IBM Corporation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 IBM Corporation ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 IBM Corporation ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func AddModelDiskSize(req *mmesh.LoadModelRequest, log logr.Logger) *mmesh.LoadModelRequest
- func ModelObjectsContainsSchema(s []string, str string) bool
- type Puller
- func (s *Puller) CleanCache()
- func (p *Puller) CleanupModel(modelID string) error
- func (s *Puller) DownloadFromCOS(modelID string, objPath string, schemaPath string, storageKey string, ...) (string, error)
- func (s *Puller) DownloadObjectsfromCOS(modelID string, storage *storage, objectsToDownload []string, ...) (string, error)
- func (p *Puller) ListModels() ([]string, error)
- func (s *Puller) ProcessLoadModelRequest(req *mmesh.LoadModelRequest) (*mmesh.LoadModelRequest, error)
- type PullerConfiguration
- type S3Downloader
- type StorageConfiguration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddModelDiskSize ¶
func AddModelDiskSize(req *mmesh.LoadModelRequest, log logr.Logger) *mmesh.LoadModelRequest
Types ¶
type Puller ¶
type Puller struct {
PullerConfig *PullerConfiguration
Log logr.Logger
NewS3DownloaderFromConfig func(*StorageConfiguration, int, logr.Logger) (S3Downloader, error)
// contains filtered or unexported fields
}
Puller represents the GRPC server and its configuration
func NewPuller ¶
NewPuller creates a new Puller instance and initializes it with configuration from the environment
func NewPullerFromConfig ¶
func NewPullerFromConfig(log logr.Logger, config *PullerConfiguration) *Puller
NewPullerFromConfig creates a new Puller instance with the given configuration
func (*Puller) CleanCache ¶
func (s *Puller) CleanCache()
func (*Puller) CleanupModel ¶
func (*Puller) DownloadFromCOS ¶
func (*Puller) DownloadObjectsfromCOS ¶
func (*Puller) ListModels ¶
func (*Puller) ProcessLoadModelRequest ¶
func (s *Puller) ProcessLoadModelRequest(req *mmesh.LoadModelRequest) (*mmesh.LoadModelRequest, error)
processLoadModelRequest is for use in an mmesh ModelRuntimeServer that embeds the puller
The input request is modified in place and also returned. The path is rewritten to a local file path and the size of the model on disk is added to the model metadata.
type PullerConfiguration ¶
type PullerConfiguration struct {
RootModelDir string // Root directory to store models
StorageConfigurationDir string
S3DownloadConcurrency int
CacheCleanPeriod time.Duration
}
PullerConfiguration stores configuration variables for the puller server
func GetPullerConfigFromEnv ¶
func GetPullerConfigFromEnv(log logr.Logger) (*PullerConfiguration, error)
GetPullerConfigFromEnv creates a new PullerConfiguration populated from environment variables
func (*PullerConfiguration) GetStorageConfiguration ¶
func (config *PullerConfiguration) GetStorageConfiguration(storageKey string, log logr.Logger) (*StorageConfiguration, error)
GetStorageConfiguration returns a StorageConfiguration read from the mounted secret at the give key
type S3Downloader ¶
type S3Downloader interface {
ListObjectsUnderPrefix(bucket string, prefix string) ([]string, error)
DownloadWithIterator(ctx aws.Context, iter s3manager.BatchDownloadIterator, opts ...func(*s3manager.Downloader)) error
IsSameConfig(config interface{}) bool
}
S3Downloader interface to s3 functions. This is a wrapper around the aws sdk and is useful for testing because we can easily mock out this interface.
func NewS3Downloader ¶
func NewS3Downloader(config *StorageConfiguration, downloadConcurrency int, log logr.Logger) (S3Downloader, error)
NewS3Downloader creates a new client connection to the s3 server and returns it as an S3Downloader
type StorageConfiguration ¶
type StorageConfiguration struct {
StorageType string `json:"type"`
AccessKeyID string `json:"access_key_id"`
SecretAccessKey string `json:"secret_access_key"`
EndpointURL string `json:"endpoint_url"`
Region string `json:"region"`
DefaultBucket string `json:"default_bucket"`
Certificate string `json:"certificate"`
}
StorageConfiguration models the json credentials read from a storage secret