Search in sources :

Example 1 with CachedFeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO in project hopsworks by logicalclocks.

the class FeaturegroupController method createFeaturegroupNoValidation.

public FeaturegroupDTO createFeaturegroupNoValidation(Featurestore featurestore, FeaturegroupDTO featuregroupDTO, Project project, Users user) throws FeaturestoreException, SQLException, ProvenanceException, ServiceException, KafkaException, SchemaException, ProjectException, UserException, IOException, HopsSecurityException {
    // Persist specific feature group metadata (cached fg or on-demand fg)
    OnDemandFeaturegroup onDemandFeaturegroup = null;
    CachedFeaturegroup cachedFeaturegroup = null;
    List<FeatureGroupFeatureDTO> featuresNoHudi = null;
    if (featuregroupDTO instanceof CachedFeaturegroupDTO) {
        // make copy of schema without hudi columns
        featuresNoHudi = new ArrayList<>(featuregroupDTO.getFeatures());
        cachedFeaturegroup = cachedFeaturegroupController.createCachedFeaturegroup(featurestore, (CachedFeaturegroupDTO) featuregroupDTO, project, user);
    } else {
        onDemandFeaturegroup = onDemandFeaturegroupController.createOnDemandFeaturegroup(featurestore, (OnDemandFeaturegroupDTO) featuregroupDTO, project, user);
    }
    // Persist basic feature group metadata
    Featuregroup featuregroup = persistFeaturegroupMetadata(featurestore, user, featuregroupDTO, cachedFeaturegroup, onDemandFeaturegroup);
    // online feature group needs to be set up after persisting metadata in order to get feature group id
    if (featuregroupDTO instanceof CachedFeaturegroupDTO && settings.isOnlineFeaturestore() && featuregroup.getCachedFeaturegroup().isOnlineEnabled()) {
        onlineFeaturegroupController.setupOnlineFeatureGroup(featurestore, featuregroup, featuresNoHudi, project, user);
    }
    FeaturegroupDTO completeFeaturegroupDTO = convertFeaturegrouptoDTO(featuregroup, project, user);
    // Extract metadata
    String hdfsUsername = hdfsUsersController.getHdfsUserName(project, user);
    DistributedFileSystemOps udfso = dfs.getDfsOps(hdfsUsername);
    try {
        String fgPath = Utils.getFeaturestorePath(featurestore.getProject(), settings) + "/" + Utils.getFeaturegroupName(featuregroup);
        fsController.featuregroupAttachXAttrs(fgPath, completeFeaturegroupDTO, udfso);
    } finally {
        dfs.closeDfsClient(udfso);
    }
    // Log activity
    fsActivityFacade.logMetadataActivity(user, featuregroup, FeaturestoreActivityMeta.FG_CREATED, null);
    return completeFeaturegroupDTO;
}
Also used : OnDemandFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.ondemand.OnDemandFeaturegroup) FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) OnDemandFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.ondemand.OnDemandFeaturegroup) CachedFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup) DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps) CachedFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO) OnDemandFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.ondemand.OnDemandFeaturegroupDTO) OnDemandFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.ondemand.OnDemandFeaturegroupDTO) CachedFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO) CachedFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup)

Example 2 with CachedFeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO in project hopsworks by logicalclocks.

the class FeaturegroupController method convertFeaturegrouptoDTO.

/**
 * Convert a featuregroup entity to a DTO representation
 *
 * @param featuregroup the entity to convert
 * @return a DTO representation of the entity
 */
private FeaturegroupDTO convertFeaturegrouptoDTO(Featuregroup featuregroup, Project project, Users user) throws FeaturestoreException, ServiceException {
    String featurestoreName = featurestoreFacade.getHiveDbName(featuregroup.getFeaturestore().getHiveDbId());
    switch(featuregroup.getFeaturegroupType()) {
        case CACHED_FEATURE_GROUP:
            CachedFeaturegroupDTO cachedFeaturegroupDTO = cachedFeaturegroupController.convertCachedFeaturegroupToDTO(featuregroup, project, user);
            cachedFeaturegroupDTO.setFeaturestoreName(featurestoreName);
            return cachedFeaturegroupDTO;
        case ON_DEMAND_FEATURE_GROUP:
            FeaturestoreStorageConnectorDTO storageConnectorDTO = connectorController.convertToConnectorDTO(user, project, featuregroup.getOnDemandFeaturegroup().getFeaturestoreConnector());
            OnDemandFeaturegroupDTO onDemandFeaturegroupDTO = new OnDemandFeaturegroupDTO(featurestoreName, featuregroup, storageConnectorDTO);
            try {
                String path = getFeatureGroupLocation(featuregroup);
                String location = featurestoreUtils.prependNameNode(path);
                onDemandFeaturegroupDTO.setLocation(location);
            } catch (ServiceDiscoveryException e) {
                throw new ServiceException(RESTCodes.ServiceErrorCode.SERVICE_NOT_FOUND, Level.SEVERE);
            }
            return onDemandFeaturegroupDTO;
        default:
            throw new IllegalArgumentException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_FEATUREGROUP_TYPE.getMessage() + ", Recognized Feature group types are: " + FeaturegroupType.ON_DEMAND_FEATURE_GROUP + ", and: " + FeaturegroupType.CACHED_FEATURE_GROUP + ". The provided feature group type was not recognized: " + featuregroup.getFeaturegroupType());
    }
}
Also used : ServiceException(io.hops.hopsworks.exceptions.ServiceException) FeaturestoreStorageConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO) CachedFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO) OnDemandFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.ondemand.OnDemandFeaturegroupDTO) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)

