コード例 #1
0
def workflow_list(obj):
    """ List all available workflows. """
    try:
        for wf in list_workflows(config=obj['config']):
            click.echo('{:23} {}'.format(
                _style(obj['show_color'], wf.name, bold=True),
                wf.docstring.split('\n')[0] if wf.docstring is not None else ''))
    except WorkflowDefinitionError as e:
        click.echo(_style(obj['show_color'],
                          'The graph {} in workflow {} is not a directed acyclic graph'.
                          format(e.graph_name, e.workflow_name), fg='red', bold=True))
コード例 #2
0
def api_list_available_workflows():
    """ Endpoint for listing all available workflows.

    Returns a list of available workflows as json under the key 'workflows'.
    The name, parameters and docstring for each workflow is returned.
    """
    result = {'workflows': []}

    for wf in list_workflows(current_app.config['LIGHTFLOW']):
        result['workflows'].append({
            'name':
            wf.name,
            'parameters': [{
                'name': param.name,
                'type': param.type.__name__,
                'docs': param.help,
                'default': param.default
            } for param in wf.parameters],
            'docs':
            wf.docstring.split('\n')[0] if wf.docstring is not None else ''
        })

    return ApiResponse(result)
コード例 #3
0
ファイル: cli.py プロジェクト: malramsay64/lightflow
def workflow_list(obj):
    """ List all available workflows. """
    for wf in list_workflows(config=obj['config']):
        click.echo('{:23} {}'.format(
            _style(obj['show_color'], wf.name, bold=True),
            wf.docstring.split('\n')[0] if wf.docstring is not None else ''))
コード例 #4
0
def test_list_workflows_when_no_workflow_dirs_in_config():
    config = Config()
    config.load_from_dict({'workflows': []})
    assert list_workflows(config) == []
コード例 #5
0
def test_list_workflows_handles_missing_parameters():
    config = Config()
    workflows_path = str(Path(__file__).parent / 'fixtures/workflows')
    config.load_from_dict({'workflows': [workflows_path]})
    assert 'parameters_workflow' in {wf.name for wf in list_workflows(config)}