With the combination of the dataclasses and omegaconf packages we can create hierarchial dataclasses like the following -
class SPORT(Enum):
TENNIS = 'tennis'
CHESS = 'chess'
@dataclass
class PreTrainConfig:
model: Any
data_config: Any
@dataclass
class PreTrainArgs:
pretrain_config: PreTrainConfig
new_sport: Optional[SPORT] = field(
default=SPORT.TENNIS
)
@dataclass
class M5Config(ModelConfig):
pretrain_args: PreTrainArgs
override_this: Union[None, int] = field(
default=None
)
def __post_init__(self):
self.param1 = self.chg_param1()
@staticmethod
def chg_param1():
return '245'
@dataclass
class M5(M5Config):
sport: SPORT = field(
default=SPORT.TENNIS
)
In this case how will I be able to print the type of M5.pretrain_args.new_sport or M5['pretrain_args']['new_sport']?
get_type_hints() does not get the job done.
With the combination of the
dataclasses
andomegaconf
packages we can create hierarchial dataclasses like the following -In this case how will I be able to print the type of
M5.pretrain_args.new_sport
orM5['pretrain_args']['new_sport']
?get_type_hints()
does not get the job done.