Example 3 with CachedFeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO in project hopsworks by logicalclocks.

the class HopsFSProvenanceController method fromFeaturegroup.

private FeaturegroupXAttr.FullDTO fromFeaturegroup(FeaturegroupDTO featuregroup) {
    List<FeaturegroupXAttr.SimpleFeatureDTO> features = new LinkedList<>();
    for (FeatureGroupFeatureDTO feature : featuregroup.getFeatures()) {
        features.add(new FeaturegroupXAttr.SimpleFeatureDTO(feature.getName(), feature.getDescription()));
    }
    FeaturegroupXAttr.FullDTO fullDTO = new FeaturegroupXAttr.FullDTO(featuregroup.getFeaturestoreId(), featuregroup.getDescription(), featuregroup.getCreated(), featuregroup.getCreator().getEmail(), features);
    if (featuregroup instanceof CachedFeaturegroupDTO) {
        fullDTO.setFgType(FeaturegroupXAttr.FGType.CACHED);
    } else if (featuregroup instanceof OnDemandFeaturegroupDTO) {
        fullDTO.setFgType(FeaturegroupXAttr.FGType.ON_DEMAND);
    }
    return fullDTO;
}
Also used : FeaturegroupXAttr(io.hops.hopsworks.common.featurestore.xattr.dto.FeaturegroupXAttr) FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) CachedFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO) OnDemandFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.ondemand.OnDemandFeaturegroupDTO) LinkedList(java.util.LinkedList)

Example 4 with CachedFeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO in project hopsworks by logicalclocks.

the class TestFeatureGroupInputValidation method testverifySchemaProvided_fail.

@Test(expected = FeaturestoreException.class)
public void testverifySchemaProvided_fail() throws Exception {
    CachedFeaturegroupDTO featuregroupDTO = new CachedFeaturegroupDTO();
    featuregroupDTO.setFeatures(new ArrayList<>());
    featuregroupDTO.setOnlineEnabled(true);
    featureGroupInputValidation.verifySchemaProvided(featuregroupDTO);
}
Also used : CachedFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO) Test(org.junit.Test)

Example 5 with CachedFeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO in project hopsworks by logicalclocks.

the class TestFeatureGroupInputValidation method testverifySchemaProvided_success.

@Test
public void testverifySchemaProvided_success() throws Exception {
    CachedFeaturegroupDTO featuregroupDTO = new CachedFeaturegroupDTO();
    featuregroupDTO.setFeatures(features);
    featuregroupDTO.setOnlineEnabled(true);
    featureGroupInputValidation.verifySchemaProvided(featuregroupDTO);
}
Also used : CachedFeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO) Test(org.junit.Test)

Aggregations

CachedFeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO)7 FeatureGroupFeatureDTO (io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO)3 OnDemandFeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.ondemand.OnDemandFeaturegroupDTO)3 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)3 CachedFeaturegroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup)2 OnDemandFeaturegroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.ondemand.OnDemandFeaturegroup)2 Test (org.junit.Test)2 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)1 Join (io.hops.hopsworks.common.featurestore.query.join.Join)1 FeaturestoreStorageConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO)1 FeaturegroupXAttr (io.hops.hopsworks.common.featurestore.xattr.dto.FeaturegroupXAttr)1 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)1 ServiceException (io.hops.hopsworks.exceptions.ServiceException)1 FeatureGroupExpectation (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation)1 FeatureStoreExpectation (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureStoreExpectation)1 StatisticColumn (io.hops.hopsworks.persistence.entity.featurestore.statistics.StatisticColumn)1 StatisticsConfig (io.hops.hopsworks.persistence.entity.featurestore.statistics.StatisticsConfig)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1