Search in sources :

Example 1 with FrameSummary

use of water.api.Frames.FrameSummary in project h2o-2 by h2oai.

the class Models method serveOneOrAll.

/**
   * Fetch all the Models from the KV store, sumamrize and enhance them, and return a map of them.
   */
private Response serveOneOrAll(Map<String, Model> modelsMap) {
    // returns empty sets if !this.find_compatible_frames
    Pair<Map<String, Frame>, Map<String, Set<String>>> frames_info = fetchFrames();
    Map<String, Frame> all_frames = frames_info.getFirst();
    Map<String, Set<String>> all_frames_cols = frames_info.getSecond();
    Map<String, ModelSummary> modelSummaries = Models.generateModelSummaries(null, modelsMap, find_compatible_frames, all_frames, all_frames_cols);
    Map resultsMap = new LinkedHashMap();
    resultsMap.put("models", modelSummaries);
    // If find_compatible_frames then include a map of the Frame summaries.  Should we put this on a separate switch?
    if (this.find_compatible_frames) {
        Set<String> all_referenced_frames = new TreeSet<String>();
        for (Map.Entry<String, ModelSummary> entry : modelSummaries.entrySet()) {
            ModelSummary summary = entry.getValue();
            all_referenced_frames.addAll(summary.compatible_frames);
        }
        Map<String, FrameSummary> frameSummaries = Frames.generateFrameSummaries(all_referenced_frames, all_frames, false, null, null);
        resultsMap.put("frames", frameSummaries);
    }
    // TODO: temporary hack to get things going
    String json = gson.toJson(resultsMap);
    JsonObject result = gson.fromJson(json, JsonElement.class).getAsJsonObject();
    return Response.done(result);
}
Also used : Frame(water.fvec.Frame) JsonObject(dontweave.gson.JsonObject) FrameSummary(water.api.Frames.FrameSummary) JsonElement(dontweave.gson.JsonElement)

Aggregations

JsonElement (dontweave.gson.JsonElement)1 JsonObject (dontweave.gson.JsonObject)1 FrameSummary (water.api.Frames.FrameSummary)1 Frame (water.fvec.Frame)1