Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hbp-mip/portal-backend
1 result
Show changes
Commits on Source (3)
Showing
with 361 additions and 252 deletions
...@@ -25,8 +25,8 @@ To use this image, you need a running instance of PostgreSQL and to configure th ...@@ -25,8 +25,8 @@ To use this image, you need a running instance of PostgreSQL and to configure th
* PORTAL_DB_PASSWORD: Password to use when connecting to the portal database. * PORTAL_DB_PASSWORD: Password to use when connecting to the portal database.
#### EXTERNAL SERVICES ### #### EXTERNAL SERVICES ###
* MIPENGINE_URL: URL to MIPENGINE server. Default is "http://localhost:5000" .
* EXAREME_URL: URL to Exareme server. Default is "http://localhost:9090" . * EXAREME_URL: URL to Exareme server. Default is "http://localhost:9090" .
* EXAREME2_URL: URL to Exareme2 server. Default is "http://localhost:5000" .
* GALAXY_URL: URL to Workflow server. Default is "http://localhost:8090/" . * GALAXY_URL: URL to Workflow server. Default is "http://localhost:8090/" .
* GALAXY_API_KEY: The api key to authorize galaxy requests. * GALAXY_API_KEY: The api key to authorize galaxy requests.
* GALAXY_USERNAME: The username of galaxy user to be able to embed the frame. * GALAXY_USERNAME: The username of galaxy user to be able to embed the frame.
......
...@@ -35,10 +35,10 @@ spring: ...@@ -35,10 +35,10 @@ spring:
### EXTERNAL SERVICES ### ### EXTERNAL SERVICES ###
services: services:
algorithmsUpdateInterval: {{ .Env.ALGORITHM_UPDATE_INTERVAL}} algorithmsUpdateInterval: {{ .Env.ALGORITHM_UPDATE_INTERVAL}}
mipengine: exareme2:
algorithmsUrl: {{ .Env.MIPENGINE_URL}}/algorithms algorithmsUrl: {{ .Env.EXAREME2_URL}}/algorithms
attributesUrl: {{ .Env.MIPENGINE_URL}}/data_models_attributes attributesUrl: {{ .Env.EXAREME2_URL}}/data_models_attributes
cdesMetadataUrl: {{ .Env.MIPENGINE_URL}}/cdes_metadata cdesMetadataUrl: {{ .Env.EXAREME2_URL}}/cdes_metadata
exareme: exareme:
queryExaremeUrl: {{ default .Env.EXAREME_URL "http://localhost:9090" }}/mining/query queryExaremeUrl: {{ default .Env.EXAREME_URL "http://localhost:9090" }}/mining/query
......
...@@ -2,8 +2,8 @@ package eu.hbp.mip.controllers; ...@@ -2,8 +2,8 @@ package eu.hbp.mip.controllers;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import eu.hbp.mip.models.DTOs.MIPEngineAttributesDTO; import eu.hbp.mip.models.DTOs.Exareme2AttributesDTO;
import eu.hbp.mip.models.DTOs.MIPEngineCommonDataElement; import eu.hbp.mip.models.DTOs.Exareme2CommonDataElement;
import eu.hbp.mip.models.DTOs.PathologyDTO; import eu.hbp.mip.models.DTOs.PathologyDTO;
import eu.hbp.mip.services.ActiveUserService; import eu.hbp.mip.services.ActiveUserService;
import eu.hbp.mip.utils.*; import eu.hbp.mip.utils.*;
...@@ -32,11 +32,11 @@ public class PathologiesAPI { ...@@ -32,11 +32,11 @@ public class PathologiesAPI {
@Value("#{'${authentication.enabled}'}") @Value("#{'${authentication.enabled}'}")
private boolean authenticationIsEnabled; private boolean authenticationIsEnabled;
@Value("#{'${services.mipengine.attributesUrl}'}") @Value("#{'${services.exareme2.attributesUrl}'}")
private String mipengineAttributesUrl; private String exareme2AttributesUrl;
@Value("#{'${services.mipengine.cdesMetadataUrl}'}") @Value("#{'${services.exareme2.cdesMetadataUrl}'}")
private String mipengineCDEsMetadataUrl; private String exareme2CDEsMetadataUrl;
private final ActiveUserService activeUserService; private final ActiveUserService activeUserService;
public PathologiesAPI(ActiveUserService activeUserService) { public PathologiesAPI(ActiveUserService activeUserService) {
...@@ -48,15 +48,15 @@ public class PathologiesAPI { ...@@ -48,15 +48,15 @@ public class PathologiesAPI {
Logger logger = new Logger(activeUserService.getActiveUser().getUsername(), "(GET) /pathologies"); Logger logger = new Logger(activeUserService.getActiveUser().getUsername(), "(GET) /pathologies");
logger.LogUserAction("Loading pathologies ..."); logger.LogUserAction("Loading pathologies ...");
Map<String, List<PathologyDTO.EnumerationDTO>> datasetsPerPathology = getMIPEngineDatasetsPerPathology(logger); Map<String, List<PathologyDTO.EnumerationDTO>> datasetsPerPathology = getExareme2DatasetsPerPathology(logger);
Map<String, MIPEngineAttributesDTO> mipEnginePathologyAttributes = getMIPEnginePathologyAttributes(logger); Map<String, Exareme2AttributesDTO> exareme2PathologyAttributes = getExareme2PathologyAttributes(logger);
List<PathologyDTO> pathologyDTOS = new ArrayList<>(); List<PathologyDTO> pathologyDTOS = new ArrayList<>();
for (String pathology : mipEnginePathologyAttributes.keySet()) { for (String pathology : exareme2PathologyAttributes.keySet()) {
PathologyDTO newPathology; PathologyDTO newPathology;
try { try {
newPathology = new PathologyDTO(pathology, mipEnginePathologyAttributes.get(pathology), datasetsPerPathology.get(pathology)); newPathology = new PathologyDTO(pathology, exareme2PathologyAttributes.get(pathology), datasetsPerPathology.get(pathology));
} }
catch(InternalServerError e) { catch(InternalServerError e) {
logger.LogUserAction(e.getMessage()); logger.LogUserAction(e.getMessage());
...@@ -76,15 +76,15 @@ public class PathologiesAPI { ...@@ -76,15 +76,15 @@ public class PathologiesAPI {
return ResponseEntity.ok().body(gson.toJson(ClaimUtils.getAuthorizedPathologies(logger, authentication, pathologyDTOS))); return ResponseEntity.ok().body(gson.toJson(ClaimUtils.getAuthorizedPathologies(logger, authentication, pathologyDTOS)));
} }
public Map<String, List<PathologyDTO.EnumerationDTO>> getMIPEngineDatasetsPerPathology(Logger logger) { public Map<String, List<PathologyDTO.EnumerationDTO>> getExareme2DatasetsPerPathology(Logger logger) {
Map<String, Map<String, MIPEngineCommonDataElement>> mipEngineCDEsMetadata; Map<String, Map<String, Exareme2CommonDataElement>> exareme2CDEsMetadata;
// Get MIPEngine algorithms // Get Exareme2 algorithms
try { try {
StringBuilder response = new StringBuilder(); StringBuilder response = new StringBuilder();
HTTPUtil.sendGet(mipengineCDEsMetadataUrl, response); HTTPUtil.sendGet(exareme2CDEsMetadataUrl, response);
mipEngineCDEsMetadata = gson.fromJson( exareme2CDEsMetadata = gson.fromJson(
response.toString(), response.toString(),
new TypeToken<HashMap<String, Map<String, MIPEngineCommonDataElement>>>() { new TypeToken<HashMap<String, Map<String, Exareme2CommonDataElement>>>() {
}.getType() }.getType()
); );
} catch (Exception e) { } catch (Exception e) {
...@@ -94,7 +94,7 @@ public class PathologiesAPI { ...@@ -94,7 +94,7 @@ public class PathologiesAPI {
Map<String, List<PathologyDTO.EnumerationDTO>> datasetsPerPathology = new HashMap<>(); Map<String, List<PathologyDTO.EnumerationDTO>> datasetsPerPathology = new HashMap<>();
mipEngineCDEsMetadata.forEach( (pathology, cdePerDataset) -> { exareme2CDEsMetadata.forEach( (pathology, cdePerDataset) -> {
List<PathologyDTO.EnumerationDTO> pathologyDatasetDTOS = new ArrayList<>(); List<PathologyDTO.EnumerationDTO> pathologyDatasetDTOS = new ArrayList<>();
Map datasetEnumerations = (Map) cdePerDataset.get("dataset").getEnumerations(); Map datasetEnumerations = (Map) cdePerDataset.get("dataset").getEnumerations();
datasetEnumerations.forEach((code, label) -> pathologyDatasetDTOS.add(new PathologyDTO.EnumerationDTO((String) code, (String) label))); datasetEnumerations.forEach((code, label) -> pathologyDatasetDTOS.add(new PathologyDTO.EnumerationDTO((String) code, (String) label)));
...@@ -106,15 +106,15 @@ public class PathologiesAPI { ...@@ -106,15 +106,15 @@ public class PathologiesAPI {
return datasetsPerPathology; return datasetsPerPathology;
} }
public Map<String, MIPEngineAttributesDTO> getMIPEnginePathologyAttributes(Logger logger) { public Map<String, Exareme2AttributesDTO> getExareme2PathologyAttributes(Logger logger) {
Map<String, MIPEngineAttributesDTO> mipEnginePathologyAttributes; Map<String, Exareme2AttributesDTO> exareme2PathologyAttributes;
// Get MIPEngine algorithms // Get Exareme2 algorithms
try { try {
StringBuilder response = new StringBuilder(); StringBuilder response = new StringBuilder();
HTTPUtil.sendGet(mipengineAttributesUrl, response); HTTPUtil.sendGet(exareme2AttributesUrl, response);
mipEnginePathologyAttributes = gson.fromJson( exareme2PathologyAttributes = gson.fromJson(
response.toString(), response.toString(),
new TypeToken<HashMap<String, MIPEngineAttributesDTO>>() { new TypeToken<HashMap<String, Exareme2AttributesDTO>>() {
}.getType() }.getType()
); );
} catch (Exception e) { } catch (Exception e) {
...@@ -123,6 +123,6 @@ public class PathologiesAPI { ...@@ -123,6 +123,6 @@ public class PathologiesAPI {
} }
return mipEnginePathologyAttributes; return exareme2PathologyAttributes;
} }
} }
package eu.hbp.mip.models.DTOs; package eu.hbp.mip.models.DTOs;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class MIPEngineAlgorithmDTO { public class Exareme2AlgorithmDTO {
@SerializedName("name") @SerializedName("name")
private String name; private String name;
@SerializedName("desc") @SerializedName("desc")
private String desc; private String desc;
@SerializedName("label") @SerializedName("label")
private String label; private String label;
@SerializedName("type") @SerializedName("type")
private String type; private String type;
@SerializedName("parameters") @SerializedName("parameters")
private Hashtable<String, MIPEngineAlgorithmParameterDTO> parameters; private Hashtable<String, Exareme2AlgorithmParameterDTO> parameters;
@SerializedName("crossvalidation") @SerializedName("crossvalidation")
private String crossvalidation; private String crossvalidation;
@SerializedName("inputdata") @SerializedName("inputdata")
private MIPEngineAlgorithmInputdataDTO inputdata; private Exareme2AlgorithmInputdataDTO inputdata;
public Optional<Hashtable<String, MIPEngineAlgorithmParameterDTO>> getParameters() { public Optional<Hashtable<String, Exareme2AlgorithmParameterDTO>> getParameters() {
return Optional.ofNullable(parameters); return Optional.ofNullable(parameters);
} }
@SerializedName("preprocessing")
private List<Exareme2TransformerDTO> preprocessing;
@Data
@AllArgsConstructor public Optional<List<Exareme2TransformerDTO>> getPreprocessing() {
public static class MIPEngineAlgorithmParameterDTO { return Optional.ofNullable(preprocessing);
}
@SerializedName("label")
private String label;
@Data
@SerializedName("notblank") @AllArgsConstructor
private String notblank; public static class Exareme2AlgorithmParameterDTO {
@SerializedName("multiple") @SerializedName("label")
private String multiple; private String label;
@SerializedName("types") @SerializedName("notblank")
private List<String> types; private String notblank;
@SerializedName("desc") @SerializedName("multiple")
private String desc; private String multiple;
@SerializedName("min") @SerializedName("types")
private String min; private List<String> types;
@SerializedName("max") @SerializedName("desc")
private String max; private String desc;
@SerializedName("default") @SerializedName("min")
private String default_value; private String min;
@SerializedName("enums") @SerializedName("max")
private MIPEngineAlgorithmEnumDTO enums; private String max;
@SerializedName("dict_keys_enums") @SerializedName("default")
private MIPEngineAlgorithmEnumDTO dict_keys_enums; private String default_value;
@SerializedName("dict_values_enums") @SerializedName("enums")
private MIPEngineAlgorithmEnumDTO dict_values_enums; private Exareme2AlgorithmEnumDTO enums;
public Optional<MIPEngineAlgorithmEnumDTO> getEnums() { @SerializedName("dict_keys_enums")
return Optional.ofNullable(enums); private Exareme2AlgorithmEnumDTO dict_keys_enums;
}
@SerializedName("dict_values_enums")
@Data private Exareme2AlgorithmEnumDTO dict_values_enums;
@AllArgsConstructor
public static class MIPEngineAlgorithmEnumDTO { public Optional<Exareme2AlgorithmEnumDTO> getEnums() {
return Optional.ofNullable(enums);
@SerializedName("type") }
private String type;
@Data
@SerializedName("source") @AllArgsConstructor
private List<String> source; public static class Exareme2AlgorithmEnumDTO {
} @SerializedName("type")
} private String type;
@Data @SerializedName("source")
@AllArgsConstructor private List<String> source;
public static class MIPEngineAlgorithmInputdataDTO {
}
@SerializedName("x") }
private MIPEngineAlgorithmInputDataDetailDTO x;
@Data
@SerializedName("y") @AllArgsConstructor
private MIPEngineAlgorithmInputDataDetailDTO y; public static class Exareme2AlgorithmInputdataDTO {
@SerializedName("data_model") @SerializedName("x")
private MIPEngineAlgorithmInputDataDetailDTO data_model; private Exareme2AlgorithmInputDataDetailDTO x;
@SerializedName("datasets") @SerializedName("y")
private MIPEngineAlgorithmInputDataDetailDTO datasets; private Exareme2AlgorithmInputDataDetailDTO y;
@SerializedName("filter") @SerializedName("data_model")
private MIPEngineAlgorithmInputDataDetailDTO filter; private Exareme2AlgorithmInputDataDetailDTO data_model;
public Optional<MIPEngineAlgorithmInputDataDetailDTO> getY() { @SerializedName("datasets")
return Optional.ofNullable(y); private Exareme2AlgorithmInputDataDetailDTO datasets;
}
@SerializedName("filter")
public Optional<MIPEngineAlgorithmInputDataDetailDTO> getX() { private Exareme2AlgorithmInputDataDetailDTO filter;
return Optional.ofNullable(x);
} public Optional<Exareme2AlgorithmInputDataDetailDTO> getY() {
} return Optional.ofNullable(y);
}
@Data
@AllArgsConstructor public Optional<Exareme2AlgorithmInputDataDetailDTO> getX() {
public static class MIPEngineAlgorithmInputDataDetailDTO { return Optional.ofNullable(x);
}
@SerializedName("stattypes") }
private List<String> stattypes;
@SerializedName("label")
private String label; @Data
@AllArgsConstructor
@SerializedName("notblank") public static class Exareme2AlgorithmInputDataDetailDTO {
private String notblank;
@SerializedName("stattypes")
@SerializedName("enumslen") private List<String> stattypes;
private Integer enumslen;
@SerializedName("label")
@SerializedName("multiple") private String label;
private String multiple;
@SerializedName("notblank")
@SerializedName("types") private String notblank;
private List<String> types;
@SerializedName("enumslen")
@SerializedName("desc") private Integer enumslen;
private String desc;
} @SerializedName("multiple")
} private String multiple;
@SerializedName("types")
private List<String> types;
@SerializedName("desc")
private String desc;
}
@Data
@AllArgsConstructor
public static class Exareme2TransformerDTO {
@SerializedName("name")
private String name;
@SerializedName("desc")
private String desc;
@SerializedName("label")
private String label;
@SerializedName("parameters")
private Hashtable<String, Exareme2AlgorithmParameterDTO> parameters;
}
}
...@@ -9,18 +9,21 @@ import java.util.*; ...@@ -9,18 +9,21 @@ import java.util.*;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class MIPEngineAlgorithmRequestDTO { public class Exareme2AlgorithmRequestDTO {
@SerializedName("request_id") @SerializedName("request_id")
private String request_id; private String request_id;
@SerializedName("inputdata") @SerializedName("inputdata")
private InputData inputdata; private InputData inputdata;
@SerializedName("parameters") @SerializedName("parameters")
private HashMap<String, Object> parameters; private HashMap<String, Object> parameters;
@SerializedName("preprocessing")
private HashMap<String, Object> preprocessing;
public MIPEngineAlgorithmRequestDTO(UUID experimentUUID, List<ExaremeAlgorithmRequestParamDTO> exaremeAlgorithmRequestParamDTOs) { public Exareme2AlgorithmRequestDTO(UUID experimentUUID, List<ExaremeAlgorithmRequestParamDTO> exaremeAlgorithmRequestParamDTOs, List<ExaremeAlgorithmDTO.ExaremeTransformerDTO> exaremeTransformers) {
this.request_id = experimentUUID.toString(); this.request_id = experimentUUID.toString();
MIPEngineAlgorithmRequestDTO.InputData inputData = new MIPEngineAlgorithmRequestDTO.InputData(); Exareme2AlgorithmRequestDTO.InputData inputData = new Exareme2AlgorithmRequestDTO.InputData();
HashMap<String, Object> mipEngineParameters = new HashMap<>(); HashMap<String, Object> exareme2Parameters = new HashMap<>();
HashMap<String, Object> exareme2Preprocessing = new HashMap<>();
exaremeAlgorithmRequestParamDTOs.forEach(parameter -> { exaremeAlgorithmRequestParamDTOs.forEach(parameter -> {
...@@ -42,14 +45,31 @@ public class MIPEngineAlgorithmRequestDTO { ...@@ -42,14 +45,31 @@ public class MIPEngineAlgorithmRequestDTO {
break; break;
case "filter": case "filter":
if (parameter.getValue() != null && !parameter.getValue().equals("")) if (parameter.getValue() != null && !parameter.getValue().equals(""))
inputData.setFilters(JsonConverters.convertJsonStringToObject(parameter.getValue(), MIPEngineAlgorithmRequestDTO.Filter.class)); inputData.setFilters(JsonConverters.convertJsonStringToObject(parameter.getValue(), Exareme2AlgorithmRequestDTO.Filter.class));
break; break;
default: default:
mipEngineParameters.put(parameter.getName(), convertStringToMultipleValues(parameter.getValue())); exareme2Parameters.put(parameter.getName(), convertStringToMultipleValues(parameter.getValue()));
} }
}); });
if (exaremeTransformers != null) {
exaremeTransformers.forEach(transformer -> {
HashMap<String, Object> transformerParameterDTOs = new HashMap<>();
for (ExaremeAlgorithmRequestParamDTO parameter : transformer.getParameters()) {
if (parameter.getName().equals("strategies")){
transformerParameterDTOs.put(parameter.getName(),
JsonConverters.convertJsonStringToObject(parameter.getValue(), HashMap.class)
);
}
else {
transformerParameterDTOs.put(parameter.getName(), convertStringToMultipleValues(parameter.getValue()));
}
}
exareme2Preprocessing.put(transformer.getName(), transformerParameterDTOs);
});
}
this.inputdata = inputData; this.inputdata = inputData;
this.parameters = mipEngineParameters; this.parameters = exareme2Parameters;
this.preprocessing = exareme2Preprocessing;
} }
private static Object convertStringToMultipleValues(String str) { private static Object convertStringToMultipleValues(String str) {
......
...@@ -4,14 +4,12 @@ import com.google.gson.annotations.SerializedName; ...@@ -4,14 +4,12 @@ import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class MIPEngineAttributesDTO { public class Exareme2AttributesDTO {
@SerializedName("properties") @SerializedName("properties")
private Map<String, List<MetadataHierarchyDTO>> properties; private Map<String, List<MetadataHierarchyDTO>> properties;
......
...@@ -7,7 +7,7 @@ import lombok.Data; ...@@ -7,7 +7,7 @@ import lombok.Data;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class MIPEngineCommonDataElement { public class Exareme2CommonDataElement {
@SerializedName("is_categorical") @SerializedName("is_categorical")
private Boolean is_categorical; private Boolean is_categorical;
......
...@@ -3,6 +3,7 @@ package eu.hbp.mip.models.DTOs; ...@@ -3,6 +3,7 @@ package eu.hbp.mip.models.DTOs;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -26,32 +27,73 @@ public class ExaremeAlgorithmDTO { ...@@ -26,32 +27,73 @@ public class ExaremeAlgorithmDTO {
@SerializedName("parameters") @SerializedName("parameters")
private List<ExaremeAlgorithmRequestParamDTO> parameters; private List<ExaremeAlgorithmRequestParamDTO> parameters;
@SerializedName("preprocessing")
private List<ExaremeTransformerDTO> preprocessing;
public ExaremeAlgorithmDTO() { public ExaremeAlgorithmDTO() {
} }
public ExaremeAlgorithmDTO(MIPEngineAlgorithmDTO mipEngineAlgorithm) { public ExaremeAlgorithmDTO(Exareme2AlgorithmDTO exareme2Algorithm) {
this.name = mipEngineAlgorithm.getName().toUpperCase(); this.name = exareme2Algorithm.getName().toUpperCase();
this.label = mipEngineAlgorithm.getLabel(); this.label = exareme2Algorithm.getLabel();
this.desc = mipEngineAlgorithm.getDesc(); this.desc = exareme2Algorithm.getDesc();
this.type = "mipengine"; this.type = "exareme2";
List<ExaremeAlgorithmRequestParamDTO> parameters = new ArrayList<>(); List<ExaremeAlgorithmRequestParamDTO> parameters = new ArrayList<>();
if (mipEngineAlgorithm.getInputdata().getY().isPresent()) { if (exareme2Algorithm.getInputdata().getY().isPresent()) {
parameters.add(new ExaremeAlgorithmRequestParamDTO("y", mipEngineAlgorithm.getInputdata().getY().get())); parameters.add(new ExaremeAlgorithmRequestParamDTO("y", exareme2Algorithm.getInputdata().getY().get()));
}
if (exareme2Algorithm.getInputdata().getX().isPresent()) {
parameters.add(new ExaremeAlgorithmRequestParamDTO("x", exareme2Algorithm.getInputdata().getX().get()));
}
parameters.add(new ExaremeAlgorithmRequestParamDTO("pathology", exareme2Algorithm.getInputdata().getData_model()));
parameters.add(new ExaremeAlgorithmRequestParamDTO("dataset", exareme2Algorithm.getInputdata().getDatasets()));
parameters.add(new ExaremeAlgorithmRequestParamDTO("filter", exareme2Algorithm.getInputdata().getFilter()));
if (exareme2Algorithm.getParameters().isPresent()) {
exareme2Algorithm.getParameters().get().forEach((name, parameterDTO) -> {
ExaremeAlgorithmRequestParamDTO parameter = new ExaremeAlgorithmRequestParamDTO(name, parameterDTO);
parameters.add(parameter);
});
} }
if (mipEngineAlgorithm.getInputdata().getX().isPresent()) { this.parameters = parameters;
parameters.add(new ExaremeAlgorithmRequestParamDTO("x", mipEngineAlgorithm.getInputdata().getX().get())); List<ExaremeTransformerDTO> preprocessing = new ArrayList<>();
if (exareme2Algorithm.getPreprocessing().isPresent()) {
exareme2Algorithm.getPreprocessing().get().forEach(exareme2TransformerDTO -> {
ExaremeTransformerDTO transformer = new ExaremeTransformerDTO(exareme2TransformerDTO);
preprocessing.add(transformer);
});
this.preprocessing = preprocessing;
} }
parameters.add(new ExaremeAlgorithmRequestParamDTO("pathology", mipEngineAlgorithm.getInputdata().getData_model())); }
parameters.add(new ExaremeAlgorithmRequestParamDTO("dataset", mipEngineAlgorithm.getInputdata().getDatasets()));
parameters.add(new ExaremeAlgorithmRequestParamDTO("filter", mipEngineAlgorithm.getInputdata().getFilter()));
if (mipEngineAlgorithm.getParameters().isPresent()) { @Data
mipEngineAlgorithm.getParameters().get().forEach((name, parameterDTO) -> { @NoArgsConstructor
@AllArgsConstructor
public static class ExaremeTransformerDTO {
@SerializedName("name")
private String name;
@SerializedName("desc")
private String desc;
@SerializedName("label")
private String label;
@SerializedName("parameters")
private List<ExaremeAlgorithmRequestParamDTO> parameters;
public ExaremeTransformerDTO(Exareme2AlgorithmDTO.Exareme2TransformerDTO transformerDTO) {
this.name = transformerDTO.getName().toUpperCase();
this.label = transformerDTO.getLabel();
this.desc = transformerDTO.getDesc();
List<ExaremeAlgorithmRequestParamDTO> parameters = new ArrayList<>();
transformerDTO.getParameters().forEach((name, parameterDTO) -> {
ExaremeAlgorithmRequestParamDTO parameter = new ExaremeAlgorithmRequestParamDTO(name, parameterDTO); ExaremeAlgorithmRequestParamDTO parameter = new ExaremeAlgorithmRequestParamDTO(name, parameterDTO);
parameters.add(parameter); parameters.add(parameter);
}); });
this.parameters = parameters;
} }
this.setParameters(parameters);
} }
@Data @Data
......
...@@ -55,7 +55,7 @@ public class ExaremeAlgorithmRequestParamDTO { ...@@ -55,7 +55,7 @@ public class ExaremeAlgorithmRequestParamDTO {
private List<String> valueEnumerations; private List<String> valueEnumerations;
public ExaremeAlgorithmRequestParamDTO (){} public ExaremeAlgorithmRequestParamDTO (){}
public ExaremeAlgorithmRequestParamDTO (String name, MIPEngineAlgorithmDTO.MIPEngineAlgorithmParameterDTO parameter){ public ExaremeAlgorithmRequestParamDTO (String name, Exareme2AlgorithmDTO.Exareme2AlgorithmParameterDTO parameter){
this.name = name; this.name = name;
this.desc = parameter.getDesc(); this.desc = parameter.getDesc();
this.valueType = parameter.getTypes().get(0); this.valueType = parameter.getTypes().get(0);
...@@ -69,7 +69,7 @@ public class ExaremeAlgorithmRequestParamDTO { ...@@ -69,7 +69,7 @@ public class ExaremeAlgorithmRequestParamDTO {
this.valueMin = parameter.getMin(); this.valueMin = parameter.getMin();
} }
public ExaremeAlgorithmRequestParamDTO (String name, MIPEngineAlgorithmDTO.MIPEngineAlgorithmInputDataDetailDTO inputDataDetail){ public ExaremeAlgorithmRequestParamDTO (String name, Exareme2AlgorithmDTO.Exareme2AlgorithmInputDataDetailDTO inputDataDetail){
this.name = name; this.name = name;
this.desc = inputDataDetail.getDesc(); this.desc = inputDataDetail.getDesc();
this.value = ""; this.value = "";
......
...@@ -33,8 +33,8 @@ public class PathologyDTO { ...@@ -33,8 +33,8 @@ public class PathologyDTO {
} }
public PathologyDTO(String pathology, MIPEngineAttributesDTO mipEngineAttributesDTO, List<EnumerationDTO> pathologyDatasetDTOS) { public PathologyDTO(String pathology, Exareme2AttributesDTO exareme2AttributesDTO, List<EnumerationDTO> pathologyDatasetDTOS) {
MetadataHierarchyDTO metadataHierarchyDTO = mipEngineAttributesDTO.getProperties().get("cdes").get(0); MetadataHierarchyDTO metadataHierarchyDTO = exareme2AttributesDTO.getProperties().get("cdes").get(0);
if (!metadataHierarchyDTO.isDatasetCDEPresent()) throw new InternalServerError("CommonDataElement Dataset was not present in the pathology:" + pathology); if (!metadataHierarchyDTO.isDatasetCDEPresent()) throw new InternalServerError("CommonDataElement Dataset was not present in the pathology:" + pathology);
metadataHierarchyDTO.updateDatasetCde(pathologyDatasetDTOS); metadataHierarchyDTO.updateDatasetCde(pathologyDatasetDTOS);
......
...@@ -9,7 +9,7 @@ import com.google.gson.reflect.TypeToken; ...@@ -9,7 +9,7 @@ import com.google.gson.reflect.TypeToken;
import eu.hbp.mip.controllers.galaxy.retrofit.RetroFitGalaxyClients; import eu.hbp.mip.controllers.galaxy.retrofit.RetroFitGalaxyClients;
import eu.hbp.mip.controllers.galaxy.retrofit.RetrofitClientInstance; import eu.hbp.mip.controllers.galaxy.retrofit.RetrofitClientInstance;
import eu.hbp.mip.models.DTOs.ExaremeAlgorithmDTO; import eu.hbp.mip.models.DTOs.ExaremeAlgorithmDTO;
import eu.hbp.mip.models.DTOs.MIPEngineAlgorithmDTO; import eu.hbp.mip.models.DTOs.Exareme2AlgorithmDTO;
import eu.hbp.mip.models.galaxy.WorkflowDTO; import eu.hbp.mip.models.galaxy.WorkflowDTO;
import eu.hbp.mip.utils.CustomResourceLoader; import eu.hbp.mip.utils.CustomResourceLoader;
import eu.hbp.mip.utils.Exceptions.BadRequestException; import eu.hbp.mip.utils.Exceptions.BadRequestException;
...@@ -38,8 +38,8 @@ public class AlgorithmService { ...@@ -38,8 +38,8 @@ public class AlgorithmService {
private ArrayList<ExaremeAlgorithmDTO> algorithmDTOS = new ArrayList<>(); private ArrayList<ExaremeAlgorithmDTO> algorithmDTOS = new ArrayList<>();
@Value("#{'${services.mipengine.algorithmsUrl}'}") @Value("#{'${services.exareme2.algorithmsUrl}'}")
private String mipengineAlgorithmsUrl; private String exareme2AlgorithmsUrl;
@Value("#{'${services.exareme.algorithmsUrl}'}") @Value("#{'${services.exareme.algorithmsUrl}'}")
private String exaremeAlgorithmsUrl; private String exaremeAlgorithmsUrl;
...@@ -62,16 +62,16 @@ public class AlgorithmService { ...@@ -62,16 +62,16 @@ public class AlgorithmService {
} }
public void update(Logger logger) { public void update(Logger logger) {
ArrayList<ExaremeAlgorithmDTO> mipengineAlgorithms = getMIPEngineAlgorithms(logger); ArrayList<ExaremeAlgorithmDTO> exareme2Algorithms = getExareme2Algorithms(logger);
ArrayList<ExaremeAlgorithmDTO> exaremeAlgorithms = getExaremeAlgorithms(logger); ArrayList<ExaremeAlgorithmDTO> exaremeAlgorithms = getExaremeAlgorithms(logger);
ArrayList<ExaremeAlgorithmDTO> galaxyAlgorithms = getGalaxyWorkflows(logger); ArrayList<ExaremeAlgorithmDTO> galaxyAlgorithms = getGalaxyWorkflows(logger);
ArrayList<ExaremeAlgorithmDTO> algorithms = new ArrayList<>(); ArrayList<ExaremeAlgorithmDTO> algorithms = new ArrayList<>();
// Remove Exareme algorithms that exist in the Exareme2 // Remove Exareme algorithms that exist in the Exareme2
if (mipengineAlgorithms != null && exaremeAlgorithms != null){ if (exareme2Algorithms != null && exaremeAlgorithms != null){
int old_exareme_algorithm_size = exaremeAlgorithms.size(); int old_exareme_algorithm_size = exaremeAlgorithms.size();
for (ExaremeAlgorithmDTO algorithm : mipengineAlgorithms) { for (ExaremeAlgorithmDTO algorithm : exareme2Algorithms) {
exaremeAlgorithms.removeIf(obj -> Objects.equals(obj.getName(), algorithm.getName())); exaremeAlgorithms.removeIf(obj -> Objects.equals(obj.getName(), algorithm.getName()));
} }
logger.LogUserAction("Removed "+ (old_exareme_algorithm_size - exaremeAlgorithms.size()) +" deprecated exareme algorithms"); logger.LogUserAction("Removed "+ (old_exareme_algorithm_size - exaremeAlgorithms.size()) +" deprecated exareme algorithms");
...@@ -83,11 +83,11 @@ public class AlgorithmService { ...@@ -83,11 +83,11 @@ public class AlgorithmService {
} else { } else {
logger.LogUserAction("Fetching exareme algorithms failed"); logger.LogUserAction("Fetching exareme algorithms failed");
} }
if (mipengineAlgorithms != null) { if (exareme2Algorithms != null) {
algorithms.addAll(mipengineAlgorithms); algorithms.addAll(exareme2Algorithms);
logger.LogUserAction("Loaded " + mipengineAlgorithms.size() + " mipengine algorithms"); logger.LogUserAction("Loaded " + exareme2Algorithms.size() + " exareme2 algorithms");
} else { } else {
logger.LogUserAction("Fetching mipengine algorithms failed"); logger.LogUserAction("Fetching exareme2 algorithms failed");
} }
if (galaxyAlgorithms != null) { if (galaxyAlgorithms != null) {
algorithms.addAll(galaxyAlgorithms); algorithms.addAll(galaxyAlgorithms);
...@@ -143,8 +143,8 @@ public class AlgorithmService { ...@@ -143,8 +143,8 @@ public class AlgorithmService {
private String getAlgorithmEngineType(ExaremeAlgorithmDTO algorithmDTO){ private String getAlgorithmEngineType(ExaremeAlgorithmDTO algorithmDTO){
switch (algorithmDTO.getType()) { switch (algorithmDTO.getType()) {
case "mipengine": case "exareme2":
return "MIP-Engine"; return "Exareme2";
case "workflow": case "workflow":
return "Galaxy"; return "Galaxy";
default: default:
...@@ -178,19 +178,19 @@ public class AlgorithmService { ...@@ -178,19 +178,19 @@ public class AlgorithmService {
} }
/** /**
* This method gets all the available mipengine algorithms and * This method gets all the available exareme2 algorithms and
* *
* @return a list of AlgorithmDTOs or null if something fails * @return a list of AlgorithmDTOs or null if something fails
*/ */
public ArrayList<ExaremeAlgorithmDTO> getMIPEngineAlgorithms(Logger logger) { public ArrayList<ExaremeAlgorithmDTO> getExareme2Algorithms(Logger logger) {
ArrayList<MIPEngineAlgorithmDTO> mipEngineAlgorithms; ArrayList<Exareme2AlgorithmDTO> exareme2Algorithms;
// Get MIPEngine algorithms // Get Exareme2 algorithms
try { try {
StringBuilder response = new StringBuilder(); StringBuilder response = new StringBuilder();
HTTPUtil.sendGet(mipengineAlgorithmsUrl, response); HTTPUtil.sendGet(exareme2AlgorithmsUrl, response);
mipEngineAlgorithms = gson.fromJson( exareme2Algorithms = gson.fromJson(
response.toString(), response.toString(),
new TypeToken<ArrayList<MIPEngineAlgorithmDTO>>() { new TypeToken<ArrayList<Exareme2AlgorithmDTO>>() {
}.getType() }.getType()
); );
} catch (Exception e) { } catch (Exception e) {
...@@ -199,7 +199,7 @@ public class AlgorithmService { ...@@ -199,7 +199,7 @@ public class AlgorithmService {
} }
ArrayList<ExaremeAlgorithmDTO> algorithms = new ArrayList<>(); ArrayList<ExaremeAlgorithmDTO> algorithms = new ArrayList<>();
mipEngineAlgorithms.forEach(mipEngineAlgorithm -> algorithms.add(new ExaremeAlgorithmDTO(mipEngineAlgorithm))); exareme2Algorithms.forEach(exareme2Algorithm -> algorithms.add(new ExaremeAlgorithmDTO(exareme2Algorithm)));
logger.LogUserAction("Completed, returned " + algorithms.size() + " Exareme2 algorithms."); logger.LogUserAction("Completed, returned " + algorithms.size() + " Exareme2 algorithms.");
return algorithms; return algorithms;
......
...@@ -32,8 +32,8 @@ public class ExperimentService { ...@@ -32,8 +32,8 @@ public class ExperimentService {
@Value("#{'${services.exareme.queryExaremeUrl}'}") @Value("#{'${services.exareme.queryExaremeUrl}'}")
private String queryExaremeUrl; private String queryExaremeUrl;
@Value("#{'${services.mipengine.algorithmsUrl}'}") @Value("#{'${services.exareme2.algorithmsUrl}'}")
private String mipengineAlgorithmsUrl; private String exareme2AlgorithmsUrl;
@Value("#{'${authentication.enabled}'}") @Value("#{'${authentication.enabled}'}")
private boolean authenticationIsEnabled; private boolean authenticationIsEnabled;
...@@ -356,13 +356,37 @@ public class ExperimentService { ...@@ -356,13 +356,37 @@ public class ExperimentService {
private void algorithmParametersLogging(ExperimentDTO experimentDTO, Logger logger) { private void algorithmParametersLogging(ExperimentDTO experimentDTO, Logger logger) {
String algorithmName = experimentDTO.getAlgorithm().getName(); String algorithmName = experimentDTO.getAlgorithm().getName();
StringBuilder parametersLogMessage = new StringBuilder(", Parameters:\n"); StringBuilder parametersLogMessage = new StringBuilder(", Parameters:\n");
experimentDTO.getAlgorithm().getParameters().forEach( if (experimentDTO.getAlgorithm().getParameters() != null){
params -> parametersLogMessage experimentDTO.getAlgorithm().getParameters().forEach(
params -> parametersLogMessage
.append(" ")
.append(params.getLabel())
.append(" -> ")
.append(params.getValue())
.append("\n"));
}
if (experimentDTO.getAlgorithm().getPreprocessing() != null) {
experimentDTO.getAlgorithm().getPreprocessing().forEach(transformer ->
{
parametersLogMessage
.append(" ") .append(" ")
.append(params.getLabel()) .append(transformer.getLabel())
.append(" -> ") .append(" -> ")
.append(params.getValue()) .append("\n");
.append("\n"));
if (transformer.getParameters() != null) {
transformer.getParameters().forEach(
transformerParams -> parametersLogMessage
.append(" ")
.append(transformerParams.getLabel())
.append(" -> ")
.append(transformerParams.getValue())
.append("\n"));
parametersLogMessage.append("\n");
}
});
}
logger.LogUserAction("Executing " + algorithmName + parametersLogMessage); logger.LogUserAction("Executing " + algorithmName + parametersLogMessage);
} }
...@@ -392,7 +416,7 @@ public class ExperimentService { ...@@ -392,7 +416,7 @@ public class ExperimentService {
/** /**
* Creates an experiment and runs it on the background. * Creates an experiment and runs it on the background.
* Uses the exareme or mip-engine engine that run an experiment synchronously. * Uses the exareme or exareme2 engine that run an experiment synchronously.
* *
* @param experimentDTO is the request with the experiment information * @param experimentDTO is the request with the experiment information
* @param logger contains username and the endpoint. * @param logger contains username and the endpoint.
...@@ -436,15 +460,15 @@ public class ExperimentService { ...@@ -436,15 +460,15 @@ public class ExperimentService {
} }
/** /**
* Runs the experiment to exareme or MIPEngine, waiting for the response from them. * Runs the experiment to exareme or Exareme2, waiting for the response from them.
* Exareme and MIP-Engine do not support async fetching of an algorithm result. * Exareme and Exareme2 do not support async fetching of an algorithm result.
* *
* @param experimentDTO is the request with the experiment information * @param experimentDTO is the request with the experiment information
* @return the result of experiment as well as the http status that was retrieved * @return the result of experiment as well as the http status that was retrieved
*/ */
private ExaremeAlgorithmResultDTO runSynchronousExperiment(ExperimentDTO experimentDTO, String algorithmEngineName, Logger logger) { private ExaremeAlgorithmResultDTO runSynchronousExperiment(ExperimentDTO experimentDTO, String algorithmEngineName, Logger logger) {
if (algorithmEngineName.equals("MIP-Engine")) { if (algorithmEngineName.equals("Exareme2")) {
return runMIPEngineExperiment(experimentDTO, logger); return runExareme2Experiment(experimentDTO, logger);
} else { } else {
return runExaremeExperiment(experimentDTO, logger); return runExaremeExperiment(experimentDTO, logger);
} }
...@@ -499,22 +523,22 @@ public class ExperimentService { ...@@ -499,22 +523,22 @@ public class ExperimentService {
} }
/** /**
* The runMIPEngineExperiment will run an experiment using the MIP-Engine * The runExareme2Experiment will run an experiment using the Exareme2
* *
* @param experimentDTO contains the information needed to run the experiment * @param experimentDTO contains the information needed to run the experiment
* @param logger is used to log * @param logger is used to log
* @return the result of the algorithm * @return the result of the algorithm
*/ */
private ExaremeAlgorithmResultDTO runMIPEngineExperiment(ExperimentDTO experimentDTO, Logger logger) { private ExaremeAlgorithmResultDTO runExareme2Experiment(ExperimentDTO experimentDTO, Logger logger) {
String algorithmName = experimentDTO.getAlgorithm().getName(); String algorithmName = experimentDTO.getAlgorithm().getName();
logger.LogUserAction("Starting MIP-Engine algorithm execution, algorithm: " + algorithmName); logger.LogUserAction("Starting Exareme2 algorithm execution, algorithm: " + algorithmName);
String algorithmEndpoint = mipengineAlgorithmsUrl + "/" + algorithmName.toLowerCase(); String algorithmEndpoint = exareme2AlgorithmsUrl + "/" + algorithmName.toLowerCase();
MIPEngineAlgorithmRequestDTO mipEngineAlgorithmRequestDTO = Exareme2AlgorithmRequestDTO exareme2AlgorithmRequestDTO =
new MIPEngineAlgorithmRequestDTO(experimentDTO.getUuid(), experimentDTO.getAlgorithm().getParameters()); new Exareme2AlgorithmRequestDTO(experimentDTO.getUuid(), experimentDTO.getAlgorithm().getParameters(), experimentDTO.getAlgorithm().getPreprocessing());
String algorithmBody = JsonConverters.convertObjectToJsonString(mipEngineAlgorithmRequestDTO); String algorithmBody = JsonConverters.convertObjectToJsonString(exareme2AlgorithmRequestDTO);
logger.LogUserAction("MIP-Engine algorithm execution. Endpoint: " + algorithmEndpoint); logger.LogUserAction("Exareme2 algorithm execution. Endpoint: " + algorithmEndpoint);
logger.LogUserAction("MIP-Engine algorithm execution. Body: " + algorithmBody); logger.LogUserAction("Exareme2 algorithm execution. Body: " + algorithmBody);
StringBuilder requestResponseBody = new StringBuilder(); StringBuilder requestResponseBody = new StringBuilder();
int requestResponseCode; int requestResponseCode;
...@@ -527,9 +551,9 @@ public class ExperimentService { ...@@ -527,9 +551,9 @@ public class ExperimentService {
List<Object> exaremeAlgorithmResult = new ArrayList<>(); List<Object> exaremeAlgorithmResult = new ArrayList<>();
if (requestResponseCode == 200) { if (requestResponseCode == 200) {
Object mipEngineResult = Object exareme2Result =
JsonConverters.convertJsonStringToObject(String.valueOf(requestResponseBody), Object.class); JsonConverters.convertJsonStringToObject(String.valueOf(requestResponseBody), Object.class);
exaremeAlgorithmResult.add(mipEngineResult); exaremeAlgorithmResult.add(exareme2Result);
} else if (requestResponseCode == 400) { } else if (requestResponseCode == 400) {
Map<String, Object> exaremeAlgorithmResultElement = new HashMap<>(); Map<String, Object> exaremeAlgorithmResultElement = new HashMap<>();
...@@ -565,7 +589,7 @@ public class ExperimentService { ...@@ -565,7 +589,7 @@ public class ExperimentService {
} else { } else {
logger.LogUserAction( logger.LogUserAction(
"MIP-Engine execution responded with an unexpected status code: " + requestResponseCode "Exareme2 execution responded with an unexpected status code: " + requestResponseCode
); );
throw new InternalServerError(""); throw new InternalServerError("");
} }
......
...@@ -35,7 +35,7 @@ spring: ...@@ -35,7 +35,7 @@ spring:
### EXTERNAL SERVICES ### ### EXTERNAL SERVICES ###
services: services:
algorithmsUpdateInterval: 100 algorithmsUpdateInterval: 100
mipengine: exareme2:
algorithmsUrl: "http://127.0.0.1:5000/algorithms" algorithmsUrl: "http://127.0.0.1:5000/algorithms"
attributesUrl: "http://127.0.0.1:5000/data_models_attributes" attributesUrl: "http://127.0.0.1:5000/data_models_attributes"
cdesMetadataUrl: "http://127.0.0.1:5000/cdes_metadata" cdesMetadataUrl: "http://127.0.0.1:5000/cdes_metadata"
......