<commit_before>from flask import Blueprint, jsonify

from .security import validate_request_authentication
from qiime.sdk import PluginManager

v1 = Blueprint('v1', __name__)
v1.before_request(validate_request_authentication)


@v1.route('/', methods=['GET', 'POST'])
def root():
    return jsonify(content="!")

@v1.route('/plugins', methods=['GET'])
def plugins():
    pm = PluginManager()
    return jsonify(pm.plugins)<commit_msg>Add plugin workflow fetching to API<commit_after>from flask import Blueprint, jsonify

from .security import validate_request_authentication
from qiime.sdk import PluginManager

PLUGIN_MANAGER = PluginManager()
v1 = Blueprint('v1', __name__)
v1.before_request(validate_request_authentication)


@v1.route('/', methods=['GET', 'POST'])
def root():
    return jsonify(content="!")


@v1.route('/plugins', methods=['GET'])
def api_plugins():
    plugin_list = list(PLUGIN_MANAGER.plugins.keys())
    return jsonify({"names": plugin_list})


@v1.route('/workflows/<plugin_name>', methods=['GET'])
def api_workflows(plugin_name):
    plugin = PLUGIN_MANAGER.plugins[plugin_name]
    workflows_dict = {}
    for key, value in plugin.workflows.items():
        workflows_dict[key] = {}
        workflows_dict[key]['info'] = "Produces: {}".format(list(value.signature.output_artifacts.values()))
    return jsonify({"workflows": workflows_dict})
{'fraction_non_alphanumeric': 0.14660831509846828, 'fraction_numerical': 0.008023340627279359, 'mean_word_length': 5.964467005076142, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5539751', 'n_tokens_mistral': 455, 'n_tokens_neox': 443, 'n_words': 90}