ironflow.model.dtypes module
Initially wrapped dtypes to avoid mutable defaults, but after that expanded to facilitate strict type checking when flow connections are made, and to add batching.
Node ports were overridden so that by default they come with an Untyped dtype, and always have a batching flag.
Further, the dtypes are broken down into broad categories of Data, List, and Choice with different behaviours under regular and batched conditions.
Warning
Any additional types defined here later need to be added to the list in DType.from_str to work with (de)serialization.
Implementation of Dtypes changes in ryvencore v0.4, so this file may be short-lived.
- class ironflow.model.dtypes.Boolean(default: bool = False, doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
Data
- class ironflow.model.dtypes.Choice(default=None, items: list | None = None, doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
DTypeData that must be chosen from among a list of items.
When Choice as an input receives output connections… Normally:
Data output: output valid classes must be a subset.
Untyped output: output value must be in the items list.
All else: Fail.
- When batched:
Batched Data output: output valid classes must be a subset.
List output: output valid classes must be a subset.
- Untyped: output value must be iterable, and each element must be in the items
list.
All else: Fail.
Choice is valid when the value is in the items list, or value is None and None is allowed.
Note that when making Data (or List) connections, the connection may be allowed but still result in an invalid value state (in cases where the output value does not match the input items list).
- class ironflow.model.dtypes.DType(default, bounds: tuple = None, doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
DType,ABC
- class ironflow.model.dtypes.Data(default=None, size: str = 'm', doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
DTypeFor most types of data.
When Data as an input receives output connections… Normally:
- Data output: output valid classes must be a subset of input valid classes, and
one of input or output classes must inherit from the other (or be the same).
Untyped output: output value must be an instance of valid classes
All else: Fail.
- When batched:
Batched Data output: same as the unbatched case, but now both are batched.
- Untyped output: output value must be iterable and each element must be an
instance of valid classes.
List output: output valid classes must be a subset of input valid classes.
All else: Fail.
Data is valid when the value is an instance of the valid classes, or is None and None is allowed.
- class ironflow.model.dtypes.Float(default: float = 0.0, bounds: tuple = None, decimals: int = 10, doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
Data
- class ironflow.model.dtypes.Integer(default: int = 0, bounds: tuple = None, doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
Data
- class ironflow.model.dtypes.List(default: list | None = None, doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
DTypeData that is explicitly iterable.
When List as an input receives output connections… Normally:
List output: output valid classes must be a subset.
Batched Data output: output valid classes must be a subset.
- Untyped output: output value must be iterable and each element must be an
instance of valid classes.
All else: Fail.
- When batched:
Batched List output: output valid classes must be a subset.
- Untyped: output value must be iterable, each element must be iterable, and
each element’s element must be an instance of a valid class.
All else: Fail.
List is valid when the value is iterable and all elements are instances of the valid classes, or the value is None and None is allowed.
- Note: allow_none in this case determines whether the _entire dtype value_ may be
None. If you want to specify that the list-like object itself may _contain_ None values, add type(None) to the valid_classes.
- class ironflow.model.dtypes.String(default: str = '', doc: str = '', _load_state=None, valid_classes=None, allow_none=False, batched=False)[source]
Bases:
Data
- class ironflow.model.dtypes.Untyped(doc: str = '', _load_state=None, batched=False)[source]
Bases:
DTypeUntyped data always performs an instance-check when used as input and when it’s used as output, other input nodes always perform an instance-check against it. That means it can’t be used to pre-wire a graph that has missing data.
When Untyped as an input receives output connections… Normally:
Accept anything.
- When batched:
Accept any value that is iterable.
Untyped is always valid unless the value is None and None is not allowed.