Fixes for remote UI (#242)

Signed-off-by: AlexDBlack <blacka101@gmail.com>
master
Alex Black 2019-09-05 17:55:52 +10:00 committed by GitHub
parent 52d2795193
commit 45017ec914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 7 deletions

View File

@ -19,23 +19,20 @@ package org.deeplearning4j.ui.module.remote;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.deeplearning4j.api.storage.*; import org.deeplearning4j.api.storage.*;
import org.deeplearning4j.ui.api.FunctionType;
import org.deeplearning4j.ui.api.HttpMethod; import org.deeplearning4j.ui.api.HttpMethod;
import org.deeplearning4j.ui.api.Route; import org.deeplearning4j.ui.api.Route;
import org.deeplearning4j.ui.api.UIModule; import org.deeplearning4j.ui.api.UIModule;
import org.deeplearning4j.ui.i18n.I18NResource; import org.deeplearning4j.ui.i18n.I18NResource;
import play.mvc.Http;
import play.mvc.Result; import play.mvc.Result;
import play.mvc.Results; import play.mvc.Results;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
import java.io.File;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import static play.mvc.Http.Context.Implicit.request;
/** /**
* *
* Used to receive UI updates remotely. * Used to receive UI updates remotely.
@ -73,7 +70,7 @@ public class RemoteReceiverModule implements UIModule {
@Override @Override
public List<Route> getRoutes() { public List<Route> getRoutes() {
Route r = new Route("/remoteReceive", HttpMethod.POST, FunctionType.Supplier, this::receiveData); Route r = Route.request0Function("/remoteReceive", HttpMethod.POST, this::receiveData);
return Collections.singletonList(r); return Collections.singletonList(r);
} }
@ -98,7 +95,7 @@ public class RemoteReceiverModule implements UIModule {
return Collections.emptyList(); return Collections.emptyList();
} }
private Result receiveData() { private Result receiveData(Http.Request request) {
if (!enabled.get()) { if (!enabled.get()) {
return Results.forbidden( return Results.forbidden(
"UI server remote listening is currently disabled. Use UIServer.getInstance().enableRemoteListener()"); "UI server remote listening is currently disabled. Use UIServer.getInstance().enableRemoteListener()");
@ -109,7 +106,7 @@ public class RemoteReceiverModule implements UIModule {
"UI Server remote listener: no StatsStorage instance is set/available to store results"); "UI Server remote listener: no StatsStorage instance is set/available to store results");
} }
JsonNode jn = request().body().asJson(); JsonNode jn = request.body().asJson();
JsonNode type = jn.get("type"); JsonNode type = jn.get("type");
JsonNode dataClass = jn.get("class"); JsonNode dataClass = jn.get("class");
JsonNode data = jn.get("data"); JsonNode data = jn.get("data");