This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
/
config.go
66 lines (57 loc) · 2.38 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package config
import pluginsConfig "github.com/lyft/flyteplugins/go/tasks/config"
//go:generate pflags Config --default-var=defaultConfig
const sagemakerConfigSectionKey = "sagemaker"
var (
defaultConfig = Config{
RoleArn: "default_role",
Region: "us-east-1",
// https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html
PrebuiltAlgorithms: []PrebuiltAlgorithmConfig{
{
Name: "xgboost",
RegionalConfig: []RegionalConfig{
{
Region: "us-east-1",
VersionConfigs: []VersionConfig{
{
Version: "0.90",
Image: "683313688378.dkr.ecr.us-east-1.amazonaws.com/sagemaker-xgboost:0.90-2-cpu-py3",
},
},
},
},
},
},
}
sagemakerConfigSection = pluginsConfig.MustRegisterSubSection(sagemakerConfigSectionKey, &defaultConfig)
)
// Sagemaker plugin configs
type Config struct {
RoleArn string `json:"roleArn" pflag:",The role the SageMaker plugin uses to communicate with the SageMaker service"`
Region string `json:"region" pflag:",The AWS region the SageMaker plugin communicates to"`
RoleAnnotationKey string `json:"roleAnnotationKey" pflag:",Map key to use to lookup role from task annotations."`
PrebuiltAlgorithms []PrebuiltAlgorithmConfig `json:"prebuiltAlgorithms" pflag:"-,A List of PrebuiltAlgorithm configs"`
}
type PrebuiltAlgorithmConfig struct {
Name string `json:"name" pflag:",The name of the ML algorithm. Should match Sagemaker"`
RegionalConfig []RegionalConfig `json:"regionalConfigs" pflag:"-,Per region specific configuration for this algorithm"`
}
type RegionalConfig struct {
Region string `json:"region" pflag:",Region for which this config is applicable"`
VersionConfigs []VersionConfig `json:"versionConfigs" pflag:",Configuration for various versions of the algorithms'"`
}
type VersionConfig struct {
Version string `json:"version" pflag:",version of the algorithm"`
Image string `json:"image" pflag:",Image URI of the algorithm"`
}
// Retrieves the current config value or default.
func GetSagemakerConfig() *Config {
return sagemakerConfigSection.GetConfig().(*Config)
}
func SetSagemakerConfig(cfg *Config) error {
return sagemakerConfigSection.SetConfig(cfg)
}
func ResetSagemakerConfig() error {
return sagemakerConfigSection.SetConfig(&defaultConfig)
}