Closed anschweitzer closed 1 month ago
A general comment.
I think we should put code like:
def model_dump(self, **kwargs: dict[str, Any]) -> dict:
d = super().model_dump(**kwargs)
d["TelemetryName"] = self.TelemetryName.value
return d
@classmethod
def type_name_value(cls) -> str:
return "data.channel.gt"
into a base class rather than using code generation to inject them into each class. Here's an example:
class Gt(BaseModel):
TypeName: Literal["component.gt"] = "component.gt"
Version: Literal["000"] = "000"
model_config = ConfigDict(use_enum_values=True)
@classmethod
@cached_property
def model_type_name(cls) -> str:
return cls.model_config["TypeName"]
Then all the message classes, ComponentGt and CacGt inherit from this. (Confirm model_type_name does what we want). (Also, I thought I had put use_enum_values in, but I don't see it and I'm not sure why the tests are passing on dev.
model_dump()
. I think it should be doing what we want, and if not we should investigatem and in general i don't think it's the recommended approach until you prove to yourself you need it. More general comment:
Additional specific comments:
hardware_layout.py
would break things. I'll follow up with you later. class ChannelReadings(DataChannelGt):
ChannelId: UUID4Str
ValueList: List[ReallyAnInt]
ScadaReadTimeUnixMsList: List[UTCMilliseconds]
TypeName: Literal["channel.readings"] = "channel.readings"
Version: Literal["000"] = "000"
Then you could remove DataChannelList from BatchedReadings and you wouldn't have to keep track of indices.
ReallyAnInt
if we want to. I took your suggestions re strict int, ChannelReadings and the reduced BatchedReadings. See this pr
PR created for ongoing review