Пример #1
0
def test_read_file_parameter_with_uploads(tmpdir):
    """Test reading a file parameter with a given list of upload files."""
    parameters = [File(name='A', index=0, target='target1')]
    sc = Scanner(reader=ListReader(['f1']))
    arguments = cli.read(parameters, sc, files=[('f1', 'F', '123')])
    assert len(arguments) == 1
    assert arguments['A'] == serialize_fh('f1', target='target1')
Пример #2
0
def start_run(ctx, group, configfile):
    """Start new workflow run."""
    group_id = ctx.obj.get_group(ctx.params)
    config = factory.read_config(configfile) if configfile else None
    with service() as api:
        doc = api.groups().get_group(group_id=group_id)
        config = config if config else doc[glbls.ENGINE_CONFIG]
        # Create list of file descriptors for uploaded files that are included
        # in the submission handle
        files = []
        for fh in doc[glbls.GROUP_UPLOADS]:
            files.append((
                fh[flbls.FILE_ID],
                fh[flbls.FILE_NAME],
                fh[flbls.FILE_DATE][:19])
            )
        # Create list of additional user-provided template parameters
        parameters = ParameterIndex.from_dict(doc[glbls.GROUP_PARAMETERS])
        # Read values for all parameters.
        user_input = read(parameters.sorted(), files=files)
        args = [serialize_arg(key, val) for key, val in user_input.items()]
        # Start the run and print returned run state information.
        doc = api.runs().start_run(group_id=group_id, arguments=args, config=config)
        run_id = doc[labels.RUN_ID]
        run_state = doc[labels.RUN_STATE]
        click.echo('started run {} is {}'.format(run_id, run_state))
Пример #3
0
def test_read_file_parameters(tmpdir):
    """Test reading lists of file parameters."""
    parameters = [
        File(name='A', index=0, target='target1'),
        File(name='B', index=1, default='target2'),
        File(name='C', index=2),
    ]
    sc = Scanner(reader=ListReader([tmpdir, tmpdir, '', tmpdir, 'target3']))
    arguments = cli.read(parameters, sc)
    assert len(arguments) == 3
Пример #4
0
def test_read_string_parameters():
    """Test reading lists of string parameters."""
    parameters = [
        String(name='A', index=0),
        String(name='B', index=1, default='ABC')
    ]
    sc = Scanner(reader=ListReader(['true', '']))
    arguments = cli.read(parameters, sc)
    assert len(arguments) == 2
    assert arguments['A'] == 'true'
    assert arguments['B'] == 'ABC'
Пример #5
0
def test_read_boolean_parameters():
    """Test reading lists of boolean parameters."""
    parameters = [
        Bool(name='A', index=0),
        Bool(name='B', index=1, default=False),
        Bool(name='C', index=2, default=False),
    ]
    sc = Scanner(reader=ListReader(['true', 'xyz', '', 'True']))
    arguments = cli.read(parameters, sc)
    assert len(arguments) == 3
    assert arguments['A']
    assert not arguments['B']
    assert arguments['C']
Пример #6
0
def test_read_numeric_parameters():
    """Test reading lists of numeric parameters."""
    parameters = [
        Int(name='A', index=0),
        Int(name='B', index=1, default=10),
        Float(name='C', index=2),
        Float(name='D', index=3, default=1.23)
    ]
    sc = Scanner(reader=ListReader(['1', 'xyz', '', 'True', '3.4', '']))
    arguments = cli.read(parameters, sc)
    assert len(arguments) == 4
    assert arguments['A'] == 1
    assert arguments['B'] == 10
    assert arguments['C'] == 3.4
    assert arguments['D'] == 1.23
Пример #7
0
def test_read_empty_list():
    """Test reading empty lists of parameter declarations."""
    assert cli.read([]) == dict()