Search in sources :

Example 1 with FeatureGroupCommit

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit in project hopsworks by logicalclocks.

the class CommitResource method commitFeatureGroup.

@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Commit to Feature Group", response = CommitDTO.class)
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response commitFeatureGroup(@Context UriInfo uriInfo, CommitDTO commitDTO, @Context SecurityContext sc) throws FeaturestoreException {
    Users user = jwtHelper.getUserPrincipal(sc);
    FeatureGroupCommit featureGroupCommit = featureGroupCommitController.createHudiFeatureGroupCommit(user, featuregroup, commitDTO.getCommitDateString(), commitDTO.getCommitTime(), commitDTO.getRowsUpdated(), commitDTO.getRowsInserted(), commitDTO.getRowsDeleted(), commitDTO.getValidationId());
    CommitDTO builtCommitDTO = commitBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.COMMITS), project, featuregroup, featureGroupCommit);
    return Response.ok().entity(builtCommitDTO).build();
}
Also used : Users(io.hops.hopsworks.persistence.entity.user.Users) FeatureGroupCommit(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) 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 FeatureGroupCommit

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit in project hopsworks by logicalclocks.

the class CodeController method registerCode.

public FeaturestoreCode registerCode(Project project, Users user, Long codeCommitTimeStamp, Long fgCommitId, String applicationId, Featuregroup featuregroup, String entityId, String databricksNotebook, byte[] databricksArchive, CodeActions.RunType type) throws ServiceException, FeaturestoreException {
    Inode codeInode = saveCode(project, user, applicationId, featuregroup, entityId, databricksNotebook, databricksArchive, type);
    Timestamp commitTime = new Timestamp(codeCommitTimeStamp);
    FeaturestoreCode featurestoreCode = new FeaturestoreCode(commitTime, codeInode, featuregroup, applicationId);
    if (featuregroup.getFeaturegroupType() == FeaturegroupType.CACHED_FEATURE_GROUP && featuregroup.getCachedFeaturegroup().getTimeTravelFormat() == TimeTravelFormat.HUDI) {
        FeatureGroupCommit featureGroupCommit = featureGroupCommitCommitController.findCommitByDate(featuregroup, fgCommitId);
        featurestoreCode.setFeatureGroupCommit(featureGroupCommit);
    }
    return featurestoreCodeFacade.update(featurestoreCode);
}
Also used : Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) FeaturestoreCode(io.hops.hopsworks.persistence.entity.featurestore.code.FeaturestoreCode) FeatureGroupCommit(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit) Timestamp(java.sql.Timestamp)

Example 3 with FeatureGroupCommit

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit in project hopsworks by logicalclocks.

the class FeatureGroupCommitFacade method getCommitDetailsByDate.

public CollectionInfo getCommitDetailsByDate(Integer featureGroupId, Integer limit, Integer offset, Set<? extends SortBy> sort, Set<? extends FilterBy> filters) {
    String queryStr = buildQuery("SELECT fgc FROM FeatureGroupCommit fgc ", filters, sort, "fgc.featureGroupCommitPK.featureGroupId = :featureGroupId");
    Query query = em.createQuery(queryStr, FeatureGroupCommit.class).setParameter("featureGroupId", featureGroupId);
    String queryCountStr = buildQuery("SELECT COUNT(fgc.featureGroupCommitPK.commitId) FROM " + "FeatureGroupCommit fgc ", filters, sort, "fgc.featureGroupCommitPK.featureGroupId = :featureGroupId");
    Query queryCount = em.createQuery(queryCountStr, FeatureGroupCommit.class).setParameter("featureGroupId", featureGroupId);
    setFilter(filters, query);
    setFilter(filters, queryCount);
    setOffsetAndLim(offset, limit, query);
    return new CollectionInfo((Long) queryCount.getSingleResult(), query.getResultList());
}
Also used : Query(javax.persistence.Query) FeatureGroupCommit(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit)

