Skip to content
Snippets Groups Projects
Commit 10fe6edc authored by Manuel Spuhler's avatar Manuel Spuhler
Browse files

Exareme algorithm list from API

parent 4f41c3f6
No related branches found
No related tags found
No related merge requests found
...@@ -89,3 +89,4 @@ endpoints: ...@@ -89,3 +89,4 @@ endpoints:
services: services:
exareme: exareme:
miningExaremeUrl: {{ default .Env.EXAREME_URL "http://localhost:9090" }}/mining/query miningExaremeUrl: {{ default .Env.EXAREME_URL "http://localhost:9090" }}/mining/query
algorithmsUrl: {{ default .Env.EXAREME_URL "http://localhost:9090" }}/mining/algorithms.json
\ No newline at end of file
...@@ -12,22 +12,23 @@ import org.springframework.cache.annotation.Cacheable; ...@@ -12,22 +12,23 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.BufferedReader; import eu.hbp.mip.utils.HTTPUtil;
import java.io.InputStream; import org.springframework.beans.factory.annotation.Value;
import java.io.InputStreamReader; import java.io.IOException;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@RestController @RestController
@RequestMapping(value = "/methods", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(value = "/methods", produces = { APPLICATION_JSON_VALUE })
@Api(value = "/methods", description = "the methods API") @Api(value = "/methods", description = "the methods API")
public class MethodsApi extends WokenClientController { public class MethodsApi extends WokenClientController {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodsApi.class); private static final Logger LOGGER = LoggerFactory.getLogger(MethodsApi.class);
private static final Gson gson = new Gson(); private static final Gson gson = new Gson();
d
private static final String EXAREME_ALGO_JSON_FILE="data/exareme_algorithms.json"; @Value("#{'${services.exareme.algorithmsUrl:http://localhost:9090/mining/algorithms.json}'}")
private String exaremeAlgorithmsUrl;
@ApiOperation(value = "List available methods and validations", response = String.class) @ApiOperation(value = "List available methods and validations", response = String.class)
@Cacheable(value = "methods", unless = "#result.getStatusCode().value()!=200") @Cacheable(value = "methods", unless = "#result.getStatusCode().value()!=200")
...@@ -37,19 +38,28 @@ public class MethodsApi extends WokenClientController { ...@@ -37,19 +38,28 @@ public class MethodsApi extends WokenClientController {
return requestWoken(MethodsQuery$.MODULE$, 10, r -> { return requestWoken(MethodsQuery$.MODULE$, 10, r -> {
MethodsResponse result = (MethodsResponse) r; MethodsResponse result = (MethodsResponse) r;
// >> Temporary : should return result.methods() in the future
JsonObject catalog = new JsonParser().parse(result.methods().compactPrint()).getAsJsonObject(); JsonObject catalog = new JsonParser().parse(result.methods().compactPrint()).getAsJsonObject();
InputStream is = MethodsApi.class.getClassLoader().getResourceAsStream(EXAREME_ALGO_JSON_FILE);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
JsonElement element = new JsonParser().parse(br);
JsonArray exaremeAlgo = element.getAsJsonArray();
catalog.get("algorithms").getAsJsonArray().addAll(exaremeAlgo);
// << Temporary
return ResponseEntity.ok(gson.toJson(catalog)); return ResponseEntity.ok(gson.toJson(catalog));
}); });
} }
@ApiOperation(value = "List Exareme algorithms and validations", response = String.class)
@Cacheable(value = "exareme", unless = "#result.getStatusCode().value()!=200")
@RequestMapping(value = "/exareme", method = RequestMethod.GET)
public ResponseEntity<Object> getExaremeAlgorithms() {
LOGGER.info("List Exareme algorithms and validations");
try {
StringBuilder response = new StringBuilder();
HTTPUtil.sendGet(exaremeAlgorithmsUrl, response);
JsonElement element = new JsonParser().parse(response.toString());
return ResponseEntity.ok(gson.toJson(element));
} catch (IOException e) {
return ResponseEntity.status(500).body(e.getMessage());
}
}
} }
[
{
"code": "WP_VARIABLES_HISTOGRAM",
"constraints": {
"variable": {
"binominal": true,
"integer": true,
"polynominal": true,
"real": true
}
},
"description": "Histograms",
"environment": "Exareme",
"label": " Histogram",
"parameters": [
{
"code": "nobuckets",
"constraints": {
"max": null,
"min": 1
},
"default_value": 4,
"description": "The number of clusters. Typical values range from 2 to 10.",
"label": "nobuckets",
"type": "int"
}
],
"type": [
"statistics"
]
},
{
"code": "PIPELINE_ISOUP_REGRESSION_TREE_SERIALIZER",
"constraints": {
"variable": {
"binominal": true,
"integer": true,
"polynominal": true,
"real": true
}
},
"description": "Regression Tree Serializer",
"environment": "Exareme",
"label": " Regression Tree",
"parameters": [],
"type": [
"statistics"
]
},
{
"code": "PIPELINE_ISOUP_MODEL_TREE_SERIALIZER",
"constraints": {
"variable": {
"binominal": true,
"integer": true,
"polynominal": true,
"real": true
}
},
"description": "Model Tree Serializer",
"environment": "Exareme",
"label": "Model Tree",
"parameters": [],
"type": [
"statistics"
]
},
{
"code": "WP_LINEAR_REGRESSION",
"constraints": {
"variable": {
"binominal": false,
"integer": true,
"polynominal": false,
"real": true
}
},
"description": "Linear Regression using Exareme services",
"environment": "Exareme",
"label": "Linear regression",
"parameters": [
{
"code": "design",
"default_value": "factorial",
"description": "The type of multi-factors design. Choose 'factorial' to enable interactions analysis or 'additive' for a model without no interaction at all.",
"label": "design",
"type": "enumeration",
"values": [
"factorial",
"additive"
]
}
],
"type": [
"statistics"
]
},
{
"code": "K_MEANS",
"constraints": {
"covariables": {
"max_count": null,
"min_count": "1"
},
"groupings": {
"max_count": 0,
"min_count": 0
},
"mixed": false,
"variable": {
"binominal": true,
"integer": true,
"polynominal": true,
"real": true
}
},
"description": "k-Means using Exareme services",
"environment": "Exareme",
"label": "K_MEANS",
"parameters": [
{
"code": "k",
"constraints": {
"max": null,
"min": 1
},
"default_value": 5,
"description": "The number of clusters. Typical values range from 2 to 10.",
"label": "k",
"type": "int"
}
],
"type": [
"statistics"
]
}
]
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