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;
}
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();
}
Aggregations