droboticflow/internal/worker/raw_human_test.go

63 lines
3.2 KiB
Go

package worker
import (
"context"
"droboticflow/internal/domain"
"droboticflow/internal/store"
"testing"
)
func TestRawHumanGateWithoutQwenCreatesFullCoverageTask(t *testing.T) {
ctx := context.Background()
db := store.NewMemoryStore()
runtime := &Runtime{store: db}
if e := db.UpsertAnnotationTemplate(ctx, domain.AnnotationTemplateRecord{ID: "labels", OrganizationID: "org", Version: 6, Status: domain.AnnotationTemplatePublished, HumanStages: domain.DefaultFanyuV58HumanStages()}); e != nil {
t.Fatal(e)
}
node := domain.WorkflowNode{ID: "human", Data: domain.WorkflowNodeData{OperatorID: "operator-builtin-annotation-gate", Hyperparams: []domain.HyperParam{{Key: "ANNOTATION_TEMPLATE_ID", Value: "labels"}}, Inputs: []domain.PortDefinition{{ID: "fullLeftVideos"}, {ID: "fullRightVideos"}, {ID: "leftTimestamps"}, {ID: "rightTimestamps"}, {ID: "imu"}}}}
left := domain.ExecutionArtifact{ID: "left", Name: "left.mp4", Data: map[string]any{"collectionId": "capture", "sourceDurationSeconds": 10.0}}
right := domain.ExecutionArtifact{ID: "right", Name: "right.mp4", Data: map[string]any{"collectionId": "capture", "sourceDurationSeconds": 10.0}}
run := &domain.RunRecord{ID: "run-raw", OrganizationID: "org", ProjectID: "project", WorkflowID: "workflow", ProcessingProfile: domain.ProcessingProfileRawHuman}
tasks, e := runtime.createAnnotationGateTasks(ctx, run, node, nil, []domain.NodeInputBinding{{TargetPortID: "fullLeftVideos", Artifacts: []domain.ExecutionArtifact{left}}, {TargetPortID: "fullRightVideos", Artifacts: []domain.ExecutionArtifact{right}}})
if e != nil {
t.Fatal(e)
}
if len(tasks) != 1 || tasks[0].ProcessingProfile != domain.ProcessingProfileRawHuman || tasks[0].RightArtifactID != "right" {
t.Fatal(tasks)
}
slices, e := db.ListSliceRevisions(ctx, "org", tasks[0].ID)
if e != nil || len(slices) != 1 || len(slices[0].Segments) != 1 || slices[0].Segments[0].Start != 0 || slices[0].Segments[0].End != 10 {
t.Fatal(slices, e)
}
items, _ := db.ListHumanItems(ctx, "org", domain.HumanItemQuery{RunID: run.ID})
if len(items) != 1 || items[0].ProcessingProfile != domain.ProcessingProfileRawHuman {
t.Fatal(items)
}
batches, _ := db.ListHumanBatches(ctx, "org", domain.HumanBatchQuery{RunID: run.ID})
if len(batches) != 1 || batches[0].ProcessingProfile != domain.ProcessingProfileRawHuman {
t.Fatal(batches)
}
}
func TestRawHumanNotSampledDoesNotInventPoseDecision(t *testing.T) {
ctx := context.Background()
db := store.NewMemoryStore()
runtime := &Runtime{store: db}
if e := db.UpsertCaptureRecord(ctx, domain.CaptureRecord{ID: "capture", RunID: "run", SamplingDecision: &domain.CaptureSamplingDecision{Decision: domain.CaptureSamplingNotSelected}}); e != nil {
t.Fatal(e)
}
batch := &domain.HumanBatchRecord{RunID: "run", ProcessingProfile: domain.ProcessingProfileRawHuman, RequirePrePackageAcceptance: true}
evidence, e := fanyuV5PrePackageAcceptanceEvidence(ctx, runtime, batch)
if e != nil {
t.Fatal(e)
}
if evidence["processingProfile"] != domain.ProcessingProfileRawHuman || evidence["poseDelivery"] != nil {
t.Fatal(evidence)
}
batch.ProcessingProfile = ""
legacy, e := fanyuV5PrePackageAcceptanceEvidence(ctx, runtime, batch)
if e != nil || legacy["poseDelivery"] == nil {
t.Fatal(legacy, e)
}
}