Search in sources :

Example 6 with FeatureView

use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.

the class FeatureViewFacade method findByFeaturestore.

public List<FeatureView> findByFeaturestore(Featurestore featurestore, QueryParam queryParam) {
    Boolean latestVersion = false;
    if (queryParam.getFilters().removeIf(filter -> filter.toString().equals("LATEST_VERSION"))) {
        latestVersion = true;
    }
    Map<String, Object> extraParam = new HashMap<>();
    extraParam.put("featurestore", featurestore);
    String queryStr = buildQuery("SELECT fv FROM FeatureView fv ", queryParam.getFilters(), queryParam.getSorts(), "fv.featurestore = :featurestore ");
    Query q = makeQuery(queryStr, queryParam, extraParam);
    List<FeatureView> results = q.getResultList();
    if (latestVersion) {
        results = retainLatestVersion(results);
    }
    return results;
}
Also used : TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) HashMap(java.util.HashMap) FeatureView(io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView)

Example 7 with FeatureView

use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.

the class FeatureViewFacadeTest method createFeatureView.

public FeatureView createFeatureView(String name, Integer version) {
    FeatureView featureView = new FeatureView();
    featureView.setName(name);
    featureView.setVersion(version);
    return featureView;
}
Also used : FeatureView(io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView)

Example 8 with FeatureView

use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.

the class FeatureViewFacadeTest method testRetainLatestVersion.

@Test
public void testRetainLatestVersion() {
    FeatureView featureView1_1 = createFeatureView("test1", 1);
    FeatureView featureView1_2 = createFeatureView("test1", 2);
    FeatureView featureView2_1 = createFeatureView("test2", 1);
    FeatureView featureView2_2 = createFeatureView("test2", 2);
    FeatureView featureView3_1 = createFeatureView("test3", 1);
    List<FeatureView> featureViews = Lists.newArrayList(featureView1_1, featureView1_2, featureView2_1, featureView2_2, featureView3_1);
    List<FeatureView> actual = target.retainLatestVersion(featureViews);
    List<FeatureView> expected = Lists.newArrayList(featureView1_2, featureView2_2, featureView3_1);
    assertEquals(actual.size(), expected.size());
    assertTrue(actual.containsAll(expected));
    assertTrue(expected.containsAll(actual));
}
Also used : FeatureView(io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView) Test(org.junit.Test)

Example 9 with FeatureView

use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.

the class FeatureViewResource method getAll.

@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get all Feature View metadata.", response = FeatureViewDTO.class)
public Response getAll(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo, @BeanParam FeatureViewBeanParam param) throws FeaturestoreException, ServiceException, IOException, MetadataException, DatasetException, SchematizedTagException {
    Users user = jWTHelper.getUserPrincipal(sc);
    ResourceRequest resourceRequest = makeResourceRequest(param);
    List<FeatureView> featureViews = featureViewController.getByFeatureStore(featurestore, resourceRequest);
    return Response.ok().entity(featureViewBuilder.build(featureViews, resourceRequest, project, user, uriInfo)).build();
}
Also used : FeatureView(io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) 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 10 with FeatureView

use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.

the class FeatureViewResource method getByNameVersion.

@GET
@Path("/{name: [a-z0-9_]*(?=[a-z])[a-z0-9_]+}/version/{version: [0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get Feature View metadata by name and version.", response = FeatureViewDTO.class)
public Response getByNameVersion(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo, @BeanParam FeatureViewBeanParam param, @ApiParam(value = "Name of the feature view", required = true) @PathParam("name") String name, @PathParam("version") Integer version) throws FeaturestoreException, ServiceException, IOException, MetadataException, DatasetException, SchematizedTagException {
    Users user = jWTHelper.getUserPrincipal(sc);
    ResourceRequest resourceRequest = makeResourceRequest(param);
    List<FeatureView> featureViews = featureViewController.getByNameVersionAndFeatureStore(name, version, featurestore, resourceRequest);
    return Response.ok().entity(featureViewBuilder.build(featureViews, resourceRequest, project, user, uriInfo)).build();
}
Also used : FeatureView(io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) 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)

Aggregations

FeatureView (io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView)11 Users (io.hops.hopsworks.persistence.entity.user.Users)6 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)4 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)4 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)4 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)4 ApiOperation (io.swagger.annotations.ApiOperation)4 Produces (javax.ws.rs.Produces)4 Date (java.util.Date)3 TrainingDatasetFeatureDTO (io.hops.hopsworks.common.featurestore.feature.TrainingDatasetFeatureDTO)2 FeaturegroupController (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupController)2 FeatureViewDTO (io.hops.hopsworks.common.featurestore.featureview.FeatureViewDTO)2 OnlineFeaturestoreController (io.hops.hopsworks.common.featurestore.online.OnlineFeaturestoreController)2 Feature (io.hops.hopsworks.common.featurestore.query.Feature)2 Query (io.hops.hopsworks.common.featurestore.query.Query)2 QueryController (io.hops.hopsworks.common.featurestore.query.QueryController)2 QueryDTO (io.hops.hopsworks.common.featurestore.query.QueryDTO)2 Join (io.hops.hopsworks.common.featurestore.query.join.Join)2 PitJoinController (io.hops.hopsworks.common.featurestore.query.pit.PitJoinController)2 TransformationFunctionFacade (io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionFacade)2