diff --git a/run b/run index 6a69628..eccca6a 100755 --- a/run +++ b/run @@ -1078,7 +1078,7 @@ addMode('int-utils', 'small commands like run community server, backup, or simul 'local' => o('serverURL', 'http://localhost:8410'), 'remote' => o('serverURL', 'http://jonsson.stanford.edu:8410') }), - o('logToFile', 0), # set to anything else to log stuff + o('sandbox', 1), # set to 0 to enable logging nil), }), nil) }) diff --git a/shrdlurn/README.md b/shrdlurn/README.md index 669977c..60b9c7e 100644 --- a/shrdlurn/README.md +++ b/shrdlurn/README.md @@ -1,4 +1,12 @@ - +Experimental work following +1) ./shrdlurn/runServer.sh to start both servers +2) Blast the server with simulator on previous logs, under sandbox mode, to get the server into state +3) Collect and append to more logs +4) For any particular experiment, save the previous log + - ./run @mode=int-utils @cmd=backup-mv + - reset the log +potentially reset citation and grammar information as well? +5) blast server with non-sandbox call to get previous citations Default port: 8410 for sempre, 8406 for user Run: ./run @mode=interactive -Server.port 8410 diff --git a/src/edu/stanford/nlp/sempre/JsonServer.java b/src/edu/stanford/nlp/sempre/JsonServer.java index fd84152..059fa5c 100644 --- a/src/edu/stanford/nlp/sempre/JsonServer.java +++ b/src/edu/stanford/nlp/sempre/JsonServer.java @@ -195,9 +195,9 @@ public class JsonServer { void handleQuery(String sessionId) throws IOException { String query = reqParams.get("q"); - boolean logToFile = true; // false when simulating - if (reqParams.containsKey("logtofile") && reqParams.get("logtofile").equals("0")) - logToFile = false; + boolean sandbox = false; // false when simulating + if (reqParams.containsKey("sandbox") && !reqParams.get("sandbox").equals("0")) + sandbox = true; String queryTime = LocalDateTime.now().toString(); { // write the query log @@ -208,9 +208,11 @@ public class JsonServer { // jsonMap.putAll(reqParams); jsonMap.put("remote", remoteHost); - boolean isContext = query.startsWith("(:context "); + + synchronized (queryLogLock) { - if (logToFile && (!isContext || opts.verbose >= 2)) { + boolean isContext = query.startsWith("(:context "); + if (!sandbox && (!isContext || opts.verbose >= 2)) { PrintWriter out = IOUtils.openOutAppend(opts.queryLogPath); out.println(Json.writeValueAsStringHard(jsonMap)); out.close(); @@ -225,7 +227,7 @@ public class JsonServer { session.remoteHost = remoteHost; session.format = "json"; // - session.logToFile = logToFile; + session.logToFile = sandbox; if (query == null) query = session.getLastQuery(); if (query == null) query = ""; @@ -258,7 +260,7 @@ public class JsonServer { jsonMap.put("q", query); // backwards compatability... jsonMap.put("lines", responseMap.get("lines")); synchronized (responseLogLock) { - if (logToFile) { + if (!sandbox) { { PrintWriter out = IOUtils.openOutAppend(opts.responseLogPath); out.println(Json.writeValueAsStringHard(jsonMap)); diff --git a/src/edu/stanford/nlp/sempre/Master.java b/src/edu/stanford/nlp/sempre/Master.java index 73e9a8e..97c0ac4 100644 --- a/src/edu/stanford/nlp/sempre/Master.java +++ b/src/edu/stanford/nlp/sempre/Master.java @@ -484,7 +484,7 @@ public class Master { if (match != null) { LogInfo.logs("Matched: %s", match); - if (session.logToFile) { + if (!session.sandbox) { CitationTracker tracker = new CitationTracker(session.id, ex); tracker.citeAll(match); } @@ -512,7 +512,7 @@ public class Master { response.ex = refExHead.value; // write out the grammar - if (session.logToFile) { + if (!session.sandbox) { PrintWriter out = IOUtils.openOutAppendHard(Paths.get(Master.opts.newGrammarPath, session.id + ".grammar").toString()); for (Rule rule : inducedRules) { out.println(rule.toLispTree().toStringWrap()); diff --git a/src/edu/stanford/nlp/sempre/Session.java b/src/edu/stanford/nlp/sempre/Session.java index 936df9f..79645a2 100644 --- a/src/edu/stanford/nlp/sempre/Session.java +++ b/src/edu/stanford/nlp/sempre/Session.java @@ -29,7 +29,7 @@ public class Session { Example lastEx; // Last example that we processed Params params; Learner learner; - boolean logToFile = true; + boolean sandbox = false; public static Options opts = new Options();