Skip to content
Snippets Groups Projects
Commit 26b0f3b3 authored by Ludovic Claude's avatar Ludovic Claude
Browse files

Fail to start if additional variables cannot be created from datasets

parent fe5cc972
No related branches found
No related tags found
1 merge request!3[pull] master from LREN-CHUV:master
package eu.hbp.mip;
import akka.actor.ActorRef;
import akka.cluster.Cluster;
import ch.chuv.lren.woken.messages.datasets.Dataset;
import com.google.gson.Gson;
import eu.hbp.mip.controllers.DatasetsApi;
......@@ -40,6 +38,8 @@ public class StartupTasks implements ApplicationListener<ApplicationReadyEvent>
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
boolean variablesRepositoryOk = false;
// Pre-fill the local variable repository with the list of datasets, interpreted here as variables
// (a bit like a categorical variable can be split into a set of variables (a.k.a one hot encoding in Data science) )
// Try 5 times, to be more robust in the face of cluster failures / slow startup
......@@ -49,17 +49,24 @@ public class StartupTasks implements ApplicationListener<ApplicationReadyEvent>
final String code = dataset.dataset().code();
Variable v = variableRepository.findOne(code);
if (v == null) {
LOGGER.info("Store additional variable {}", v.getCode());
v = new Variable(code);
variableRepository.save(v);
}
}
LOGGER.info("Datasets fetched from Woken");
variablesRepositoryOk = true;
break;
} catch (Exception e) {
variablesRepositoryOk = false;
LOGGER.error("Cannot initialise the variable repository. Is the connection to Woken working?", e);
}
}
if (!variablesRepositoryOk) {
System.exit(1);
}
/*
for (String variableJson: variablesApi.loadVariables()) {
String code = gson.fromJson(variableJson, Variable.class).getCode();
......
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