_.isFile
A type-theory check that returns False for actual files
- obj
- *
Let me save you some time: _.isFile from the sfinktah/comfy-ovum pack does not tell you whether a file exists, and it barely tells you whether something is a file. It checks whether the exact type of the object is io.IOBase - the Python base class for file objects - and here's the trap: an actual open file is not io.IOBase, it's a subclass like _io.TextIOWrapper. The exact-type check misses it. You feed this node a real open file and it says False.
That's the kind of bug that's obvious once you see it, which is exactly why the README's warning on the ovum/underscore family - work in progress, "not recommended for use in workflows" - deserves to be taken literally. These are auto-generated wrappers around underscore3, a Python port of Underscore.js, and not every wrapped method survived translation with its meaning intact. isFile is the poster child.
What it does
The implementation:
filetype = io.IOBase
return type(self.obj) is filetype
type(x) is io.IOBase is almost never True in practice. Python's file objects are instances of concrete subclasses - TextIOWrapper, BufferedReader, BufferedWriter - not of the base class itself. The only way to get True is to construct or find an object whose type is io.IOBase, which is something nothing in a normal workflow does. So this node is effectively a False factory for real-world input.
The author's intent is clear - they wanted "is this an open file handle" - and it's not even far off conceptually. The implementation just picked the wrong way to check it. An isinstance check would have worked; the exact-type check doesn't.
Like the rest of the family, it takes a plain value and returns the boolean, or takes a _.CHAIN from _.chain and keeps the chain going.
Inputs and outputs
obj- the only input, type*, optional.- Output - a single
*socket holding a Python bool.
Where it fits
Nowhere, really - and the honest advice is to use a different node. If you want to know whether a path on disk is a real file, the same pack ships proper os.path wrappers (_.isFile's neighbor in the README's path utilities), which delegate to os.path.isfile() and answer the question you actually meant. If you want to check whether an object is an open file handle, this node won't reliably do it. Consider _.isFile a type-theory curiosity that you'll never need, and reach for the pack's path nodes instead.
Installing it
Install the pack via ComfyUI Manager - search comfy-ovum - or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart ComfyUI. No extra dependencies for this node; underscore3 is bundled in the repo.
Gotchas
- Real open files are
TextIOWrapper/BufferedReaderetc., notio.IOBase- the exact-type check saysFalse. - The node has no filesystem interaction at all. It never touches disk.
- For "does this file path exist," use the pack's
os.path.isfilewrapper, not this node.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |