Exemplo n.º 1
0
def text_experiment_different_hash(jikken_experiment):
    exp, expected_variables, _, tmpdir = jikken_experiment
    exp_diff_dir = Experiment(variables=expected_variables,
                              code_dir=os.getcwd())
    assert exp.parameters_hash == exp_diff_dir.parameters_hash
    assert exp.schema_hash == exp_diff_dir.schema_hash
    assert exp_diff_dir.hash != exp.hash
    diff_variables = copy.deepcopy(expected_variables)
    diff_variables['training_parameters']['batch_size'] = 200
    exp_diff_variables = Experiment(name="exp1",
                                    variables=diff_variables,
                                    code_dir=tmpdir.strpath)
    assert exp.parameters_hash != exp_diff_dir.parameters_hash
    assert exp.schema_hash == exp_diff_dir.schema_hash
    assert exp_diff_variables.hash != exp.hash
Exemplo n.º 2
0
def text_same_experiment_hash(jikken_experiment):
    exp, expected_variables, _, tmpdir = jikken_experiment
    exp_same = Experiment(variables=expected_variables,
                          code_dir=tmpdir.strpath)
    assert exp.hash == exp_same.hash
    assert exp.parameters_hash == exp_same.parameters_hash
    assert exp.schema_hash == exp_same.schema_hash
Exemplo n.º 3
0
def test_experiment_different_names(jikken_experiment):
    exp, expected_variables, _, tmpdir = jikken_experiment
    exp_diff_tags = Experiment(name="exp1",
                               variables=expected_variables,
                               code_dir=tmpdir.strpath,
                               tags='test2')
    assert exp.schema_hash == exp_diff_tags.schema_hash
    assert exp.parameters_hash == exp_diff_tags.parameters_hash
    assert exp.hash != exp_diff_tags.hash
Exemplo n.º 4
0
def test_experiment_parameters_schema_comparison(jikken_experiment):
    exp, expected_variables, _, tmpdir = jikken_experiment
    diff_variables = copy.deepcopy(expected_variables)
    diff_variables['training_parameters']['batch_size'] = 200
    exp_2 = Experiment(name="exp2",
                       variables=diff_variables,
                       code_dir=tmpdir.strpath)
    assert exp_2.schema_hash == exp.schema_hash
    assert exp.parameters_hash != exp_2.parameters_hash
Exemplo n.º 5
0
def test_experiment_schema(jikken_experiment):
    "test schema is constructed properly"
    exp, expected_variables, _, tmpdir = jikken_experiment
    expected_hash = '40a3f5106cf9426bd4b13b168717e7bf'
    assert exp.schema_hash == expected_hash
    exp_2 = Experiment(name="exp1",
                       variables=expected_variables,
                       code_dir=tmpdir.strpath)
    assert exp_2.schema_hash == exp.schema_hash
Exemplo n.º 6
0
def jikken_experiment(experiment_setup):
    expected_variables, tags, tmpdir = experiment_setup
    repo_dir = str(tmpdir)
    file_name = os.path.join(repo_dir, 'new-file')
    r = git.Repo.init(repo_dir)
    # This function just creates an empty file ...
    open(file_name, 'wb').close()
    r.index.add([file_name])
    r.index.commit("initial commit")
    exp = Experiment(name="exp",
                     variables=expected_variables,
                     code_dir=repo_dir,
                     tags=tags)
    return exp, expected_variables, tags, tmpdir
Exemplo n.º 7
0
def test_experiment_equality(experiment_setup):
    # Given some variables and tags
    expected_variables, tags, tmpdir = experiment_setup
    # When I  create an experiment
    exp1 = Experiment("exp1",
                      variables=expected_variables,
                      code_dir=str(tmpdir),
                      tags=tags)
    # And another one with teh same inputs
    exp2 = Experiment("exp1",
                      variables=expected_variables,
                      code_dir=str(tmpdir),
                      tags=tags)
    # Then they are equal
    assert exp1 == exp2
    # And when i create a third one with an extra tag
    tags3 = tags + ["third tag"]
    exp3 = Experiment("exp1",
                      variables=expected_variables,
                      code_dir=str(tmpdir),
                      tags=tags3)
    # Then that is also equal
    assert exp1 == exp3
Exemplo n.º 8
0
def test_experiment_not_equality(experiment_setup):
    # Given some variables and tags
    expected_variables, tags, tmpdir = experiment_setup
    # When I  create an experiment
    exp1 = Experiment("exp1",
                      variables=expected_variables,
                      code_dir=str(tmpdir),
                      tags=tags)
    # And whe I create one with a different name
    exp5 = Experiment("exp2",
                      variables=expected_variables,
                      code_dir=str(tmpdir),
                      tags=tags)
    # Then it is not equal
    assert exp1 != exp5
    # And when I create one with different variables
    new_variables = copy.deepcopy(expected_variables)
    new_variables["training_parameters"]["batch_size"] = 5
    exp4 = Experiment("exp1",
                      variables=new_variables,
                      code_dir=str(tmpdir),
                      tags=tags)
    # Then it is not equal
    assert exp1 != exp4
Exemplo n.º 9
0
def test_experiment_from_dict_is_same(jikken_experiment):
    exp, expected_variables, _, tmpdir = jikken_experiment
    new_exp = Experiment.from_dict(exp.to_dict())
    assert new_exp == exp