-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
I have a code like:
@dataclasses.dataclass
class Args:
model_cls: type[Model] = Transformer
I would like to support this through CLI. I have a mapping str -> type[Model]
, such as the user can pass a string --model_cls=Transformer
that I can then normalize to the model class.
Something like:
@dataclasses.dataclass
class Args:
model_cls: type[Model] = field(default=Transformer, parsing_type=str)
def __post_init__(self):
if isinstance(self.model_cls, str):
self.model_cls = _NAME_TO_CLS[self.model]
However I do not know how to make simple_parsing
parse model_cls
as a str
.
Metadata
Metadata
Assignees
Labels
No labels