Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Start experiment ID with 0 if no experiments found
  • Loading branch information
Sergei Chipiga
Sergei Chipiga committed Oct 19, 2018
commit ef07ddfcdb950e47133f424d97bc495e7e02ebc7
2 changes: 1 addition & 1 deletion mlflow/store/file_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def create_experiment(self, name, artifact_location=None):
# Get all existing experiments and find the one with largest ID.
# len(list_all(..)) would not work when experiments are deleted.
experiments_ids = [e.experiment_id for e in self.list_experiments(ViewType.ALL)]
experiment_id = max(experiments_ids) + 1
experiment_id = max(experiments_ids) + 1 if experiments_ids else 0
return self._create_experiment_with_id(name, experiment_id, artifact_location)

def _has_experiment(self, experiment_id):
Expand Down
13 changes: 11 additions & 2 deletions tests/store/test_file_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
import os
import shutil
import time
import unittest
import uuid

import time

import mock
import pytest

from mlflow.entities import Experiment, Metric, Param, RunTag, ViewType, RunInfo
Expand Down Expand Up @@ -148,6 +148,15 @@ def test_get_experiment_by_name(self):
exp = fs.get_experiment_by_name(exp_names)
self.assertIsNone(exp)

def test_create_first_experiment(self):
fs = FileStore(self.test_root)
fs.list_experiments = mock.Mock(return_value=[])
fs._create_experiment_with_id = mock.Mock()
fs.create_experiment(random_str(1))
fs._create_experiment_with_id.assert_called_once()
experiment_id = fs._create_experiment_with_id.call_args[0][1]
self.assertEqual(experiment_id, 0)

def test_create_experiment(self):
fs = FileStore(self.test_root)

Expand Down