def test_images_read_yaml(self): values = [ V1Event( timestamp=dt_parser.parse("2018-12-11 10:24:57"), image=V1EventImage(path="test"), step=12, ), V1Event( timestamp=dt_parser.parse("2018-12-11 10:25:57"), image=V1EventImage(height=1, width=1), step=13, ), V1Event( timestamp=dt_parser.parse("2018-12-11 10:26:57"), image=V1EventImage(height=10, width=10, colorspace=2), step=14, ), ] events = V1Events.read( name="foo", kind="image", data=os.path.abspath( "tests/fixtures/polyboard/image/image_events.plx"), ) assert events.name == "foo" assert len(events.df.values) == 3 for i in range(3): assert events.get_event_at(i).to_dict() == values[i].to_dict()
def test_images(self): events = LoggedEventListSpec( name="foo", kind="metric", events=[ V1Event( timestamp=dt_parser.parse("2018-12-11 10:24:57"), image=V1EventImage(height=1, width=1, colorspace=1, path="path"), step=12, ), V1Event( timestamp=dt_parser.parse("2018-12-11 11:24:57"), image=V1EventImage(height=10, width=1, colorspace=0, path="path"), step=13, ), V1Event( timestamp=dt_parser.parse("2018-12-11 12:24:57"), image=V1EventImage(height=1, width=10, colorspace=2, path="path"), step=14, ), ], ) events_dict = events.to_dict() assert events_dict == events.from_dict(events_dict).to_dict()
def save_image(asset_path, image_data, height, width, colorspace): check_or_create_path(asset_path, is_dir=False) image_data.save(asset_path, format="PNG") return V1EventImage(height=height, width=width, colorspace=colorspace, path=asset_path)
def image_path(from_path: str, asset_path: str) -> V1EventImage: copy_file_path(from_path, asset_path) return V1EventImage(path=asset_path)
def image_path( from_path: str, asset_path: str, asset_rel_path: str = None ) -> V1EventImage: copy_file_path(from_path, asset_path) return V1EventImage(path=asset_rel_path or asset_path)
def image_path(from_path: str, asset_path: str) -> V1EventImage: check_or_create_path(asset_path, is_dir=False) shutil.copy(from_path, asset_path) return V1EventImage(path=asset_path)