Add versioning to the data point model

This commit is contained in:
vasilije 2024-12-17 20:20:10 +01:00
parent f455ba9843
commit f71485ea2b
2 changed files with 10 additions and 0 deletions

View file

@ -57,6 +57,7 @@ jobs:
run: |
poetry install --no-interaction --all-extras
poetry run pip install pyinstrument
poetry run pip install parso
# Set environment variables for SHAs

View file

@ -81,3 +81,12 @@ class DataPoint(BaseModel):
"""Deserialize the instance from pickled bytes."""
data = pickle.loads(pickled_data)
return self(**data)
def to_dict(self, **kwargs) -> Dict[str, Any]:
"""Serialize model to a dictionary."""
return self.model_dump(**kwargs)
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "DataPoint":
"""Deserialize model from a dictionary."""
return cls.model_validate(data)