Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Type checking for config #40

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading