Skip to content

Commit

Permalink
Type checking for config
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolagarwalcp810 committed Oct 8, 2024
1 parent bb29069 commit ee139f1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vidur/config/flat_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ def reconstruct_original_dataclass(self) -> Any:
if is_subclass(field_type, BasePolyConfig):
config_type = getattr(self, f"{original_field_name}_type")
# find all subclasses of field_type and check which one matches the config_type
config_type_matched = False
for subclass in get_all_subclasses(field_type):
if str(subclass.get_type()) == config_type:
config_type_matched = True
args[original_field_name] = instances[subclass]
break
assert (
config_type_matched
), f"Invalid type {config_type} for {prefixed_field_name}_type. Valid types: {[str(subclass.get_type()) for subclass in get_all_subclasses(field_type)]}"
elif hasattr(field_type, "__dataclass_fields__"):
args[original_field_name] = instances[field_type]
else:
Expand Down

0 comments on commit ee139f1

Please sign in to comment.