| """Tests that dataset node config declared as class attributes reaches the schema. | |
| ``ImageProcessingNode`` and ``TextProcessingNode`` let subclasses configure | |
| themselves with plain class attributes, and their shared ``define_schema()`` is | |
| what forwards those attributes into ``io.Schema``. Anything it forgets to | |
| forward is silently dropped from /object_info, so this pins the forwarding | |
| itself rather than any single field. | |
| """ | |
| import dataclasses | |
| import pytest | |
| from comfy_api.latest import io | |
| from comfy_extras import nodes_dataset | |
| # Structural schema members, not per-node config; a node class would never | |
| # declare these as class attributes. | |
| IGNORED_FIELDS = {"inputs", "outputs", "hidden", "node_id"} | |
| SCHEMA_FIELDS = [ | |
| f.name for f in dataclasses.fields(io.Schema) if f.name not in IGNORED_FIELDS | |
| ] | |
| def _node_classes(): | |
| """Every concrete node defined in nodes_dataset.""" | |
| found = [] | |
| for obj in vars(nodes_dataset).values(): | |
| if not isinstance(obj, type) or not issubclass(obj, io.ComfyNode): | |
| continue | |
| if obj.__module__ != nodes_dataset.__name__: | |
| continue | |
| if getattr(obj, "node_id", "") is None: | |
| continue # abstract base class, define_schema() would raise | |
| found.append(obj) | |
| return sorted(found, key=lambda c: c.__name__) | |
| def test_class_attributes_are_forwarded_to_schema(node_cls): | |
| schema = node_cls.define_schema() | |
| for name in SCHEMA_FIELDS: | |
| declared = getattr(node_cls, name, None) | |
| if not declared: | |
| continue # unset, or left at the base class default | |
| assert getattr(schema, name) == declared, ( | |
| f"{node_cls.__name__}.{name} is not forwarded into io.Schema by " | |
| f"define_schema(), so /object_info reports " | |
| f"{name}={getattr(schema, name)!r} instead of {declared!r}" | |
| ) | |
| def test_node_classes_are_discovered(): | |
| """Guard against the parametrization above collapsing to zero cases.""" | |
| assert _node_classes() | |
Xet Storage Details
- Size:
- 2.09 kB
- Xet hash:
- cfa00595564b5b1f2340d13bc383de767e012ebf80d53208570f22d6c0f990b2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.