Exemple #1
0
def test_load_config_invalid_yaml():
    file_contents = """
you:
  - will
- not
  - parse
    """
    with pytest.raises(TrainerConfigError):
        fp = io.StringIO(file_contents)
        _load_config(fp)
Exemple #2
0
def test_load_config_valid_yaml():
    file_contents = """
this:
  - is fine
    """
    fp = io.StringIO(file_contents)
    res = _load_config(fp)
    assert res == {"this": ["is fine"]}
Exemple #3
0
def test_assemble_curriculum_config():
    file_contents = """
behavior1:
    curriculum:
        foo: 5
behavior2:
    curriculum:
        foo: 6
    """
    trainer_config = _load_config(file_contents)
    curriculum_config = assemble_curriculum_config(trainer_config)
    assert curriculum_config == {
        "behavior1": {
            "foo": 5
        },
        "behavior2": {
            "foo": 6
        }
    }

    # Check that nothing is returned if no curriculum.
    file_contents = """
behavior1:
    foo: 3
behavior2:
    foo: 4
    """
    trainer_config = _load_config(file_contents)
    curriculum_config = assemble_curriculum_config(trainer_config)
    assert curriculum_config == {}

    # Check that method doesn't break if 1st level entity isn't a dict.
    # Note: this is a malformed configuration.
    file_contents = """
behavior1: 3
behavior2: 4
    """
    trainer_config = _load_config(file_contents)
    curriculum_config = assemble_curriculum_config(trainer_config)
    assert curriculum_config == {}