Search in sources :

Example 1 with TransformationFunctionDTO

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();
}
Also used : TransformationFunctionDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) TransformationFunction(io.hops.hopsworks.persistence.entity.featurestore.transformationFunction.TransformationFunction) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 2 with TransformationFunctionDTO

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;
}
Also used : TransformationFunctionAttachedDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionAttachedDTO) TransformationFunctionDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO)

Example 3 with TransformationFunctionDTO

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;
}
Also used : TransformationFunctionDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO)

Example 4 with 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();
}
Also used : TransformationFunctionDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 5 with TransformationFunctionDTO

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;
}
Also used : TransformationFunctionDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO) AbstractFacade(io.hops.hopsworks.common.dao.AbstractFacade) ArrayList(java.util.ArrayList) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) TransformationFunction(io.hops.hopsworks.persistence.entity.featurestore.transformationFunction.TransformationFunction)

Aggregations

TransformationFunctionDTO (io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO)5 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)2 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)2 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)2 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)2 TransformationFunction (io.hops.hopsworks.persistence.entity.featurestore.transformationFunction.TransformationFunction)2 Users (io.hops.hopsworks.persistence.entity.user.Users)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Produces (javax.ws.rs.Produces)2 AbstractFacade (io.hops.hopsworks.common.dao.AbstractFacade)1 TransformationFunctionAttachedDTO (io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionAttachedDTO)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1