Search in sources :

Example 1 with ExperimentResultSummaryDTO

use of io.hops.hopsworks.api.experiments.dto.results.ExperimentResultSummaryDTO 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)

Example 2 with ExperimentResultSummaryDTO

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

the class ExperimentResultsResource method getResults.

@ApiOperation(value = "Get results information", response = ExperimentResultSummaryDTO.class)
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getResults(@Context UriInfo uriInfo, @BeanParam Pagination pagination, @BeanParam ExperimentResultsBeanParam experimentResultsBeanParam, @Context SecurityContext sc) throws ExperimentsException {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.RESULTS);
    resourceRequest.setOffset(pagination.getOffset());
    resourceRequest.setLimit(pagination.getLimit());
    resourceRequest.setSort(experimentResultsBeanParam.getSortBySet());
    ExperimentResultSummaryDTO dto = experimentResultsBuilder.build(uriInfo, resourceRequest, project, experimentId);
    if (dto == null) {
        throw new ExperimentsException(RESTCodes.ExperimentsErrorCode.RESULTS_NOT_FOUND, Level.FINE);
    }
    return Response.ok().entity(dto).build();
}
Also used : ExperimentsException(io.hops.hopsworks.exceptions.ExperimentsException) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ExperimentResultSummaryDTO(io.hops.hopsworks.api.experiments.dto.results.ExperimentResultSummaryDTO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Aggregations

ExperimentResultSummaryDTO (io.hops.hopsworks.api.experiments.dto.results.ExperimentResultSummaryDTO)2 ExperimentsException (io.hops.hopsworks.exceptions.ExperimentsException)2 ExperimentResultsDTO (io.hops.hopsworks.api.experiments.dto.results.ExperimentResultsDTO)1 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)1 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)1 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)1 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)1 ApiOperation (io.swagger.annotations.ApiOperation)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 Path (org.apache.hadoop.fs.Path)1