Complete Promptkit batch execution cutover
This commit is contained in:
@@ -27,7 +27,6 @@ type Config struct {
|
||||
Secrets SecretsConfig `yaml:"secrets"`
|
||||
Notify NotifyConfig `yaml:"notify"`
|
||||
MissingSource MissingSourceConfig `yaml:"missing_source"`
|
||||
Scriptorium ScriptoriumConfig `yaml:"scriptorium"`
|
||||
Promptkit PromptkitConfig `yaml:"promptkit"`
|
||||
Workspace WorkspaceConfig `yaml:"workspace"`
|
||||
Dayparts []DaypartConfig `yaml:"dayparts"`
|
||||
@@ -82,14 +81,6 @@ type MissingSourceConfig struct {
|
||||
Sources map[string]MissingSourcePolicy `yaml:"sources"`
|
||||
}
|
||||
|
||||
type ScriptoriumConfig struct {
|
||||
Binary string `yaml:"binary"`
|
||||
ConfigPath string `yaml:"config_path"`
|
||||
Profile string `yaml:"profile"`
|
||||
Timeout time.Duration `yaml:"timeout"`
|
||||
ExtraArgs []string `yaml:"extra_args"`
|
||||
}
|
||||
|
||||
type PromptkitConfig struct {
|
||||
Profile string `yaml:"profile"`
|
||||
ProfileFile string `yaml:"profile_file"`
|
||||
|
||||
@@ -144,8 +144,8 @@ func TestLoadMinimalExampleConfig(t *testing.T) {
|
||||
if cfg.WeatherAPI.Units != "us" {
|
||||
t.Fatalf("Units = %q, want default us", cfg.WeatherAPI.Units)
|
||||
}
|
||||
if cfg.Scriptorium.Binary != "scriptorium" {
|
||||
t.Fatalf("Scriptorium.Binary = %q, want default scriptorium", cfg.Scriptorium.Binary)
|
||||
if cfg.Promptkit.Timeout != 2*time.Minute || cfg.Promptkit.Local.ConcurrencyLimit != 1 {
|
||||
t.Fatalf("Promptkit defaults = %#v", cfg.Promptkit)
|
||||
}
|
||||
if cfg.Workspace.Root != "workspace" {
|
||||
t.Fatalf("Workspace.Root = %q, want default workspace", cfg.Workspace.Root)
|
||||
@@ -158,6 +158,13 @@ func TestLoadMinimalExampleConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsRetiredExecutionConfiguration(t *testing.T) {
|
||||
_, err := LoadFile(writeConfig(t, "scriptorium:\n binary: scriptorium\n"))
|
||||
if err == nil || !strings.Contains(err.Error(), "migrate to promptkit") {
|
||||
t.Fatalf("LoadFile() error = %v, want actionable migration error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadReportModuleOverrides(t *testing.T) {
|
||||
path := writeConfig(t, `
|
||||
reports:
|
||||
|
||||
@@ -43,10 +43,6 @@ func Defaults() Config {
|
||||
Default: MissingSourceWarn,
|
||||
Sources: map[string]MissingSourcePolicy{},
|
||||
},
|
||||
Scriptorium: ScriptoriumConfig{
|
||||
Binary: "scriptorium",
|
||||
Timeout: 2 * time.Minute,
|
||||
},
|
||||
Promptkit: PromptkitConfig{
|
||||
Timeout: 2 * time.Minute,
|
||||
Local: PromptkitLocalConfig{
|
||||
|
||||
@@ -59,6 +59,9 @@ func mergeFile(cfg *Config, path string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("read config %q: %w", path, err)
|
||||
}
|
||||
if err := rejectRetiredExecutionConfig(data); err != nil {
|
||||
return fmt.Errorf("parse config %q: %w", path, err)
|
||||
}
|
||||
if err := yaml.Unmarshal(data, cfg); err != nil {
|
||||
return fmt.Errorf("parse config %q: %w", path, err)
|
||||
}
|
||||
@@ -70,3 +73,20 @@ func mergeFile(cfg *Config, path string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func rejectRetiredExecutionConfig(data []byte) error {
|
||||
var document yaml.Node
|
||||
if err := yaml.Unmarshal(data, &document); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(document.Content) == 0 || document.Content[0].Kind != yaml.MappingNode {
|
||||
return nil
|
||||
}
|
||||
root := document.Content[0]
|
||||
for i := 0; i+1 < len(root.Content); i += 2 {
|
||||
if root.Content[i].Value == "scriptorium" {
|
||||
return fmt.Errorf("scriptorium configuration is no longer supported; migrate to promptkit configuration")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -59,12 +59,6 @@ func Validate(cfg Config) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if cfg.Scriptorium.Binary == "" {
|
||||
return fmt.Errorf("scriptorium.binary is required")
|
||||
}
|
||||
if cfg.Scriptorium.Timeout <= 0 {
|
||||
return fmt.Errorf("scriptorium.timeout must be greater than zero")
|
||||
}
|
||||
if err := validatePromptkit(cfg.Promptkit); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user