Example 4 with FeatureGroupCommit

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit in project hopsworks by logicalclocks.

the class FeatureGroupCommitFacade method getCommitDetails.

public CollectionInfo getCommitDetails(Integer featureGroupId, Integer limit, Integer offset, Set<? extends SortBy> sort) {
    String queryStr = buildQuery("SELECT fgc FROM FeatureGroupCommit fgc ", null, sort, "fgc.featureGroupCommitPK.featureGroupId = :featureGroupId");
    Query query = em.createQuery(queryStr, FeatureGroupCommit.class).setParameter("featureGroupId", featureGroupId);
    String queryCountStr = buildQuery("SELECT COUNT(fgc.featureGroupCommitPK.commitId) FROM " + "FeatureGroupCommit fgc ", null, sort, "fgc.featureGroupCommitPK.featureGroupId = :featureGroupId");
    Query queryCount = em.createQuery(queryCountStr, FeatureGroupCommit.class).setParameter("featureGroupId", featureGroupId);
    query.setFirstResult(offset);
    if (limit != null) {
        query.setMaxResults(limit);
    }
    return new CollectionInfo((Long) queryCount.getSingleResult(), query.getResultList());
}
Also used : Query(javax.persistence.Query) FeatureGroupCommit(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit)

Example 5 with FeatureGroupCommit

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit in project hopsworks by logicalclocks.

the class FeatureGroupCommitController method createHudiFeatureGroupCommit.

public FeatureGroupCommit createHudiFeatureGroupCommit(Users user, Featuregroup featuregroup, String commitDateString, Long commitTime, Long rowsUpdated, Long rowsInserted, Long rowsDeleted, Integer validationId) throws FeaturestoreException {
    // Compute HUDI commit path
    String commitPath = computeHudiCommitPath(featuregroup, commitDateString);
    Inode inode = inodeController.getInodeAtPath(commitPath);
    // commit id will be timestamp
    FeatureGroupCommit featureGroupCommit = new FeatureGroupCommit(featuregroup.getId(), commitTime);
    featureGroupCommit.setInode(inode);
    featureGroupCommit.setCommittedOn(new Timestamp(commitTime));
    featureGroupCommit.setNumRowsUpdated(rowsUpdated);
    featureGroupCommit.setNumRowsInserted(rowsInserted);
    featureGroupCommit.setNumRowsDeleted(rowsDeleted);
    // Find validation
    if (validationId != null && validationId > 0) {
        featureGroupCommit.setValidation(featureGroupValidationFacade.findById(validationId));
    }
    featureGroupCommit = featureGroupCommitFacade.update(featureGroupCommit);
    fsActivityFacade.logCommitActivity(user, featuregroup, featureGroupCommit);
    return featureGroupCommit;
}
Also used : Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) FeatureGroupCommit(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit) Timestamp(java.sql.Timestamp)

Aggregations

FeatureGroupCommit (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit)7 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)3 Timestamp (java.sql.Timestamp)3 Users (io.hops.hopsworks.persistence.entity.user.Users)2 Query (javax.persistence.Query)2 Strings (com.google.common.base.Strings)1 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)1 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)1 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)1 FeaturestoreFacade (io.hops.hopsworks.common.featurestore.FeaturestoreFacade)1 FeatureGroupFeatureDTO (io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO)1 FeaturegroupController (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupController)1 FeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO)1 FeaturegroupFacade (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupFacade)1 FeatureGroupCommitController (io.hops.hopsworks.common.featurestore.featuregroup.cached.FeatureGroupCommitController)1 OnlineFeaturestoreController (io.hops.hopsworks.common.featurestore.online.OnlineFeaturestoreController)1 FilterController (io.hops.hopsworks.common.featurestore.query.filter.FilterController)1 Join (io.hops.hopsworks.common.featurestore.query.join.Join)1 JoinDTO (io.hops.hopsworks.common.featurestore.query.join.JoinDTO)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1