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))
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)
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 ''))
def test_list_workflows_when_no_workflow_dirs_in_config(): config = Config() config.load_from_dict({'workflows': []}) assert list_workflows(config) == []
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)}