Allow artifact-only continuation from imported products
This commit is contained in:
@@ -13,9 +13,9 @@ import (
|
||||
)
|
||||
|
||||
// prepareBoundedReferences makes current references available before downstream
|
||||
// checks when a supplied transcript replaces the normal preparation prefix.
|
||||
// checks when supplied products replace the normal preparation prefix.
|
||||
func prepareBoundedReferences(runtime *invocationRuntime) error {
|
||||
if runtime.plan.Contains("prepare") || !suppliedCompletion(runtime.cfg, runtime.manifest)["transcribe"] {
|
||||
if runtime.plan.Contains("prepare") || !hasSuppliedBaseline(runtime.manifest) {
|
||||
return nil
|
||||
}
|
||||
if !stagesContainAny(runtime.stages, "polish", "trim", "extract", "analyze") {
|
||||
@@ -34,17 +34,19 @@ func prepareBoundedReferences(runtime *invocationRuntime) error {
|
||||
}
|
||||
env := *runtime.env
|
||||
env.Force = false
|
||||
current, err := referencePreparationCurrent(runtime.ctx, runtime.cfg, runtime.manifest, runtime.artifactStore, runtime.effectiveArtifacts)
|
||||
env.ReferenceOnly = true
|
||||
requirements, err := referenceHistoryRequirements(runtime.cfg, runtime.effectiveArtifacts, projection)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reference preparation requirements: %w", err)
|
||||
}
|
||||
env.PreparePreviousRequirements = requirements
|
||||
current, err := referencePreparationCurrent(runtime.ctx, runtime.cfg, runtime.manifest, runtime.artifactStore, runtime.effectiveArtifacts, requirements)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if current {
|
||||
return nil
|
||||
}
|
||||
requirements, err := artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(runtime.cfg), runtime.effectiveArtifacts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reference preparation requirements: %w", err)
|
||||
}
|
||||
if len(requirements) > 0 && strings.TrimSpace(runtime.cfg.Session.PreviousSessionID) != "" && runtime.env.ObjectStore == nil {
|
||||
runtime.env.ObjectStore, err = runtime.dependencies.newObjectStore(runtime.ctx, runtime.cfg)
|
||||
if err != nil {
|
||||
@@ -52,7 +54,9 @@ func prepareBoundedReferences(runtime *invocationRuntime) error {
|
||||
}
|
||||
}
|
||||
priorInputs := append([]manifest.InputRecord(nil), runtime.manifest.Inputs...)
|
||||
result, err := stage.PrepareReferences(runtime.ctx, runtime.env, runtime.manifest)
|
||||
// Preserve any lazily composed history store on the reference environment.
|
||||
env.ObjectStore = runtime.env.ObjectStore
|
||||
result, err := stage.PrepareReferences(runtime.ctx, &env, runtime.manifest)
|
||||
if err != nil {
|
||||
return fmt.Errorf("prepare references: %w", err)
|
||||
}
|
||||
@@ -75,7 +79,7 @@ func prepareBoundedReferences(runtime *invocationRuntime) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *manifest.Manifest, store artifacts.Store, effective artifacts.EffectiveArtifactSet) (bool, error) {
|
||||
func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *manifest.Manifest, store artifacts.Store, effective artifacts.EffectiveArtifactSet, requirements []artifacts.PreviousArtifactRequirement) (bool, error) {
|
||||
if recordedStageStatus(m, "prepare") != manifest.StatusSucceeded {
|
||||
return false, nil
|
||||
}
|
||||
@@ -83,7 +87,7 @@ func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *man
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
env := &stage.Env{Config: cfg, ArtifactStore: store, EffectiveArtifacts: effective}
|
||||
env := &stage.Env{Config: cfg, ArtifactStore: store, EffectiveArtifacts: effective, ReferenceOnly: true, PreparePreviousRequirements: requirements}
|
||||
semantic, err := currentStageSemanticConfig(prepare, env)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -95,6 +99,28 @@ func referencePreparationCurrent(ctx context.Context, cfg *config.Config, m *man
|
||||
return validation != nil && validation.Resumable, nil
|
||||
}
|
||||
|
||||
func referenceHistoryRequirements(cfg *config.Config, effective artifacts.EffectiveArtifactSet, projection *workProjection) ([]artifacts.PreviousArtifactRequirement, error) {
|
||||
var keys []string
|
||||
for _, item := range projection.Stages {
|
||||
if item.Name != "analyze" || item.Decision.action != stageActionRun {
|
||||
continue
|
||||
}
|
||||
if item.Analysis == nil {
|
||||
return artifacts.CollectPreviousArtifactRequirements(configuredScriptoriumArtifacts(cfg), effective)
|
||||
}
|
||||
for _, work := range item.Analysis.ExecutionOrder {
|
||||
keys = append(keys, work.Key)
|
||||
}
|
||||
}
|
||||
requirements, err := artifacts.PreviousArtifactRequirementsForKeys(configuredScriptoriumArtifacts(cfg), keys)
|
||||
// An explicit empty set distinguishes no planned history from the ordinary
|
||||
// preparation default, which collects the full structural target closure.
|
||||
if requirements == nil {
|
||||
requirements = []artifacts.PreviousArtifactRequirement{}
|
||||
}
|
||||
return requirements, err
|
||||
}
|
||||
|
||||
func projectionNeedsReferences(projection *workProjection) bool {
|
||||
needsReferences := false
|
||||
for _, item := range projection.Stages {
|
||||
|
||||
Reference in New Issue
Block a user