From ee380dade0914c01e7f76aa63809ec651faa2589 Mon Sep 17 00:00:00 2001 From: Ruan Comelli Date: Wed, 15 Jun 2022 00:17:01 -0300 Subject: [PATCH] fix(preprocessing/experiment_video): add descriptor and JSON serializer for `ExperimentVideo` --- .../preprocessing/experiment_video.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/boiling_learning/preprocessing/experiment_video.py b/boiling_learning/preprocessing/experiment_video.py index 44c5092b..d411cba0 100644 --- a/boiling_learning/preprocessing/experiment_video.py +++ b/boiling_learning/preprocessing/experiment_video.py @@ -8,10 +8,17 @@ from loguru import logger from boiling_learning.datasets.sliceable import SliceableDataset +from boiling_learning.io import json from boiling_learning.preprocessing.preprocessing import sync_dataframes from boiling_learning.preprocessing.video import PimsVideo, VideoFrame, convert_video -from boiling_learning.utils import PathLike, dataframe_categories_to_int, merge_dicts, resolve from boiling_learning.utils.dataclasses import dataclass, field +from boiling_learning.utils.descriptions import describe +from boiling_learning.utils.utils import ( + PathLike, + dataframe_categories_to_int, + merge_dicts, + resolve, +) class ExperimentVideo: @@ -338,3 +345,13 @@ def targets(self, select_columns: Optional[Union[str, List[str]]] = None) -> pd. df = df[select_columns] return df + + +@json.encode.instance(ExperimentVideo) +def _encode_video(obj: ExperimentVideo) -> json.JSONDataType: + return json.serialize(obj.path) + + +@describe.instance(ExperimentVideo) +def _describe_video(obj: ExperimentVideo) -> Path: + return obj.path