Search in sources :

Example 1 with ExperimentResultsDTO

use of io.hops.hopsworks.api.experiments.dto.results.ExperimentResultsDTO in project hopsworks by logicalclocks.

the class ExperimentResultsBuilder method build.

public ExperimentResultSummaryDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, String mlId) throws ExperimentsException {
    ExperimentResultSummaryDTO dto = new ExperimentResultSummaryDTO();
    uri(dto, uriInfo, project, mlId);
    expand(dto, resourceRequest);
    dto.setCount(0l);
    if (dto.isExpand()) {
        DistributedFileSystemOps dfso = null;
        try {
            dfso = dfs.getDfsOps();
            String summaryPath = Utils.getProjectPath(project.getName()) + Settings.HOPS_EXPERIMENTS_DATASET + "/" + mlId + "/.summary.json";
            if (dfso.exists(summaryPath)) {
                String summaryJson = dfso.cat(new Path(summaryPath));
                if (!Strings.isNullOrEmpty(summaryJson)) {
                    ExperimentResultsDTO[] results = experimentConverter.unmarshalResults(summaryJson).getCombinations();
                    if (results != null) {
                        dto.setCount((long) results.length);
                        results = apply(results, resourceRequest);
                        dto.setCombinations(results);
                    }
                }
            }
        } catch (Exception e) {
            throw new ExperimentsException(RESTCodes.ExperimentsErrorCode.RESULTS_RETRIEVAL_ERROR, Level.SEVERE, "Unable to get results for experiment", e.getMessage(), e);
        } finally {
            if (dfso != null) {
                dfs.closeDfsClient(dfso);
            }
        }
    }
    return dto;
}
Also used : Path(org.apache.hadoop.fs.Path) ExperimentResultsDTO(io.hops.hopsworks.api.experiments.dto.results.ExperimentResultsDTO) ExperimentsException(io.hops.hopsworks.exceptions.ExperimentsException) DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps) ExperimentsException(io.hops.hopsworks.exceptions.ExperimentsException) ExperimentResultSummaryDTO(io.hops.hopsworks.api.experiments.dto.results.ExperimentResultSummaryDTO)

Aggregations

ExperimentResultSummaryDTO (io.hops.hopsworks.api.experiments.dto.results.ExperimentResultSummaryDTO)1 ExperimentResultsDTO (io.hops.hopsworks.api.experiments.dto.results.ExperimentResultsDTO)1 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)1 ExperimentsException (io.hops.hopsworks.exceptions.ExperimentsException)1 Path (org.apache.hadoop.fs.Path)1