hyperstate
hyperstate copied to clipboard
Unsupported type: <class 'list'>
File "/opt/conda/lib/python3.8/site-packages/hyperstate/schema/types.py", line 271, in materialize_type raise ValueError(f"Unsupported type: {clz}") ValueError: Unsupported type: <class 'list'>
Here is my code, I used list in my config class.
@dataclass
class Config:
optimizer: OptimizerConfig = field(metadata={'doc': 'Optimizer configuration'})
net: NetConfig = field(metadata={'doc': 'Network configuration'})
steps: int = field(default=1, metadata={'doc': 'Number of steps to run'})
names: list = field(default_factory = lambda: list(['1', '2', '3']))
Seems it doesn't support list type as class member types ? And I also want to know what is the purpose for materialize_type? Is there any keywords to learn about this programming paradigm? thank you !
You can make this work by using a MyPy type annotation:
from typing import List
@dataclass
class Config:
names: List[str] = ...
HyperState should probably either support list and dict directly or at least return a more helpful error message if those are used.
And I also want to know what is the purpose for materialize_type? Is there any keywords to learn about this programming paradigm?
Basically, materialize_type will create a Python object that describes the type/structure of your Config object. This can then be used to parse a serialized config and typecheck all the fields when reconstructing the Config object. The other feature this is used for is when comparing compatibility between different config versions (basically, by running an algorithm that checks whether the type of a config is a subtype of another config type). I don't know if there's a good specific term here, but I would say the broader areas that are most applicable are "type checking", "type system", and "metaprogramming".
And I also want to know what is the purpose for materialize_type? Is there any keywords to learn about this programming paradigm?
Basically,
materialize_typewill create a Python object that describes the type/structure of yourConfigobject. This can then be used to parse a serialized config and typecheck all the fields when reconstructing theConfigobject. The other feature this is used for is when comparing compatibility between different config versions (basically, by running an algorithm that checks whether the type of a config is a subtype of another config type). I don't know if there's a good specific term here, but I would say the broader areas that are most applicable are "type checking", "type system", and "metaprogramming".
Sorry, no message hint for my account. I will see the meta programming in python, seems it can work.