os.path.isfile
The 'does my output actually exist' check every automation graph needs
- path_in
- isfile
If you build ComfyUI graphs that do anything beyond "generate one image and stare at it," this is the node you'll reach for most from the whole path family. os.path.isfile answers the single most important question in automation: is there actually a regular file at this path, right now? It's the difference between a workflow that tries to open a file that isn't there and one that gracefully routes around it.
It comes from the ovum/path/os.path family in comfy-ovum, sfinktah's utility pack, and it's a direct wrapper over Python's os.path.isfile(). No cleverness, no caching - stdlib semantics, straight through.
How it works
Predicate, returns a BOOLEAN (isfile). Path from:
- path (STRING, required): the widget.
- path_in (PATHLIKE,STRING, optional): link-only input; connected value overrides the widget.
The stdlib contract applies: missing file → False, directory → False, file you can't stat → False. It never raises. That's the whole reason predicates are safe to chain into logic without guarding them.
The patterns that matter
Three setups make this node earn its keep:
- Post-save existence gate. Wire your saver's output path in, check
isfile, and only then run the "open in player" or "post-process" branch. Your run can't crash on a missing output anymore. - Polling for external files. Watch a folder where another process drops files. Loop on
isfile; when it flips toTrue, proceed. Combine withos.path.getmtimeto wait until the file stops growing so you don't read a half-written file. - Dispatch on path type.
isfilevsos.path.isdirgives you a clean three-way branch: file, folder, or neither - the skeleton of any "process this batch directory" graph.
Installing it
Standard pack install, once:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Or search "comfy-ovum" in ComfyUI Manager, install, restart. No models, no extra deps - pure stdlib.
Gotchas
- "Exists" is not "is a file." A path that points at a directory, or a broken symlink, returns
False. If you need the looser "does anything exist here, including a broken link," useos.path.lexists; if you need "is it a directory," useisdir. - Regular file only. Special files (devices, sockets, named pipes) aren't "regular files" and return
False. You almost certainly don't care about that - but it's the difference betweenisfileandexists, and it explains the oddFalseon exotic paths. - Symlinks that point at a real file return
True(it follows the link).islinkis the one that asks "is this entry a link."
For any workflow that watches, waits, or gates on disk state, isfile is the node you didn't know you were missing. It's boring, and that's a compliment.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| path_inopt | PATHLIKE,STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| isfile | BOOLEAN | — |