Image Pipeline Playground
refactor(frontend/store): rename Samples to Iterations
Mohammad Rajaei9d32daadba15
diff --git a/frontend/src/app/AppHeader.tsx b/frontend/src/app/AppHeader.tsxindex 5fcd974..d96aefd 100644--- a/frontend/src/app/AppHeader.tsx+++ b/frontend/src/app/AppHeader.tsx@@ -15,7 +15,7 @@ import { useGraphStore } from '../store/graphStore'import { ProjectInfoModal } from './ProjectInfoModal'const fieldSx = {- width: 92,+ width: 100,'& .MuiInputBase-root': {color: '#f0ebe3',bgcolor: '#0f0f0f',@@ -177,9 +177,9 @@ export function AppHeader({onOpenRecent,}: AppHeaderProps) {const seed = useGraphStore((s) => s.seed)- const sampleCount = useGraphStore((s) => s.sampleCount)+ const iterationCount = useGraphStore((s) => s.iterationCount)const setSeed = useGraphStore((s) => s.setSeed)- const setSampleCount = useGraphStore((s) => s.setSampleCount)+ const setIterationCount = useGraphStore((s) => s.setIterationCount)const isExecuting = useGraphStore((s) => s.isExecuting)const selectedNodeId = useGraphStore((s) => s.selectedNodeId)const nodeCount = useGraphStore((s) => s.nodes.length)@@ -357,7 +357,7 @@ export function AppHeader({}}><Tooltip- title="Base random seed for stochastic nodes (noise, augmentations, etc.). The same seed gives reproducible results; each sample uses seed + sample index."+ title="Base random seed for stochastic nodes (noise, augmentations, etc.). The same seed gives reproducible results; each iteration uses seed + iteration index."arrowenterDelay={400}>@@ -371,16 +371,16 @@ export function AppHeader({/></Tooltip><Tooltip- title="How many times to run the pipeline. Use more than 1 to preview variation from stochastic nodes; each run gets seed + sample index."+ title="How many times to run the full pipeline over your image set. A batch of 10 images with Iterations=1 runs once; raise this to preview stochastic variation."arrowenterDelay={400}><TextFieldsize="small"- label="Samples"+ label="Iterations"type="number"- value={sampleCount}- onChange={(e) => setSampleCount(Math.max(1, Number(e.target.value) || 1))}+ value={iterationCount}+ onChange={(e) => setIterationCount(Math.max(1, Number(e.target.value) || 1))}sx={fieldSx}/></Tooltip>diff --git a/frontend/src/features/inspector/FileParamInput.tsx b/frontend/src/features/inspector/FileParamInput.tsxindex cf0a0d2..7c858b1 100644--- a/frontend/src/features/inspector/FileParamInput.tsx+++ b/frontend/src/features/inspector/FileParamInput.tsx@@ -11,7 +11,6 @@ interface FileParamInputProps {onChange: (path: string) => voidonPreviews?: (dataUrls: string[], uploadedFiles: string[]) => voidonRemovePreview?: (index: number) => void- onBatchCount?: (count: number) => void}interface UploadResponse {@@ -85,7 +84,6 @@ export function FileParamInput({onChange,onPreviews,onRemovePreview,- onBatchCount,}: FileParamInputProps) {const fileRef = useRef<HTMLInputElement>(null)const addRef = useRef<HTMLInputElement>(null)@@ -133,7 +131,6 @@ export function FileParamInput({const nextFiles = [...uploadedFiles, ...result.files]onPreviews?.(nextUrls, nextFiles)onChange(result.path)- onBatchCount?.(nextUrls.length)notifySuccess(result.count > 1? `Added ${result.count} images (${nextUrls.length} total)`@@ -142,7 +139,6 @@ export function FileParamInput({} else {onPreviews?.(urls, result.files)onChange(result.path)- onBatchCount?.(result.count)notifySuccess(result.count > 1 ? `${result.count} images loaded` : 'Image loaded',)diff --git a/frontend/src/features/inspector/NodeInspector.tsx b/frontend/src/features/inspector/NodeInspector.tsxindex e04c77f..b1361cb 100644--- a/frontend/src/features/inspector/NodeInspector.tsx+++ b/frontend/src/features/inspector/NodeInspector.tsx@@ -38,7 +38,6 @@ export function NodeInspector() {const updateNodeParams = useGraphStore((s) => s.updateNodeParams)const setLocalPreviews = useGraphStore((s) => s.setLocalPreviews)const removeLocalPreview = useGraphStore((s) => s.removeLocalPreview)- const setSampleCount = useGraphStore((s) => s.setSampleCount)const selected = nodes.find((node) => node.id === selectedNodeId) ?? nullconst meta = catalog.find((item) => item.type === selected?.data.type)@@ -168,9 +167,6 @@ export function NodeInspector() {method: 'DELETE',})}}- onBatchCount={(count) => {- setSampleCount(Math.max(1, count))- }}/>)}diff --git a/frontend/src/hooks/useExecutionSocket.ts b/frontend/src/hooks/useExecutionSocket.tsindex 15646b3..c9372ed 100644--- a/frontend/src/hooks/useExecutionSocket.ts+++ b/frontend/src/hooks/useExecutionSocket.ts@@ -36,7 +36,7 @@ export function useExecutionSocket() {const setNodeTiming = useGraphStore((s) => s.setNodeTiming)const toGraphPayload = useGraphStore((s) => s.toGraphPayload)const seed = useGraphStore((s) => s.seed)- const sampleCount = useGraphStore((s) => s.sampleCount)+ const iterationCount = useGraphStore((s) => s.iterationCount)const targetLabelRef = useRef<string | null>(null)const cancel = useCallback(() => {@@ -62,7 +62,7 @@ export function useExecutionSocket() {JSON.stringify({graph: toGraphPayload(),seed,- sample_count: sampleCount,+ sample_count: iterationCount,cache: true,...(options?.targetNodeId? { target_node_id: options.targetNodeId }@@ -162,7 +162,7 @@ export function useExecutionSocket() {addPreview,appendLog,clearExecution,- sampleCount,+ iterationCount,seed,setActiveNodeId,setIsExecuting,diff --git a/frontend/src/hooks/useWorkflowPersistence.ts b/frontend/src/hooks/useWorkflowPersistence.tsindex 431d353..f560f5e 100644--- a/frontend/src/hooks/useWorkflowPersistence.ts+++ b/frontend/src/hooks/useWorkflowPersistence.ts@@ -17,7 +17,7 @@ export function useWorkflowPersistence() {const nodes = useGraphStore((s) => s.nodes)const edges = useGraphStore((s) => s.edges)const seed = useGraphStore((s) => s.seed)- const sampleCount = useGraphStore((s) => s.sampleCount)+ const iterationCount = useGraphStore((s) => s.iterationCount)const workflowId = useGraphStore((s) => s.workflowId)const workflowName = useGraphStore((s) => s.workflowName)const workflowDescription = useGraphStore((s) => s.workflowDescription)@@ -65,7 +65,7 @@ export function useWorkflowPersistence() {nodes,edges,seed,- sampleCount,+ iterationCount,workflowId,workflowName,workflowDescription,diff --git a/frontend/src/store/graphStore.ts b/frontend/src/store/graphStore.tsindex 401c254..56bbf8e 100644--- a/frontend/src/store/graphStore.ts+++ b/frontend/src/store/graphStore.ts@@ -55,7 +55,7 @@ interface GraphState {generatedCode: stringisExecuting: booleanseed: number- sampleCount: number+ iterationCount: number/** Bumped on loadWorkflow so the canvas can refit the viewport. */graphRevision: numberworkflowId: string | null@@ -89,9 +89,9 @@ interface GraphState {setGeneratedCode: (code: string) => voidsetIsExecuting: (value: boolean) => voidsetSeed: (seed: number) => void- setSampleCount: (count: number) => void+ setIterationCount: (count: number) => voidsetWorkflowMeta: (meta: { name?: string; description?: string }) => void- markworkflowDirty: () => void+ markWorkflowDirty: () => voidmarkWorkflowClean: (record?: {id: stringname: string@@ -165,7 +165,7 @@ export const useGraphStore = create<GraphState>((set, get) => ({generatedCode: '# Run codegen to export a Python script\n',isExecuting: false,seed: 0,- sampleCount: 1,+ iterationCount: 1,graphRevision: 0,workflowId: null,workflowName: DEFAULT_WORKFLOW_NAME,@@ -419,7 +419,6 @@ export const useGraphStore = create<GraphState>((set, get) => ({}: item,),- sampleCount: Math.max(1, previews.length),workflowDirty: true,})return { file: removedFile, path: nextPath }@@ -505,7 +504,7 @@ export const useGraphStore = create<GraphState>((set, get) => ({setGeneratedCode: (code) => set({ generatedCode: code }),setIsExecuting: (value) => set({ isExecuting: value }),setSeed: (seed) => set({ seed, workflowDirty: true }),- setSampleCount: (count) => set({ sampleCount: Math.max(1, count), workflowDirty: true }),+ setIterationCount: (count) => set({ iterationCount: Math.max(1, count), workflowDirty: true }),setWorkflowMeta: (meta) =>set((state) => ({@@ -518,7 +517,7 @@ export const useGraphStore = create<GraphState>((set, get) => ({workflowDirty: true,})),- markworkflowDirty: () => set({ workflowDirty: true }),+ markWorkflowDirty: () => set({ workflowDirty: true }),markWorkflowClean: (record) =>set((state) => ({@@ -547,7 +546,7 @@ export const useGraphStore = create<GraphState>((set, get) => ({isExecuting: false,generatedCode: '# Run codegen to export a Python script\n',seed: 0,- sampleCount: 1,+ iterationCount: 1,graphRevision: get().graphRevision + 1,workflowId: null,workflowName: DEFAULT_WORKFLOW_NAME,@@ -621,7 +620,7 @@ export const useGraphStore = create<GraphState>((set, get) => ({toWorkflowDocument: () => {const {seed,- sampleCount,+ iterationCount,workflowId,workflowName,workflowDescription,@@ -636,7 +635,7 @@ export const useGraphStore = create<GraphState>((set, get) => ({...(workflowCreatedAt ? { createdAt: workflowCreatedAt } : {}),...(workflowUpdatedAt ? { updatedAt: workflowUpdatedAt } : {}),seed,- sampleCount,+ iterationCount,graph: get().toGraphPayload(),}},@@ -711,7 +710,7 @@ export const useGraphStore = create<GraphState>((set, get) => ({isExecuting: false,generatedCode: '# Run codegen to export a Python script\n',seed: doc.seed,- sampleCount: Math.max(1, doc.sampleCount),+ iterationCount: Math.max(1, doc.iterationCount),graphRevision: get().graphRevision + 1,workflowId: doc.id ?? null,workflowName: doc.name || DEFAULT_WORKFLOW_NAME,diff --git a/frontend/src/workflow/io.ts b/frontend/src/workflow/io.tsindex d8cc5b8..2e8b74c 100644--- a/frontend/src/workflow/io.ts+++ b/frontend/src/workflow/io.ts@@ -33,7 +33,8 @@ export interface WorkflowDocument {createdAt?: stringupdatedAt?: stringseed: number- sampleCount: number+ /** How many times to run the pipeline (stochastic variation). */+ iterationCount: numbergraph: WorkflowGraphPayload}@@ -89,13 +90,17 @@ function normalizeGraph(graph: WorkflowGraphPayload): WorkflowGraphPayload {}}-function readSampleCount(value: Record<string, unknown>): number {+function readIterationCount(value: Record<string, unknown>): number {const raw =- typeof value.sampleCount === 'number'- ? value.sampleCount- : typeof value.sample_count === 'number'- ? value.sample_count- : 1+ typeof value.iterationCount === 'number'+ ? value.iterationCount+ : typeof value.iteration_count === 'number'+ ? value.iteration_count+ : typeof value.sampleCount === 'number'+ ? value.sampleCount+ : typeof value.sample_count === 'number'+ ? value.sample_count+ : 1return Math.max(1, raw)}@@ -142,7 +147,7 @@ export function coerceWorkflowDocument(value: unknown): WorkflowDocument {...(createdAt ? { createdAt } : {}),...(updatedAt ? { updatedAt } : {}),seed: typeof value.seed === 'number' ? value.seed : 0,- sampleCount: readSampleCount(value),+ iterationCount: readIterationCount(value),graph: normalizeGraph(graph),}}diff --git a/frontend/src/workflow/materializeSampleImages.ts b/frontend/src/workflow/materializeSampleImages.tsindex 0615890..8047e92 100644--- a/frontend/src/workflow/materializeSampleImages.ts+++ b/frontend/src/workflow/materializeSampleImages.ts@@ -20,8 +20,7 @@ function blobToDataUrl(blob: Blob): Promise<string> {* sample via /api/sample-image and attach it like a normal file pick.*/export async function materializeSampleImages(): Promise<void> {- const { nodes, updateNodeParams, setLocalPreviews, setSampleCount } =- useGraphStore.getState()+ const { nodes, updateNodeParams, setLocalPreviews } = useGraphStore.getState()const targets = nodes.filter((node) =>node.data.type === 'load_image' &&@@ -51,5 +50,4 @@ export async function materializeSampleImages(): Promise<void> {updateNodeParams(node.id, { path: result.path })setLocalPreviews(node.id, [dataUrl], result.files)}- setSampleCount(1)}