Skip to content

Commit

Permalink
Release v1.3.0 (PR #146)
Browse files Browse the repository at this point in the history
Merging release/1.3.0 into master
  • Loading branch information
kvndrsslr authored Feb 21, 2018
2 parents 09e4ffe + ebc4e6a commit 50de898
Show file tree
Hide file tree
Showing 57 changed files with 1,739 additions and 1,024 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ WORKDIR /limes
COPY --from=builder /limes/limes.jar limes.jar
# set default java flags
ENV JAVA_OPTS="-Xmx2G"
# expose port
EXPOSE 8080
# assign start command
CMD ["java", "-jar", "limes.jar", "-s"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# LIMES - Link Discovery Framework for Metric Spaces.

[![Build Status](https://travis-ci.org/dice-group/LIMES.svg?branch=master)](https://travis-ci.org/dice-group/LIMES) [![Join the chat at https://gitter.im/dice_limes/Lobby](https://badges.gitter.im/dice_limes/Lobby.svg)](https://gitter.im/dice_limes/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/dice-group/LIMES.svg?branch=dev)](https://travis-ci.org/dice-group/LIMES)

Development branch for LIMES - Link Discovery Framework for Metric Spaces.

## Generating Jar File (Headless)
installing use:
Expand Down
19 changes: 0 additions & 19 deletions git-hooks/pre-push

This file was deleted.

2 changes: 0 additions & 2 deletions git-hooks/setup.sh

This file was deleted.

36 changes: 7 additions & 29 deletions limes-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.aksw.limes</groupId>
<artifactId>limes-full</artifactId>
<version>1.2.4</version>
<version>1.3.0</version>
</parent>

<scm>
Expand Down Expand Up @@ -95,17 +95,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<version>2.20.1</version>
<configuration>
<forkMode>pertest</forkMode>
<argLine>${argLine} -Xms256m -Xmx512m</argLine>
<argLine>@{argLine} -Xms256m -Xmx512m</argLine>
<testFailureIgnore>false</testFailureIgnore>
<skipTests>false</skipTests>
<useManifestOnlyJar>false</useManifestOnlyJar>
<!-- used to debug one only package via CLI (mvn test -DtestGroup=org/aksw/limes/...) -->
<!-- <includes>
<include>**/${testGroup}/*Test.java</include>
</includes> -->
</configuration>
</plugin>

Expand Down Expand Up @@ -140,28 +136,10 @@
</configuration>
</plugin>

<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution><!-- symlink hooks to git -->
<id>Git-Hooks-Setup</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/../git-hooks/setup.sh</executable>
<workingDirectory>${basedir}/../git-hooks</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<version>3.0.0</version>
<executions>
<execution>
<id>validate</id>
Expand Down Expand Up @@ -207,7 +185,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
Expand All @@ -223,12 +201,12 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.3</version>
<version>3.0.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.6</version>
<version>3.9.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import org.aksw.limes.core.execution.planning.planner.ExecutionPlannerFactory;
import org.aksw.limes.core.execution.rewriter.RewriterFactory;
//import org.aksw.limes.core.gui.LimesGUI;
import org.aksw.limes.core.io.cache.ACache;
import org.aksw.limes.core.io.cache.HybridCache;
import org.aksw.limes.core.io.cache.MemoryCache;
import org.aksw.limes.core.io.config.Configuration;
import org.aksw.limes.core.io.config.reader.AConfigurationReader;
import org.aksw.limes.core.io.config.reader.rdf.RDFConfigurationReader;
Expand All @@ -28,17 +30,20 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.function.Function;

/**
* This is the default LIMES Controller used to run the software as CLI.
*
* @author Kevin Dreßler
*/
public class Controller {

public static final String DEFAULT_LOGGING_PATH = "limes.log";
private static final String DEFAULT_LOGGING_PATH = "limes.log";
private static final int MAX_ITERATIONS_NUMBER = 10;
private static Logger logger = null;
private static int serverPort = 8080;
private static int defaultPort = 8080;
private static int defaultLimit = -1;
private static Options options = getOptions();

/**
Expand All @@ -61,9 +66,11 @@ public static void main(String[] args) {
// LimesGUI.startGUI(new String[0]);
// System.exit(0);
} else if (cmd.hasOption('s')){
int port = serverPort;
int port = defaultPort;
if (cmd.hasOption('p')) port = Integer.parseInt(cmd.getOptionValue('p'));
SimpleServer.startServer(port);
int limit = defaultLimit;
if (cmd.hasOption('l')) limit = Integer.parseInt(cmd.getOptionValue('l'));
SimpleServer.startServer(port, limit);
} else {
// III. Has Arguments?
if (cmd.getArgs().length < 1) {
Expand All @@ -78,7 +85,7 @@ public static void main(String[] args) {
}
}

public static CommandLine parseCommandLine(String[] args) {
private static CommandLine parseCommandLine(String[] args) {
CommandLineParser parser = new BasicParser();
CommandLine cl = null;
try {
Expand Down Expand Up @@ -135,13 +142,27 @@ public static Configuration getConfig(CommandLine cmd) {
*
*/
public static ResultMappings getMapping(Configuration config) {
return getMapping(config, -1);
}


static ResultMappings getMapping(Configuration config, int limit) {
if (logger == null)
logger = LoggerFactory.getLogger(Controller.class);
AMapping results = null;

// 3. Fill Caches
HybridCache sourceCache = HybridCache.getData(config.getSourceInfo());
HybridCache targetCache = HybridCache.getData(config.getTargetInfo());
ACache sourceCache = HybridCache.getData(config.getSourceInfo());
ACache targetCache = HybridCache.getData(config.getTargetInfo());
if (limit > 0) {
Function<ACache, ACache> getSubCache = c -> {
ACache reducedCache = new MemoryCache();
c.getAllInstances().subList(0, limit).forEach(reducedCache::addInstance);
return reducedCache;
};
sourceCache = getSubCache.apply(sourceCache);
targetCache = getSubCache.apply(targetCache);
}

// 4. Machine Learning or Planning
StopWatch stopWatch = new StopWatch();
Expand Down Expand Up @@ -202,7 +223,7 @@ private static Options getOptions() {
options.addOption("f", true, "Optionally configure format of <config_file_or_uri>, either \"xml\" (default) or " +
"\"rdf\". If not specified, LIMES tries to infer the format from file ending.");
options.addOption("p", true, "Optionally configure HTTP server port. Only effective if -s is specified. Default port is 8080.");
// options.addOption("s", false, "Silent run");
options.addOption("l", true, "Optionally configure a limit for source and target resources processed by LIMES Server. Only effective if -s is specified. Default value is -1 (no limit).");
// options.addOption("v", false, "Verbose run");
return options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static AMapping execute(
mls.init(learningParameters, source, target);
mls.getMl().setConfiguration(configuration);
mlm = mls.learn(trainingDataMap);
logger.info(mlm.getLinkSpecification().toStringOneLine());
logger.info("Learned: " + mlm.getLinkSpecification().getFullExpression() + " with threshold: " + mlm.getLinkSpecification().getThreshold());
return mls.predict(source, target, mlm);
case SUPERVISED_ACTIVE:
// for active learning, need to reiterate and prompt the user for evaluation of examples:
Expand Down Expand Up @@ -109,6 +109,7 @@ public static AMapping execute(
}
mlm = mla.activeLearn(nextExamples);
}
logger.info("Learned: " + mlm.getLinkSpecification().getFullExpression() + " with threshold: " + mlm.getLinkSpecification().getThreshold());
return mla.predict(source, target, mlm);
case UNSUPERVISED:
UnsupervisedMLAlgorithm mlu = new UnsupervisedMLAlgorithm(clazz);
Expand All @@ -119,6 +120,7 @@ public static AMapping execute(
pfm = (PseudoFMeasure) EvaluatorFactory.create(pfmType);
}
mlm = mlu.learn(pfm);
logger.info("Learned: " + mlm.getLinkSpecification().getFullExpression() + " with threshold: " + mlm.getLinkSpecification().getThreshold());
return mlu.predict(source, target, mlm);
default:
throw new UnsupportedMLImplementationException(clazz.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public class SimpleServer {
private static final String LOCK_DIR_PATH = "/lock/";
private static final String QUERY_PARAM_RESULT_TYPE = "result_type";
private static final String QUERY_PARAM_JOB_ID = "job_id";
public static final String CONFIG_FILE_PREFIX = "limes_server_cfg_";
private static final String CONFIG_FILE_PREFIX = "limes_server_cfg_";
private static ConcurrentMap<Long, Integer> jobs = new ConcurrentHashMap<>();
private static int limit;

public static void startServer(int port) {
public static void startServer(int port, int limit) {
SimpleServer.limit = limit;
HttpServer server = null;
logger.info("Attempting to start LIMES server at port " + port + "...");
try {
Expand All @@ -54,10 +56,16 @@ public static void startServer(int port) {
logger.info("Server has been started! Waiting for requests...");
}

private static void addCORSHeaders(Headers headers) {
headers.add("Access-Control-Allow-Origin", "*");
headers.add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
}

private static class ExecuteHandler implements HttpHandler {

@Override
public void handle(HttpExchange t) throws IOException {
addCORSHeaders(t.getResponseHeaders());
if (t.getRequestMethod().equals("POST")) {
Headers headers = t.getRequestHeaders();
String boundary = "boundary=";
Expand All @@ -79,7 +87,7 @@ public void handle(HttpExchange t) throws IOException {
AConfigurationReader reader = new XMLConfigurationReader(STORAGE_DIR_PATH + CONFIG_FILE_PREFIX + id + ".xml");
Configuration config = reader.read();
jobs.put(Long.parseLong(id), 1);
ResultMappings mappings = Controller.getMapping(config);
ResultMappings mappings = Controller.getMapping(config, limit);
String outputFormat = config.getOutputFormat();
ISerializer output = SerializerFactory.createSerializer(outputFormat);
output.setPrefixes(config.getPrefixes());
Expand All @@ -100,6 +108,10 @@ public void handle(HttpExchange t) throws IOException {
_acceptanceFile.renameTo(acceptanceFile);
lockDir.delete();
jobs.put(Long.parseLong(id), 2);
} else if (t.getRequestMethod().equals("OPTIONS")) {
// we only accept POST requests here, anything else gets code "405 - Method Not Allowed"
t.sendResponseHeaders(200 ,-1);
logger.info("Replied to OPTIONS request");
} else {
// we only accept POST requests here, anything else gets code "405 - Method Not Allowed"
t.sendResponseHeaders(405 ,-1);
Expand Down Expand Up @@ -132,6 +144,7 @@ private static class GetResultHandler implements HttpHandler {

@Override
public void handle(HttpExchange t) throws IOException {
addCORSHeaders(t.getResponseHeaders());
if (t.getRequestMethod().equals("GET")) {
Map<String, String> params = queryToMap(t.getRequestURI().getRawQuery());
if (params.containsKey(QUERY_PARAM_JOB_ID) && params.containsKey(QUERY_PARAM_RESULT_TYPE) &&
Expand Down Expand Up @@ -186,6 +199,11 @@ public void handle(HttpExchange t) throws IOException {
t.sendResponseHeaders(400 ,-1);
logger.info("Bad request: " + t.getRequestURI() + "\nPlease specify job_id and result_type query parameters!");
}

} else if (t.getRequestMethod().equals("OPTIONS")) {
// we only accept POST requests here, anything else gets code "405 - Method Not Allowed"
t.sendResponseHeaders(200 ,-1);
logger.info("Replied to OPTIONS request");
} else {
// we only accept GET requests here, anything else gets code "405 - Method Not Allowed"
t.sendResponseHeaders(405 ,-1);
Expand All @@ -198,6 +216,7 @@ private static class GetStatusHandler implements HttpHandler {

@Override
public void handle(HttpExchange t) throws IOException {
addCORSHeaders(t.getResponseHeaders());
if (t.getRequestMethod().equals("GET")) {
Map<String, String> params = queryToMap(t.getRequestURI().getRawQuery());
if (params.containsKey(QUERY_PARAM_JOB_ID)) {
Expand Down Expand Up @@ -226,6 +245,10 @@ public void handle(HttpExchange t) throws IOException {
t.sendResponseHeaders(400, -1);
logger.info("Bad request: " + t.getRequestURI() + "\nPlease specify job_id query parameters!");
}
} else if (t.getRequestMethod().equals("OPTIONS")) {
// we only accept POST requests here, anything else gets code "405 - Method Not Allowed"
t.sendResponseHeaders(200 ,-1);
logger.info("Replied to OPTIONS request");
} else {
// we only accept GET requests here, anything else gets code "405 - Method Not Allowed"
t.sendResponseHeaders(405, -1);
Expand All @@ -234,24 +257,24 @@ public void handle(HttpExchange t) throws IOException {
}
}

public static Map<String, String> queryToMap(String query){
Map<String, String> result = new HashMap<>();
if (query == null)
return result;
for (String param : query.split("&")) {
try {
param = java.net.URLDecoder.decode(param, "UTF-8");
String pair[] = param.split("=");
if (pair.length > 1) {
result.put(pair[0], pair[1]);
} else {
result.put(pair[0], "");
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
private static Map<String, String> queryToMap(String query){
Map<String, String> result = new HashMap<>();
if (query == null)
return result;
for (String param : query.split("&")) {
try {
param = java.net.URLDecoder.decode(param, "UTF-8");
String pair[] = param.split("=");
if (pair.length > 1) {
result.put(pair[0], pair[1]);
} else {
result.put(pair[0], "");
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}

return result;
}

}
Loading

0 comments on commit 50de898

Please sign in to comment.