Skip to content

Commit ee139f1

Browse files
Type checking for config
1 parent bb29069 commit ee139f1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

vidur/config/flat_dataclass.py

+5
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ def reconstruct_original_dataclass(self) -> Any:
6161
if is_subclass(field_type, BasePolyConfig):
6262
config_type = getattr(self, f"{original_field_name}_type")
6363
# find all subclasses of field_type and check which one matches the config_type
64+
config_type_matched = False
6465
for subclass in get_all_subclasses(field_type):
6566
if str(subclass.get_type()) == config_type:
67+
config_type_matched = True
6668
args[original_field_name] = instances[subclass]
6769
break
70+
assert (
71+
config_type_matched
72+
), f"Invalid type {config_type} for {prefixed_field_name}_type. Valid types: {[str(subclass.get_type()) for subclass in get_all_subclasses(field_type)]}"
6873
elif hasattr(field_type, "__dataclass_fields__"):
6974
args[original_field_name] = instances[field_type]
7075
else:

0 commit comments

Comments
 (0)