ComfyUI Node Runs on cloud

Slice

Trim a sequence down to dry-run part of a big sweep

By ali1234·Created 3 years ago·Updated 3 months ago· 130
Slice
  • sequence
  • sequence
start0
stop9999999
step1

Before you commit a 500-step sweep to the queue, it's worth running just the first handful of steps to make sure the workflow actually does what you think it does. Slice is the node for that: it takes a sequence and hands back a smaller piece of it, without touching whatever built the original sequence.

How it works

It's plain Python slicing - sequence[start:stop:step] - so every rule you already know about Python slices applies here. Negative indices count from the end. A stop value past the actual length of the sequence gets clamped automatically instead of erroring. A negative step walks backward, effectively reversing the slice as it goes.

The inputs and outputs that matter

  • sequence (SEQUENCE) - whatever you're trimming.
  • start (INT, default 0) - where the slice begins.
  • stop (INT, default 9999999) - where it ends; the huge default means "take everything" unless you narrow it.
  • step (INT, default 1) - the stride between kept elements.

Output is a single sequence, the trimmed result - feed it into MakeJob, CombineJobs, or whatever consumed the original.

It's also the pragmatic way to resume a big sweep that died partway through - if step 340 of 500 crashed your ComfyUI process, there's no need to rerun the first 339 successful steps. Set start=340 (leave stop at its huge default) on the sequence feeding the job, requeue, and you pick up exactly where you left off instead of burning GPU time re-generating images you already have.

How to install it

Via ComfyUI Manager: search comfyui-job-iterator, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ali1234/comfyui-job-iterator

then restart. No dependencies.

Common issues & troubleshooting

Using it to dry-run an expensive sweep. Set start=0, stop=3 on the sequence feeding your job, queue it, and watch three steps run end to end before you commit to the full run. This is the node's best use case and the reason it's worth keeping in your graph even after you're confident the workflow works - flip it back to the huge default to run for real.

Confusing stop with a count. stop is an index, not "how many items to take." Slice(sequence, 0, 3) gives you the first 3 elements (indices 0, 1, 2) - that part lines up - but if your start isn't 0, remember stop is still measured from the start of the original sequence, not relative to start.

Slicing a sequence that isn't actually indexable. Most of this pack's sequence nodes hand back something slice-friendly (a list, a range), but if you've piped in something unusual from elsewhere in your graph, Python's slicing only works on sequence types - an error here usually means the thing upstream isn't really a plain sequence.

Categoryali1234/sequence

Inputs (4)

NameTypeDefaultDescription
sequenceSEQUENCE
startINT0-9999999–9999999
stopINT9999999-9999999–9999999
stepINT1-9999999–9999999

Outputs (1)

NameTypeDescription
sequenceSEQUENCE