def test_log_versioned_model_dir(self):
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.MODEL)) is False)
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.MODEL)) is False)
    model_dir = (tempfile.mkdtemp() + '/model')
    create_path(model_dir)
    model_file = (model_dir + '/model.pkl')
    self.touch(model_file)
    weights_file = (model_dir + '/weights')
    self.touch(weights_file)
    configs_file = (model_dir + '/configs')
    self.touch(configs_file)
    with patch('polyaxon.tracking.run.Run._log_has_model') as log_model:
        self.run.log_model(name='my_model', path=model_dir, framework='tensorflow', step=1)
    assert (log_model.call_count == 1)
    self.event_logger.flush()
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.MODEL)) is True)
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.MODEL)) is True)
    events_file = get_event_path(self.run_path, kind=V1ArtifactKind.MODEL, name='my_model')
    assert (os.path.exists(events_file) is True)
    results = V1Events.read(kind='model', name='my_model', data=events_file)
    assert (len(results.df.values) == 1)
    asset_file = get_asset_path(self.run_path, kind=V1ArtifactKind.MODEL, name='my_model_1')
    assert (os.path.exists(asset_file) is True)
def test_log_versioned_model_dir(self):
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.MODEL)) is False)
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.MODEL)) is False)
    model_dir = (tempfile.mkdtemp() + '/model')
    create_path(model_dir)
    model_file = (model_dir + '/model.pkl')
    self.touch(model_file)
    weights_file = (model_dir + '/weights')
    self.touch(weights_file)
    configs_file = (model_dir + '/configs')
    self.touch(configs_file)
    with patch('polyaxon.tracking.run.Run._log_has_model') as log_model:
        self.run.log_model(name='my_model', path=model_dir, framework='tensorflow', step=1)
    assert (log_model.call_count == 1)
    self.event_logger.flush()
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.MODEL)) is True)
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.MODEL)) is True)
    events_file = get_event_path(self.run_path, kind=V1ArtifactKind.MODEL, name='my_model')
    assert (os.path.exists(events_file) is True)
    results = V1Events.read(kind='model', name='my_model', data=events_file)
    assert (len(results.df.values) == 1)
    asset_file = get_asset_path(self.run_path, kind=V1ArtifactKind.MODEL, name='my_model_1')
    assert (os.path.exists(asset_file) is True)