Added dict coercion for refImages in imageInference#310
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches✨ Simplify code
Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the IInputs dataclass in runware/types.py to allow inputs.referenceImages to be provided as plain dictionaries (in addition to str, File, and IInputReference) and coerces those dict entries into IInputReference instances during __post_init__. This aligns IInputs with existing patterns in the codebase where dict payloads are normalized into dataclass instances for downstream processing (e.g., media normalization).
Changes:
- Expanded the
IInputs.referenceImagestype to acceptDict[str, Any]. - Added
__post_init__coercion that converts dict entries inreferenceImagesintoIInputReference.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if self.referenceImages is not None: | ||
| coerced_reference_images: List[Union[str, File, IInputReference]] = [] | ||
| for item in self.referenceImages: | ||
| if isinstance(item, dict): | ||
| d = dict(item) | ||
| if "type" in d: | ||
| if "refType" not in d: | ||
| d["refType"] = d["type"] | ||
| d.pop("type", None) | ||
| coerced_reference_images.append(IInputReference(**d)) | ||
| else: | ||
| coerced_reference_images.append(item) | ||
| self.referenceImages = coerced_reference_images |
Changed
IInputs.referenceImagesnow acceptsDict[str, Any]entries and coerces them toIInputReferenceinIInputs.__post_init__