use of io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO in project hopsworks by logicalclocks.
the class TransformationFunctionResource method register.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Register transformation function in to a featurestore", response = TransformationFunctionDTO.class)
public Response register(@Context UriInfo uriInfo, @Context SecurityContext sc, TransformationFunctionDTO transformationFunctionDTO) throws IOException, FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
TransformationFunction transformationFunction = transformationFunctionController.register(user, project, featurestore, transformationFunctionDTO);
TransformationFunctionDTO newTransformationFunctionDTO = transformationFunctionBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.TRANSFORMATIONFUNCTIONS), user, project, featurestore, transformationFunction);
return Response.ok().entity(newTransformationFunctionDTO).build();
}
use of io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO in project hopsworks by logicalclocks.
the class TransformationFunctionBuilder method build.
public TransformationFunctionAttachedDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Users user, Project project, TrainingDataset trainingDataset, TrainingDatasetFeature tdFeature) throws FeaturestoreException {
TransformationFunctionAttachedDTO transformationFunctionAttachedDTO = new TransformationFunctionAttachedDTO();
TransformationFunctionDTO transformationFunctionDTO = new TransformationFunctionDTO(tdFeature.getTransformationFunction().getId(), tdFeature.getTransformationFunction().getName(), tdFeature.getTransformationFunction().getOutputType(), tdFeature.getTransformationFunction().getVersion(), transformationFunctionController.readContent(user, project, tdFeature.getTransformationFunction()), tdFeature.getTransformationFunction().getFeaturestore().getId());
transformationFunctionAttachedDTO.setHref(uri(uriInfo, project, trainingDataset.getFeaturestore(), trainingDataset));
transformationFunctionAttachedDTO.setExpand(expand(resourceRequest));
if (transformationFunctionAttachedDTO.isExpand()) {
transformationFunctionAttachedDTO.setName(trainingDatasetController.checkPrefix(tdFeature));
transformationFunctionAttachedDTO.setTransformationFunction(transformationFunctionDTO);
}
return transformationFunctionAttachedDTO;
}
use of io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO in project hopsworks by logicalclocks.
the class TransformationFunctionBuilder method build.
public TransformationFunctionDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Users user, Project project, Featurestore featurestore, TransformationFunction transformationFunction) throws FeaturestoreException {
TransformationFunctionDTO transformationFunctionDTO = new TransformationFunctionDTO();
transformationFunctionDTO.setHref(uri(uriInfo, project, featurestore));
transformationFunctionDTO.setExpand(expand(resourceRequest));
if (transformationFunctionDTO.isExpand()) {
transformationFunctionDTO.setId(transformationFunction.getId());
transformationFunctionDTO.setName(transformationFunction.getName());
transformationFunctionDTO.setOutputType(transformationFunction.getOutputType());
transformationFunctionDTO.setVersion(transformationFunction.getVersion());
transformationFunctionDTO.setFeaturestoreId(transformationFunction.getFeaturestore().getId());
transformationFunctionDTO.setSourceCodeContent(transformationFunctionController.readContent(user, project, transformationFunction));
}
return transformationFunctionDTO;
}
use of io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO in project hopsworks by logicalclocks.
the class TransformationFunctionResource method get.
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get transformation function DTO", response = TransformationFunctionDTO.class)
public Response get(@BeanParam Pagination pagination, @BeanParam TransformationFunctionsBeanParam transformationFunctionsBeanParam, @Context SecurityContext sc, @Context UriInfo uriInfo, @QueryParam("name") String name, @QueryParam("version") Integer version) throws FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TRANSFORMATIONFUNCTIONS);
resourceRequest.setSort(transformationFunctionsBeanParam.getSortBySet());
resourceRequest.setFilter(transformationFunctionsBeanParam.getFilter());
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(transformationFunctionsBeanParam.getSortBySet());
TransformationFunctionDTO transformationFunctionDTO = transformationFunctionBuilder.build(uriInfo, resourceRequest, user, project, featurestore, name, version);
return Response.ok().entity(transformationFunctionDTO).build();
}
use of io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO in project hopsworks by logicalclocks.
the class TransformationFunctionBuilder method build.
public TransformationFunctionDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Users user, Project project, Featurestore featurestore, String name, Integer version) throws FeaturestoreException {
Long counts;
List<TransformationFunction> transformationFunctions;
if (name != null) {
TransformationFunction transformationFunction;
if (version != null) {
transformationFunction = transformationFunctionFacade.findByNameVersionAndFeaturestore(name, version, featurestore).orElseThrow(() -> new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.TRANSFORMATION_FUNCTION_DOES_NOT_EXIST, Level.FINE, "Could not find transformation function with name " + name + " and version" + version));
} else {
transformationFunction = transformationFunctionFacade.findByNameVersionAndFeaturestore(name, 1, featurestore).orElseThrow(() -> new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.TRANSFORMATION_FUNCTION_DOES_NOT_EXIST, Level.FINE, "Could not find transformation function with name " + name + " and version" + 1));
}
transformationFunctions = Arrays.asList(transformationFunction);
counts = 1L;
} else {
AbstractFacade.CollectionInfo transformationFunction = transformationFunctionFacade.findByFeaturestore(resourceRequest.getOffset(), resourceRequest.getLimit(), resourceRequest.getFilter(), resourceRequest.getSort(), featurestore);
transformationFunctions = transformationFunction.getItems();
counts = transformationFunction.getCount();
}
TransformationFunctionDTO transformationFunctionDTO = new TransformationFunctionDTO();
transformationFunctionDTO.setHref(uri(uriInfo, project, featurestore));
transformationFunctionDTO.setExpand(expand(resourceRequest));
if (transformationFunctionDTO.isExpand()) {
List<TransformationFunctionDTO> list = new ArrayList<>();
for (TransformationFunction t : transformationFunctions) {
TransformationFunctionDTO build = build(uriInfo, resourceRequest, user, project, featurestore, t);
list.add(build);
}
transformationFunctionDTO.setItems(list);
transformationFunctionDTO.setCount(counts);
}
return transformationFunctionDTO;
}
Aggregations