Search in sources :

Example 1 with NatNum32

use of edu.rice.cs.caper.programming.numbers.NatNum32 in project bayou by capergroup.

the class ApiSynthesisHealthCheckServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
    _logger.debug("entering");
    /*
         * Perform a generic API synth call and check that no exceptions are generated and that at least one result
         * is found. If so return HTTP status 200. Otherwise, 500.
         */
    try {
        String code = "import edu.rice.cs.caper.bayou.annotations.Evidence;\n" + "\n" + "public class TestIO1 {\n" + "\n" + "    // Read from a file\n" + "    void read(String file) {\n" + "        Evidence.apicalls(\"readLine\");\n" + "    }   \n" + "}";
        Iterable<String> results = _synthesisRequestProcessor.synthesise(code, new NatNum32(1));
        if (!results.iterator().hasNext()) {
            _logger.error("health check failed due to empty results.");
            resp.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
        }
        resp.getWriter().write("Ok.");
    } catch (Throwable e) {
        _logger.error("health check failed due to exception", e);
        resp.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500);
    }
    _logger.debug("exiting");
}
Also used : NatNum32(edu.rice.cs.caper.programming.numbers.NatNum32)

Example 2 with NatNum32

use of edu.rice.cs.caper.programming.numbers.NatNum32 in project bayou by capergroup.

the class ApiSynthesizerFactory method makeFromConfig.

/**
 * @return a synthesiser in accordance with edu.rice.cs.caper.bayou.application.api_synthesis_server.Configuration
 */
static ApiSynthesizer makeFromConfig() {
    _logger.debug("entering");
    ApiSynthesizer synthesizer;
    if (Configuration.UseSynthesizeEchoMode) {
        synthesizer = new ApiSynthesizerEcho(Configuration.EchoModeDelayMs);
    } else {
        ContentString tensorFlowHost = new ContentString(Configuration.AstServerAuthority.split(":")[0]);
        NatNum32 tensorFlowPort = new NatNum32(Configuration.AstServerAuthority.split(":")[1]);
        synthesizer = new ApiSynthesizerRemoteTensorFlowAsts(tensorFlowHost, tensorFlowPort, Configuration.SynthesizeTimeoutMs, Configuration.EvidenceClasspath, Configuration.AndroidJarPath, Configuration.ApiSynthMode);
    }
    _logger.debug("exiting");
    return synthesizer;
}
Also used : ContentString(edu.rice.cs.caper.programming.ContentString) ApiSynthesizerEcho(edu.rice.cs.caper.bayou.application.api_synthesis_server.synthesis.ApiSynthesizerEcho) NatNum32(edu.rice.cs.caper.programming.numbers.NatNum32) ApiSynthesizerRemoteTensorFlowAsts(edu.rice.cs.caper.bayou.application.api_synthesis_server.synthesis.ApiSynthesizerRemoteTensorFlowAsts) ApiSynthesizer(edu.rice.cs.caper.bayou.application.api_synthesis_server.synthesis.ApiSynthesizer)

Example 3 with NatNum32

use of edu.rice.cs.caper.programming.numbers.NatNum32 in project bayou by capergroup.

the class SynthesisRequest method make.

static SynthesisRequest make(JSONObject jsonMessage) throws NoCodeFieldException, NoMaxProgramCountFieldException, InvalidMaxProgramCountException, InvalidSampleCountException {
    final String CODE = "code";
    if (!jsonMessage.has(CODE))
        throw new NoCodeFieldException();
    String code = jsonMessage.get(CODE).toString();
    NatNum32 maxProgramCount;
    try {
        final String MAX_PROGRAM_COUNT = "max program count";
        if (!jsonMessage.has(MAX_PROGRAM_COUNT))
            throw new NoMaxProgramCountFieldException();
        maxProgramCount = new NatNum32(jsonMessage.get(MAX_PROGRAM_COUNT).toString());
    } catch (IllegalArgumentException e) {
        throw new InvalidMaxProgramCountException();
    }
    return new SynthesisRequest() {

        @Override
        public String getCode() {
            return code;
        }

        @Override
        public NatNum32 getMaxProgramCount() {
            return maxProgramCount;
        }
    };
}
Also used : NatNum32(edu.rice.cs.caper.programming.numbers.NatNum32)

Aggregations

NatNum32 (edu.rice.cs.caper.programming.numbers.NatNum32)3 ApiSynthesizer (edu.rice.cs.caper.bayou.application.api_synthesis_server.synthesis.ApiSynthesizer)1 ApiSynthesizerEcho (edu.rice.cs.caper.bayou.application.api_synthesis_server.synthesis.ApiSynthesizerEcho)1 ApiSynthesizerRemoteTensorFlowAsts (edu.rice.cs.caper.bayou.application.api_synthesis_server.synthesis.ApiSynthesizerRemoteTensorFlowAsts)1 ContentString (edu.rice.cs.caper.programming.ContentString)1