Allow selecting transcript variants for rendering
This commit is contained in:
@@ -271,12 +271,13 @@ type TrimSeriatimConfig struct {
|
||||
|
||||
// RenderConfig configures render-stage output formatting behavior.
|
||||
type RenderConfig struct {
|
||||
Enabled *bool `yaml:"enabled" json:"enabled"`
|
||||
Format string `yaml:"format" json:"format"`
|
||||
Title string `yaml:"title" json:"title"`
|
||||
IncludeTimestamps *bool `yaml:"include_timestamps" json:"include_timestamps"`
|
||||
IncludeSegmentIDs *bool `yaml:"include_segment_ids" json:"include_segment_ids"`
|
||||
IncludeMetadata bool `yaml:"include_metadata" json:"include_metadata"`
|
||||
Variants []string `yaml:"variants" json:"variants"`
|
||||
Enabled *bool `yaml:"enabled" json:"enabled"`
|
||||
Format string `yaml:"format" json:"format"`
|
||||
Title string `yaml:"title" json:"title"`
|
||||
IncludeTimestamps *bool `yaml:"include_timestamps" json:"include_timestamps"`
|
||||
IncludeSegmentIDs *bool `yaml:"include_segment_ids" json:"include_segment_ids"`
|
||||
IncludeMetadata bool `yaml:"include_metadata" json:"include_metadata"`
|
||||
}
|
||||
|
||||
// ScriptoriumConfig configures Scriptorium-backed artifact generation.
|
||||
|
||||
@@ -103,6 +103,7 @@ func pipelineConfigDefaults() PipelineConfig {
|
||||
},
|
||||
Render: &RenderConfig{
|
||||
Enabled: boolPtr(DefaultRenderEnabled), Format: DefaultRenderFormat, Title: DefaultRenderTitle,
|
||||
Variants: []string{"normalized", "trimmed"},
|
||||
IncludeTimestamps: boolPtr(DefaultRenderTimestamps), IncludeSegmentIDs: boolPtr(DefaultRenderSegmentIDs),
|
||||
},
|
||||
Notification: NotificationConfig{Mode: DefaultNotificationMode},
|
||||
|
||||
@@ -144,3 +144,40 @@ func TestRenderLoadAndValidate(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderVariantsConfiguration(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name, yaml string
|
||||
want []string
|
||||
invalid bool
|
||||
}{
|
||||
{"omitted", "", []string{"normalized", "trimmed"}, false},
|
||||
{"trimmed", "render:\n variants: [trimmed]\n", []string{"trimmed"}, false},
|
||||
{"empty", "render:\n variants: []\n", nil, false},
|
||||
{"null", "render:\n variants: null\n", nil, false},
|
||||
{"unknown", "render:\n variants: [other]\n", nil, true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
pipeline, session := writeConfigFiles(t, testPipelineBaseYAML+"\n"+tc.yaml, testSessionBaseYAML)
|
||||
cfg, err := Load(pipeline, session)
|
||||
if tc.invalid {
|
||||
if err == nil {
|
||||
t.Fatal("expected unsupported variant error")
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := cfg.Pipeline.Render.Variants
|
||||
if len(got) != len(tc.want) {
|
||||
t.Fatalf("variants %v, want %v", got, tc.want)
|
||||
}
|
||||
for i := range got {
|
||||
if got[i] != tc.want[i] {
|
||||
t.Fatalf("variants %v, want %v", got, tc.want)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
|
||||
)
|
||||
|
||||
func validateNotification(cfg NotificationConfig) error {
|
||||
@@ -63,6 +65,9 @@ func validateRender(cfg *RenderConfig) error {
|
||||
if cfg == nil {
|
||||
return nil
|
||||
}
|
||||
if _, err := artifactmodel.SelectRenderVariants(cfg.Variants); err != nil {
|
||||
return fmt.Errorf("pipeline.render.variants: %w", err)
|
||||
}
|
||||
if cfg.Enabled == nil {
|
||||
return fmt.Errorf("pipeline.render.enabled must be set (defaults should populate this)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user