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;
}
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());
}
}
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;
}
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);
}
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);
}
Aggregations