Exemplo n.º 1
0
def main():
    """run cptools.job.Job on a yaml file containing arguments"""
    # check arguments
    if len(sys.argv) < 2:
        msg = "missing argument: need to pass a config file as an argument"
        raise ValueError(msg)
    config_file = sys.argv[1]
    if os.path.isfile(config_file) is False:
        msg = "'{}' is not a file".format(config_file)
        raise ValueError(msg)
    # parse yaml file into a dictionary
    yaml_dict = parse_yaml.open_yaml(config_file)
    # check the arguments in the yaml file are recognised
    parse_yaml.check_yaml_args(yaml_dict)
    # parse all possible commands
    experiment_args = parse_yaml.experiment(yaml_dict)
    chunk_args = parse_yaml.chunk(yaml_dict)
    remove_plate_args = parse_yaml.remove_plate(yaml_dict)
    add_plate_args = parse_yaml.add_plate(yaml_dict)
    create_command_args = parse_yaml.create_commands(yaml_dict)
    # some of the optional arguments might be none, in which case don't
    # pass them as arguments to the methods
    jobber = job.Job()
    if experiment_args is not None:
        jobber.add_experiment(**experiment_args)
    if remove_plate_args is not None:
        jobber.remove_plate(**remove_plate_args)
    if add_plate_args is not None:
        jobber.add_plate(**add_plate_args)
    if chunk_args is not None:
        jobber.chunk(**chunk_args)
    jobber.create_commands(**create_command_args)
Exemplo n.º 2
0
def test_add_plate():
    """cptools2.parse_yaml.add_plate(yaml_dict)"""
    yaml_dict = parse_yaml.open_yaml(TEST_PATH)
    output = parse_yaml.add_plate(yaml_dict)
    assert output == {
        "exp_dir": "/path/to/new/experiment",
        "plates": ["plate_3", "plate_4"]
    }
Exemplo n.º 3
0
def test_create_commands():
    """cptools2.parse_yaml.create_commands(yaml_dict)"""
    yaml_dict = parse_yaml.open_yaml(TEST_PATH)
    output = parse_yaml.create_commands(yaml_dict)
    assert output == {
        "pipeline": "/path/to/example_pipeline.cppipe",
        "location": "/example/location",
        "commands_location": "/home/user"
    }
Exemplo n.º 4
0
def test_open_yaml():
    """cptools2.parse_yaml.open_yaml(path_to_yaml)"""
    yaml_dict = parse_yaml.open_yaml(TEST_PATH)
    assert isinstance(yaml_dict, dict)
Exemplo n.º 5
0
def test_remove_plate():
    """cptools2.parse_yaml.remove_plate(yaml_dict):"""
    yaml_dict = parse_yaml.open_yaml(TEST_PATH)
    output = parse_yaml.remove_plate(yaml_dict)
    assert output == {"plates": ["plate_1", "plate_2"]}
Exemplo n.º 6
0
def test_chunk():
    """cptools2.parse_yaml.chunk(yaml_dict)"""
    yaml_dict = parse_yaml.open_yaml(TEST_PATH)
    output = parse_yaml.chunk(yaml_dict)
    assert output == {"job_size": 46}
Exemplo n.º 7
0
def test_experiment():
    """cptools2.parse_yaml.experiment(yaml_dict)"""
    yaml_dict = parse_yaml.open_yaml(TEST_PATH)
    output = parse_yaml.experiment(yaml_dict)
    assert output == {"exp_dir": "/path/to/experiment"}
Exemplo n.º 8
0
def test_check_yaml_args():
    """cptools2.parse_yaml.check_yaml_args(yaml_dict)"""
    yaml_dict = parse_yaml.open_yaml(TEST_BROKEN)
    with pytest.raises(ValueError):
        parse_yaml.check_yaml_args(yaml_dict)