Commit 67bae9a2 authored by Ignacio Corcuera's avatar Ignacio Corcuera
Browse files

Implementing the evaluation service inside the Senpy api

parent 551a5cb1
......@@ -53,6 +53,21 @@ API_PARAMS = {
"algorithm": {
"aliases": ["plug", "p", "plugins", "algorithms", 'algo', 'a', 'plugin'],
"description": "Plugins to be evaluated",
"required": True,
"help": "See activated plugins in /plugins"
"dataset": {
"aliases": ["datasets", "data", "d"],
"description": "Datasets to be evaluated",
"required": True,
"help": "See avalaible datasets in /datasets"
"plugin_type": {
"@id": "pluginType",
......@@ -19,7 +19,7 @@ Blueprints for Senpy
from flask import (Blueprint, request, current_app, render_template, url_for,
from .models import Error, Response, Help, Plugins, read_schema
from .models import Error, Response, Help, Plugins, read_schema, Datasets
from . import api
from .version import __version__
from functools import wraps
......@@ -133,6 +133,17 @@ def api_root():
req = api.parse_call(request.parameters)
return current_app.senpy.analyse(req)
@api_blueprint.route('/evaluate/', methods=['POST', 'GET'])
def evaluate():
if request.parameters['help']:
dic = dict(api.EVAL_PARAMS)
response = Help(parameters=dic)
return response
params = api.parse_params(request.parameters, api.EVAL_PARAMS)
response = current_app.senpy.evaluate(params)
return response
@api_blueprint.route('/plugins/', methods=['POST', 'GET'])
......@@ -150,3 +161,12 @@ def plugins():
def plugin(plugin=None):
sp = current_app.senpy
return sp.get_plugin(plugin)
@api_blueprint.route('/datasets/', methods=['POST','GET'])
def datasets():
sp = current_app.senpy
datasets = sp.datasets
dic = Datasets(datasets = list(datasets.values()))
return dic
\ No newline at end of file
......@@ -12,10 +12,17 @@ class Client(object):
def analyse(self, input, method='GET', **kwargs):
return self.request('/', method=method, input=input, **kwargs)
def evaluate(self, input, method='GET', **kwargs):
return self.request('/evaluate', method = method, input=input, **kwargs)
def plugins(self, *args, **kwargs):
resp = self.request(path='/plugins').plugins
return { p for p in resp}
def datasets(self):
resp = self.request(path='/datasets').datasets
return { d for d in resp}
def request(self, path=None, method='GET', **params):
url = '{}{}'.format(self.endpoint, path)
response = requests.request(method=method, url=url, params=params)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment