Compare commits
1 commit
main
...
pensar-aut
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4880abf72 |
1 changed files with 2 additions and 6 deletions
|
|
@ -80,11 +80,7 @@ class DataPoint(BaseModel):
|
||||||
"""Serialize the instance to pickle-compatible bytes."""
|
"""Serialize the instance to pickle-compatible bytes."""
|
||||||
return pickle.dumps(self.dict())
|
return pickle.dumps(self.dict())
|
||||||
|
|
||||||
@classmethod
|
# The unsafe from_pickle method is removed due to security concerns (CWE-502).
|
||||||
def from_pickle(self, pickled_data: bytes):
|
|
||||||
"""Deserialize the instance from pickled bytes."""
|
|
||||||
data = pickle.loads(pickled_data)
|
|
||||||
return self(**data)
|
|
||||||
|
|
||||||
def to_dict(self, **kwargs) -> Dict[str, Any]:
|
def to_dict(self, **kwargs) -> Dict[str, Any]:
|
||||||
"""Serialize model to a dictionary."""
|
"""Serialize model to a dictionary."""
|
||||||
|
|
@ -93,4 +89,4 @@ class DataPoint(BaseModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, data: Dict[str, Any]) -> "DataPoint":
|
def from_dict(cls, data: Dict[str, Any]) -> "DataPoint":
|
||||||
"""Deserialize model from a dictionary."""
|
"""Deserialize model from a dictionary."""
|
||||||
return cls.model_validate(data)
|
return cls.model_validate(data)
|
||||||
Loading…
Add table
Reference in a new issue