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)
    with patch('polyaxon.tracking.run.Run._log_has_events') as log_image_with_boxes:
        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]]))
    assert (log_image_with_boxes.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')
    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)
    with patch('polyaxon.tracking.run.Run._log_has_events') as log_image_with_boxes:
        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]]))
    assert (log_image_with_boxes.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')
    assert (os.path.exists(asset_file) is True)