Skip to content

Commit

Permalink
Merge pull request #4272 from deeplearning4j/ab_knn
Browse files Browse the repository at this point in the history
NearestNeighboursServer logging improvements
  • Loading branch information
AlexDBlack committed Nov 13, 2017
2 parents c831b62 + 4bfdf13 commit d70537e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
Expand Up @@ -25,7 +25,23 @@
</configuration>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Ddtype=double</argLine>
<systemPropertyVariables>
<config.file>../../deeplearning4j-ui-parent/deeplearning4j-play/src/main/resources/application.conf</config.file>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>org.deeplearning4j</groupId>
Expand Down Expand Up @@ -117,5 +133,4 @@
<id>test-nd4j-cuda-8.0</id>
</profile>
</profiles>

</project>
Expand Up @@ -61,17 +61,31 @@ public void runMain(String... args) throws Exception {
try {
jcmdr.parse(args);
} catch (ParameterException e) {
log.error("Error in NearestNeighboursServer parameters", e);
StringBuilder sb = new StringBuilder();
jcmdr.usage(sb);
log.error("Usage: {}", sb.toString());

//User provides invalid input -> print the usage info
jcmdr.usage();
if (ndarrayPath == null)
System.err.println("Json path parameter is missing.");
log.error("Json path parameter is missing (null)");
try {
Thread.sleep(500);
} catch (Exception e2) {
}
System.exit(1);
}

try {
runHelper();
} catch (Throwable t){
log.error("Error in NearestNeighboursServer run method",t);
}
}

protected void runHelper() throws Exception {

String[] pathArr = ndarrayPath.split(",");
//INDArray[] pointsArr = new INDArray[pathArr.length];
// first of all we reading shapes of saved eariler files
Expand Down Expand Up @@ -138,9 +152,10 @@ else if (cols != Shape.size(shape, 1))

return ok(Json.toJson(results));

} catch (Exception e) {
} catch (Throwable e) {
log.error("Error in POST /knn",e);
e.printStackTrace();
return internalServerError();
return internalServerError(e.getMessage());
}
})));

Expand Down Expand Up @@ -182,9 +197,10 @@ else if (cols != Shape.size(shape, 1))
NearstNeighborsResults results2 = NearstNeighborsResults.builder().results(nnResult).build();
return ok(Json.toJson(results2));

} catch (Exception e) {
} catch (Throwable e) {
log.error("Error in POST /knnnew",e);
e.printStackTrace();
return internalServerError();
return internalServerError(e.getMessage());
}
})));

Expand All @@ -197,8 +213,10 @@ else if (cols != Shape.size(shape, 1))
* Stop the server
*/
public void stop() {
if (server != null)
if (server != null) {
log.info("Attempting to stop server");
server.stop();
}
}

public static void main(String[] args) throws Exception {
Expand Down

0 comments on commit d70537e

Please sign in to comment.