-
Notifications
You must be signed in to change notification settings - Fork 0
Enum and dataclasses #2
Comments
Thanks @mthrok. Your question/proposal is valid just note that the code you are quoting comes from the README and its pseudocode, not real code. It was there for illustration purposes to keep things brief. Here is the actual implementation: @dataclass
class Weights(Enum):
url: str
transforms: Callable
meta: Dict[str, Any]
latest: bool
# method definitions go here And the here is the actual usage: dapi-model-versioning/dapi_lib/models/resnet.py Lines 46 to 53 in 21f0d8e
So as you see with this approach, the parameters are not named. The alternative implementation would look like the following. Note that the use of the base class Weights(Enum):
# method definitions go here
@dataclass
class WeightEntry:
url: str
transforms: Any
meta: meta: Dict[str, Any]
latest: bool Usage: class ResNet50Weights(Weights):
ImageNet1K_RefV1 = WeightEntry(url=..., transforms=..., meta=..., latest=True) |
(Opening a new issue so as not to mix the ongoing discussion)
I feel that separating
dataclass
andEnum
make the code more readable.The text was updated successfully, but these errors were encountered: