Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NearestNeighboursServer logging improvements #4272

Merged
merged 3 commits into from Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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