Search in sources :

Example 1 with KeywordDTO

use of io.hops.hopsworks.common.featurestore.keyword.KeywordDTO in project hopsworks by logicalclocks.

the class FeaturestoreKeywordBuilder method build.

public KeywordDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, FeatureView featureView, List<String> keywords) {
    KeywordDTO dto = new KeywordDTO();
    dto.setHref(uri(uriInfo, project, featureView.getFeaturestore(), featureView));
    dto.setExpand(expand(resourceRequest));
    if (dto.isExpand()) {
        dto.setKeywords(keywords);
    }
    return dto;
}
Also used : KeywordDTO(io.hops.hopsworks.common.featurestore.keyword.KeywordDTO)

Example 2 with KeywordDTO

use of io.hops.hopsworks.common.featurestore.keyword.KeywordDTO in project hopsworks by logicalclocks.

the class FeaturestoreKeywordBuilder method build.

public KeywordDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, List<String> keywords) {
    KeywordDTO dto = new KeywordDTO();
    dto.setHref(uri(uriInfo, project));
    dto.setExpand(expand(resourceRequest));
    if (dto.isExpand()) {
        dto.setKeywords(keywords);
    }
    return dto;
}
Also used : KeywordDTO(io.hops.hopsworks.common.featurestore.keyword.KeywordDTO)

Example 3 with KeywordDTO

use of io.hops.hopsworks.common.featurestore.keyword.KeywordDTO in project hopsworks by logicalclocks.

the class FeaturestoreKeywordResource method deleteKeywords.

@DELETE
@ApiOperation(value = "Delete a keyword")
@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" })
public Response deleteKeywords(@Context SecurityContext sc, @Context UriInfo uriInfo, @QueryParam("keyword") String keyword) throws FeaturestoreException, MetadataException {
    Users user = jwtHelper.getUserPrincipal(sc);
    List<String> updatedKeywords = keywordControllerIface.deleteKeywords(project, user, featuregroup, trainingDataset, Arrays.asList(keyword));
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.KEYWORDS);
    KeywordDTO dto = featurestoreKeywordBuilder.build(uriInfo, resourceRequest, project, featuregroup, trainingDataset, updatedKeywords);
    return Response.ok().entity(dto).build();
}
Also used : KeywordDTO(io.hops.hopsworks.common.featurestore.keyword.KeywordDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) DELETE(javax.ws.rs.DELETE) 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 4 with KeywordDTO

use of io.hops.hopsworks.common.featurestore.keyword.KeywordDTO in project hopsworks by logicalclocks.

the class FeaturestoreKeywordResource method replaceKeywords.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Create keywords or replace existing ones")
@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" })
public Response replaceKeywords(@Context SecurityContext sc, @Context UriInfo uriInfo, KeywordDTO keywordDTO) throws FeaturestoreException, MetadataException {
    Users user = jwtHelper.getUserPrincipal(sc);
    List<String> updatedKeywords = keywordControllerIface.replaceKeywords(project, user, featuregroup, trainingDataset, keywordDTO.getKeywords());
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.KEYWORDS);
    KeywordDTO dto = featurestoreKeywordBuilder.build(uriInfo, resourceRequest, project, featuregroup, trainingDataset, updatedKeywords);
    return Response.ok().entity(dto).build();
}
Also used : KeywordDTO(io.hops.hopsworks.common.featurestore.keyword.KeywordDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) 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 5 with KeywordDTO

use of io.hops.hopsworks.common.featurestore.keyword.KeywordDTO in project hopsworks by logicalclocks.

the class FeatureViewBuilder method buildSingle.

private FeatureViewDTO buildSingle(FeatureView featureView, ResourceRequest resourceRequest, Project project, Users user, UriInfo uriInfo) throws FeaturestoreException, ServiceException, IOException, MetadataException, DatasetException, SchematizedTagException {
    FeatureViewDTO base = convertToDTO(featureView);
    if (resourceRequest != null) {
        if (resourceRequest.contains(ResourceRequest.Name.QUERY)) {
            // For the overview page of UI
            base.setQueryString(queryBuilder.build(uriInfo, project, user, featureView));
        }
        if (resourceRequest.contains(ResourceRequest.Name.FEATURES)) {
            base.setFeatures(makeFeatures(featureView, project));
        }
        if (resourceRequest.contains(ResourceRequest.Name.KEYWORDS)) {
            // TODO feature view: revisit after implementation of keyword endpoint
            List<String> keywords = keywordControllerIface.getAll(project, user, featureView);
            ResourceRequest keywordResourceRequest = new ResourceRequest(ResourceRequest.Name.KEYWORDS);
            KeywordDTO dto = featurestoreKeywordBuilder.build(uriInfo, keywordResourceRequest, project, featureView, keywords);
            base.setKeywords(dto);
        }
        if (resourceRequest.contains(ResourceRequest.Name.TAGS)) {
            // TODO feature view: revisit after implementation of tag endpoint
            Map<String, String> result = tagController.getAll(project, user, featureView.getFeaturestore(), featureView);
            ResourceRequest tagsResourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
            TagsDTO dto = tagsBuilder.build(uriInfo, tagsResourceRequest, project, featureView.getFeaturestore().getId(), ResourceRequest.Name.FEATUREVIEW.name(), featureView.getId(), result);
            base.setTags(dto);
        }
    }
    return base;
}
Also used : KeywordDTO(io.hops.hopsworks.common.featurestore.keyword.KeywordDTO) TagsDTO(io.hops.hopsworks.common.tags.TagsDTO) FeatureViewDTO(io.hops.hopsworks.common.featurestore.featureview.FeatureViewDTO) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest)

Aggregations

KeywordDTO (io.hops.hopsworks.common.featurestore.keyword.KeywordDTO)8 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)5 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)4 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)4 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)4 ApiOperation (io.swagger.annotations.ApiOperation)4 Users (io.hops.hopsworks.persistence.entity.user.Users)3 Produces (javax.ws.rs.Produces)3 GET (javax.ws.rs.GET)2 FeatureViewDTO (io.hops.hopsworks.common.featurestore.featureview.FeatureViewDTO)1 TagsDTO (io.hops.hopsworks.common.tags.TagsDTO)1 Consumes (javax.ws.rs.Consumes)1 DELETE (javax.ws.rs.DELETE)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1