73 lines
2.5 KiB
Go
73 lines
2.5 KiB
Go
|
|
package app
|
||
|
|
|
||
|
|
import (
|
||
|
|
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
|
||
|
|
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||
|
|
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||
|
|
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||
|
|
)
|
||
|
|
|
||
|
|
// suppliedCompletion examines actual accepted products without changing progress.
|
||
|
|
func suppliedCompletion(cfg *config.Config, m *manifest.Manifest) map[string]bool {
|
||
|
|
covered := map[string]bool{}
|
||
|
|
if cfg == nil || cfg.Pipeline == nil || cfg.Session == nil || m == nil || m.SuppliedProducts == nil {
|
||
|
|
return covered
|
||
|
|
}
|
||
|
|
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||
|
|
covered = artifacts.SuppliedTranscriptCoverage(paths, m.SuppliedProducts)
|
||
|
|
render := cfg.Pipeline.Render
|
||
|
|
if render == nil || render.Enabled == nil || *render.Enabled {
|
||
|
|
selected := []string{"normalized", "trimmed"}
|
||
|
|
if render != nil {
|
||
|
|
selected = render.Variants
|
||
|
|
}
|
||
|
|
variants, err := artifactmodel.SelectRenderVariants(selected)
|
||
|
|
if err == nil {
|
||
|
|
complete := true
|
||
|
|
for _, variant := range variants {
|
||
|
|
record, ok := m.SuppliedProducts.Products[variant.OutputSource]
|
||
|
|
if !ok || artifacts.ValidateSuppliedProduct(paths, variant.OutputSource, variant.OutputPath, record) != nil {
|
||
|
|
complete = false
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if complete {
|
||
|
|
covered["render"] = true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if cfg.Pipeline.Notarius != nil && cfg.Pipeline.Notarius.Enabled && artifacts.SuppliedExtractionComplete(paths, m, artifacts.ExtractionDefinitionsFromConfig(cfg.Pipeline.Notarius)) {
|
||
|
|
covered["extract"] = true
|
||
|
|
}
|
||
|
|
return covered
|
||
|
|
}
|
||
|
|
|
||
|
|
// retireSuppliedForAttempt prevents older supplied completion from returning
|
||
|
|
// after a selected producer begins replacement work.
|
||
|
|
func retireSuppliedForAttempt(cfg *config.Config, m *manifest.Manifest, name string) {
|
||
|
|
if cfg == nil || cfg.Pipeline == nil || cfg.Session == nil || m == nil || m.SuppliedProducts == nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
for source := range m.SuppliedProducts.Products {
|
||
|
|
remove := artifacts.SuppliedTranscriptSourceCovers(source, name)
|
||
|
|
if name == "render" {
|
||
|
|
selected := []string{"normalized", "trimmed"}
|
||
|
|
if cfg.Pipeline.Render != nil {
|
||
|
|
selected = cfg.Pipeline.Render.Variants
|
||
|
|
}
|
||
|
|
variants, _ := artifactmodel.SelectRenderVariants(selected)
|
||
|
|
for _, variant := range variants {
|
||
|
|
if source == variant.OutputSource {
|
||
|
|
remove = true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if name == "extract" && artifacts.IsExtractionArtifactSource(source) {
|
||
|
|
remove = true
|
||
|
|
}
|
||
|
|
if remove {
|
||
|
|
delete(m.SuppliedProducts.Products, source)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|