def test_log_histogram(self): assert ( os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False ) assert ( os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False ) with patch("polyaxon.tracking.run.Run._log_has_events") as log_dashboard: self.run.log_histogram( name="histo", values=tensor_np(shape=(1024,)), bins="auto", step=1 ) self.run.log_histogram( name="histo", values=tensor_np(shape=(1024,)), bins="fd", step=1 ) self.run.log_histogram( name="histo", values=tensor_np(shape=(1024,)), bins="doane", step=1 ) assert log_dashboard.call_count == 3 self.event_logger.flush() assert ( os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False ) assert ( os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is True ) events_file = get_event_path( self.run_path, kind=V1ArtifactKind.HISTOGRAM, name="histo" ) assert os.path.exists(events_file) is True results = V1Events.read(kind="histogram", name="histo", data=events_file) assert len(results.df.values) == 3
def test_log_histogram(self): assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False) assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False) self.run.log_histogram(name="histo", values=tensor_np(shape=(1024, )), bins="auto", step=1) self.run.log_histogram(name="histo", values=tensor_np(shape=(1024, )), bins="fd", step=1) self.run.log_histogram(name="histo", values=tensor_np(shape=(1024, )), bins="doane", step=1) self.event_logger.flush() assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False) assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is True) events_file = get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM, name="histo") assert os.path.exists(events_file) is True results = V1Events.read(kind="histogram", name="histo", data=events_file) assert len(results.df.values) == 3
def test_log_data_audio(self): assert ( os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is False ) assert ( os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is False ) with patch("polyaxon.tracking.run.Run._log_has_events") as log_dashboard: self.run.log_audio(name="my_audio", data=tensor_np(shape=(42,))) assert log_dashboard.call_count == 1 self.event_logger.flush() assert ( os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is True ) assert ( os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is True ) events_file = get_event_path( self.run_path, kind=V1ArtifactKind.AUDIO, name="my_audio" ) assert os.path.exists(events_file) is True results = V1Events.read(kind="audio", name="my_audio", data=events_file) assert len(results.df.values) == 1 asset_file = get_asset_path( self.run_path, kind=V1ArtifactKind.AUDIO, name="my_audio", ext="wav" ) assert os.path.exists(asset_file) is True
def test_log_data_image(self): assert ( os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is False ) assert ( os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is False ) with patch("polyaxon.tracking.run.Run._log_has_events") as log_dashboard: self.run.log_image( name="my_image", data=tensor_np(shape=(1, 8, 8)), dataformats="CHW" ) assert log_dashboard.call_count == 1 self.event_logger.flush() assert ( os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is True ) assert ( os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is True ) events_file = get_event_path( self.run_path, kind=V1ArtifactKind.IMAGE, name="my_image" ) assert os.path.exists(events_file) is True results = V1Events.read(kind="image", name="my_image", data=events_file) assert len(results.df.values) == 1 asset_file = get_asset_path( self.run_path, kind=V1ArtifactKind.IMAGE, name="my_image", ext="png" ) assert os.path.exists(asset_file) is True
def test_log_data_audio(self): assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is False) assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is False) self.run.log_audio(name="my_audio", data=tensor_np(shape=(42, ))) self.event_logger.flush() assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is True) assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.AUDIO)) is True) events_file = get_event_path(self.run_path, kind=V1ArtifactKind.AUDIO, name="my_audio") assert os.path.exists(events_file) is True results = V1Events.read(kind="audio", name="my_audio", data=events_file) assert len(results.df.values) == 1 asset_file = get_asset_path(self.run_path, kind=V1ArtifactKind.AUDIO, name="my_audio", ext="wav") assert os.path.exists(asset_file) is True
def test_log_data_video(self): assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.VIDEO)) is False) assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.VIDEO)) is False) self.run.log_video(name="my_video", data=tensor_np(shape=(4, 3, 1, 8, 8))) self.event_logger.flush() assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.VIDEO)) is True) assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.VIDEO)) is True) events_file = get_event_path(self.run_path, kind=V1ArtifactKind.VIDEO, name="my_video") assert os.path.exists(events_file) is True results = V1Events.read(kind="video", name="my_video", data=events_file) assert len(results.df.values) == 1 asset_file = get_asset_path(self.run_path, kind=V1ArtifactKind.VIDEO, name="my_video", ext="gif") assert os.path.exists(asset_file) is True
def test_log_image_with_boxes(self): assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is False) assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is False) image_file = tempfile.mkdtemp() + "/file.png" self.touch(image_file) self.run.log_image_with_boxes( name="my_image", tensor_image=tensor_np(shape=(3, 32, 32)), tensor_boxes=np.array([[10, 10, 40, 40]]), ) self.event_logger.flush() assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is True) assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is True) events_file = get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE, name="my_image") assert os.path.exists(events_file) is True results = V1Events.read(kind="image", name="my_image", data=events_file) assert len(results.df.values) == 1 asset_file = get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE, name="my_image") assert os.path.exists(asset_file) is True
def test_log_data_image(self): assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is False) assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is False) self.run.log_image(name="my_image", data=tensor_np(shape=(1, 8, 8)), dataformats="CHW") self.event_logger.flush() assert (os.path.exists( get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is True) assert (os.path.exists( get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE)) is True) events_file = get_event_path(self.run_path, kind=V1ArtifactKind.IMAGE, name="my_image") assert os.path.exists(events_file) is True results = V1Events.read(kind="image", name="my_image", data=events_file) assert len(results.df.values) == 1 asset_file = get_asset_path(self.run_path, kind=V1ArtifactKind.IMAGE, name="my_image", ext="png") assert os.path.exists(asset_file) is True