use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation in project hopsworks by logicalclocks.
the class FeatureGroupValidationsController method detachExpectation.
public void detachExpectation(Featuregroup featuregroup, String name) throws FeaturestoreException {
FeatureStoreExpectation featureStoreExpectation = getFeatureStoreExpectation(featuregroup.getFeaturestore(), name);
Optional<FeatureGroupExpectation> e = featureGroupExpectationFacade.findByFeaturegroupAndExpectation(featuregroup, featureStoreExpectation);
featureGroupExpectationFacade.remove(e.orElseThrow(() -> new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURE_GROUP_EXPECTATION_NOT_FOUND, FINE, "expectation: " + name)));
}
use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation in project hopsworks by logicalclocks.
the class FeatureGroupExpectationsResource method attachExpectation.
@ApiOperation(value = "Attach an expectation to a feature group.", response = ExpectationDTO.class)
@PUT
@Path("/{name}")
@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 attachExpectation(@ApiParam(value = "name of the expectation", required = true) @PathParam("name") String name, @Context SecurityContext sc, @Context UriInfo uriInfo) throws FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
FeatureGroupExpectation expectation = featureGroupValidationsController.attachExpectation(featuregroup, name, project, user);
ExpectationDTO dto = featureStoreExpectationsBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.EXPECTATIONS), project, featurestore, expectation.getFeatureStoreExpectation());
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation in project hopsworks by logicalclocks.
the class FeatureGroupExpectationsResource method get.
@ApiOperation(value = "Fetch a specific data validation rule", response = ExpectationDTO.class)
@GET
@Path("/{name}")
@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 get(@ApiParam(value = "name of the expectation", required = true) @PathParam("name") String name, @BeanParam FeatureGroupExpectationsBeanParam featureGroupExpectationsBeanParam, @Context SecurityContext sc, @Context UriInfo uriInfo) throws FeaturestoreException {
FeatureGroupExpectation expectation = featureGroupValidationsController.getFeatureGroupExpectation(featuregroup, name);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXPECTATIONS);
resourceRequest.setField(featureGroupExpectationsBeanParam.getFieldSet());
ExpectationDTO dto = featureStoreExpectationsBuilder.build(uriInfo, resourceRequest, project, featuregroup, expectation);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation in project hopsworks by logicalclocks.
the class FeatureStoreExpectationsBuilder method build.
public ExpectationDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, Featuregroup featuregroup) {
ExpectationDTO dto = new ExpectationDTO();
uri(dto, uriInfo, project, featuregroup);
expand(dto, resourceRequest);
if (dto.isExpand()) {
AbstractFacade.CollectionInfo collectionInfo = featureGroupExpectationFacade.findByFeaturegroup(resourceRequest.getOffset(), resourceRequest.getLimit(), resourceRequest.getFilter(), resourceRequest.getSort(), featuregroup);
List<FeatureGroupExpectation> featureGroupExpectations = collectionInfo.getItems();
for (FeatureGroupExpectation featureGroupExpectation : featureGroupExpectations) {
dto.addItem(build(uriInfo, resourceRequest, project, featuregroup, featureGroupExpectation));
}
}
if (dto.getItems() == null) {
dto.setCount(0L);
} else {
dto.setCount((long) dto.getItems().size());
}
return dto;
}
Aggregations