예제 #1
0
def test_can_write_and_read_default_opts(config_file_args, minimal_args):
    config_file_path = config_file_args[1]
    parser = build_parser()
    default_options = vars(parser.parse(args=minimal_args).all_options)
    save_args_to_file(file_name=config_file_path, **default_options)

    try:
        loaded_options = parser.parse(config_file_args).all_options
    except Exception as e:
        raised_exception = e
        loaded_options = None
    else:
        raised_exception = None

    assert raised_exception is None
    assert loaded_options.source_max_length == float('inf')
    assert loaded_options.target_max_length == float('inf')

    loaded_options = vars(loaded_options)
    del loaded_options['config']
    del default_options['config']
    for key, value in loaded_options.items():
        assert key in default_options
        assert value == default_options[key]
        del default_options[key]
    assert not default_options
예제 #2
0
def build_parser():
    return HyperPipelineParser(
        name='jackknife',
        pipeline_parser=train.build_parser(),
        pipeline_config_key='train-config',
        options_fn=jackknife_opts,
    )
예제 #3
0
def train_from_file(filename):
    """
    Loads options from a config file and calls the training procedure.

    Args:
        filename (str): filename of the configuration file
    """
    parser = build_parser()
    options = parser.parse_config_file(filename)
    return train_from_options(options)