Search in sources :

Example 1 with Expectation

use of io.hops.hopsworks.common.featurestore.datavalidation.Expectation in project hopsworks by logicalclocks.

the class FeatureStoreExpectationsResource method createExpectation.

@ApiOperation(value = "Create feature store expectation.", response = ExpectationDTO.class)
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response createExpectation(Expectation expectation, @Context SecurityContext sc, @Context UriInfo uriInfo) throws FeaturestoreException {
    // Workaround to ignore the list initialized from a json like {legalValues: null}
    if (expectation.getRules() != null && !expectation.getRules().isEmpty()) {
        expectation.getRules().stream().filter(rule -> rule.getLegalValues() != null && rule.getLegalValues().size() == 1 && rule.getLegalValues().get(0) == null).forEach(rule -> rule.setLegalValues(null));
    }
    FeatureStoreExpectation featureStoreExpectation = featureGroupValidationsController.createOrUpdateExpectation(featurestore, new io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.Expectation(expectation.getName(), expectation.getDescription(), expectation.getFeatures(), expectation.getRules()));
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXPECTATIONS);
    ExpectationDTO dto = featureStoreExpectationsBuilder.build(uriInfo, resourceRequest, project, featurestore, featureStoreExpectation);
    return Response.ok().entity(dto).build();
}
Also used : PathParam(javax.ws.rs.PathParam) Expectation(io.hops.hopsworks.common.featurestore.datavalidation.Expectation) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) Path(javax.ws.rs.Path) SecurityContext(javax.ws.rs.core.SecurityContext) ApiParam(io.swagger.annotations.ApiParam) ExpectationDTO(io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO) Project(io.hops.hopsworks.persistence.entity.project.Project) FeatureGroupValidationsController(io.hops.hopsworks.common.featurestore.datavalidation.FeatureGroupValidationsController) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles) ApiOperation(io.swagger.annotations.ApiOperation) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) MediaType(javax.ws.rs.core.MediaType) TransactionAttributeType(javax.ejb.TransactionAttributeType) Consumes(javax.ws.rs.Consumes) FeaturestoreController(io.hops.hopsworks.common.featurestore.FeaturestoreController) TransactionAttribute(javax.ejb.TransactionAttribute) ApiScope(io.hops.hopsworks.persistence.entity.user.security.apiKey.ApiScope) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) Api(io.swagger.annotations.Api) FeaturestoreDTO(io.hops.hopsworks.common.featurestore.FeaturestoreDTO) EJB(javax.ejb.EJB) DELETE(javax.ws.rs.DELETE) Audience(io.hops.hopsworks.api.filter.Audience) Context(javax.ws.rs.core.Context) Pagination(io.hops.hopsworks.api.util.Pagination) Featurestore(io.hops.hopsworks.persistence.entity.featurestore.Featurestore) BeanParam(javax.ws.rs.BeanParam) Response(javax.ws.rs.core.Response) RequestScoped(javax.enterprise.context.RequestScoped) FeatureStoreExpectation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureStoreExpectation) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) FeatureStoreExpectation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureStoreExpectation) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ExpectationDTO(io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO) 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) PUT(javax.ws.rs.PUT)

Aggregations

ExpectationDTO (io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO)1 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)1 Audience (io.hops.hopsworks.api.filter.Audience)1 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)1 Pagination (io.hops.hopsworks.api.util.Pagination)1 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)1 FeaturestoreController (io.hops.hopsworks.common.featurestore.FeaturestoreController)1 FeaturestoreDTO (io.hops.hopsworks.common.featurestore.FeaturestoreDTO)1 Expectation (io.hops.hopsworks.common.featurestore.datavalidation.Expectation)1 FeatureGroupValidationsController (io.hops.hopsworks.common.featurestore.datavalidation.FeatureGroupValidationsController)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)1 Featurestore (io.hops.hopsworks.persistence.entity.featurestore.Featurestore)1 FeatureStoreExpectation (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureStoreExpectation)1 Project (io.hops.hopsworks.persistence.entity.project.Project)1 ApiScope (io.hops.hopsworks.persistence.entity.user.security.apiKey.ApiScope)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 EJB (javax.ejb.EJB)1