- JobEngine: ISelectiveJobHandler lets a host decline jobs of a kind it runs; declined jobs stay queued for other claimers without holding up the rest. JobContext.EnqueueFollowUpAsync queues follow-up work on the same engine. - Server renders the jobs whose every output a managed encoder produces (ManagedRenderJobHandler); MP4 jobs stay for render nodes. Program.cs registers ProcessingModule next to ArchiveModule. Server renders ignore a client's export folder. - Light analysis is queued after imports and after scans that indexed new sequences, so the advisor's Auto values exist without user action. - Analysis jobs log a failing sequence and go on; the job then fails and a retry analyses only the failed ones. The advised frame rate follows the user's fit-to duration. - ProcessingJobs.RenderEach splits a batch into one job per preset for servers; render nodes say which batch presets they did not render, fetch each content once and stop on a changed certificate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
66 lines
3.3 KiB
C#
66 lines
3.3 KiB
C#
using Titano.Core.Archiving;
|
|
using Titano.Core.Diagnostics.Synthetic;
|
|
using Titano.Core.Import;
|
|
using Titano.Core.Model;
|
|
using Titano.Core.Project;
|
|
using Titano.Data.Archiving;
|
|
using Titano.Data.Tests.Archiving;
|
|
using Titano.Testing;
|
|
|
|
namespace Titano.Data.Tests.Processing;
|
|
|
|
/// <summary>New sequences get their light analysis (and so their Auto values) without any user action (BRIEF §1.1).</summary>
|
|
[Category("processing")]
|
|
public sealed class AnalysisFollowUpTests(TestContext context)
|
|
{
|
|
[Test]
|
|
public async Task AnAdoptingScanQueuesLightAnalysisOfTheNewSequencesOnly()
|
|
{
|
|
await using var fx = await ProcessingFixture.CreateAsync(context);
|
|
fx.Write(SyntheticSequence.Create(new SyntheticSequenceOptions { FrameCount = 12 }), "Roof");
|
|
await fx.StartEngineAsync(withArchive: true);
|
|
|
|
var scan = await fx.EnqueueAsync(ArchiveJobs.Scan(fx.Archive.Archive, full: true));
|
|
await fx.WaitForAsync(scan.Id, JobState.Done);
|
|
var light = Assert.NotNull(await SingleLightJobAsync(fx));
|
|
await fx.WaitForAsync(light.Id, JobState.Done);
|
|
|
|
var sequence = (await fx.Db.Sequences.GetAsync(light.TargetIds.Single(), fx.Ct))!;
|
|
Assert.Equal("Roof", sequence.Folder);
|
|
Assert.True(sequence.Status.HasFlag(SequenceStatus.AnalyzedLight), "analysed");
|
|
Assert.True(ProjectSettings.FromJson(await File.ReadAllTextAsync(fx.Folder(sequence).ProjectPath, fx.Ct)).Timing.Mode.HasAdvice, "advised");
|
|
|
|
// Scans that find nothing new queue nothing more.
|
|
foreach (var full in new[] { false, true })
|
|
{
|
|
var again = await fx.EnqueueAsync(ArchiveJobs.Scan(fx.Archive.Archive, full));
|
|
await fx.WaitForAsync(again.Id, JobState.Done);
|
|
}
|
|
Assert.Equal(light.Id, (await SingleLightJobAsync(fx))?.Id);
|
|
}
|
|
|
|
[Test]
|
|
public async Task AnImportQueuesLightAnalysisOfTheSequencesItFilled()
|
|
{
|
|
await using var fx = await ProcessingFixture.CreateAsync(context);
|
|
var card = context.CreateTempDirectory("card");
|
|
Photos.WriteSeries(Path.Combine(card, "DCIM", "100CANON"), ArchiveFixture.Start, 10);
|
|
var plan = await fx.Archive.Service.PlanImportAsync(fx.Archive.Archive.Id, card, new ImportOptions(), null, null, fx.Ct);
|
|
await fx.StartEngineAsync(withArchive: true);
|
|
|
|
var import = await fx.Engine.EnqueueAsync(ArchiveJobs.Import(fx.Archive.Archive, plan, null), createdBy: Guid.CreateVersion7(), cancellationToken: fx.Ct);
|
|
await fx.WaitForAsync(import.Id, JobState.Done);
|
|
var light = Assert.NotNull(await SingleLightJobAsync(fx));
|
|
await fx.WaitForAsync(light.Id, JobState.Done);
|
|
|
|
var sequenceId = await fx.Db.Sequences.FindBySessionKeyAsync(fx.Archive.Archive.Id, plan.Sessions.Single().SessionKey, fx.Ct);
|
|
Assert.SequenceEqual([Assert.NotNull(sequenceId)], light.TargetIds);
|
|
Assert.Equal(import.CreatedBy, light.CreatedBy);
|
|
Assert.Equal(JobPriority.Background, light.Priority);
|
|
Assert.True((await fx.Db.Sequences.GetAsync(sequenceId.Value, fx.Ct))!.Status.HasFlag(SequenceStatus.AnalyzedLight), "analysed");
|
|
}
|
|
|
|
private static async Task<Job?> SingleLightJobAsync(ProcessingFixture fx) =>
|
|
(await fx.Db.Jobs.ListAsync(null, JobKind.LightAnalyse, cancellationToken: fx.Ct)).Items.SingleOrDefault();
|
|
}
|