Search in sources :

Example 26 with TrainingDataset

use of io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset in project hopsworks by logicalclocks.

the class TrainingDatasetService method provenance.

@Path("/{trainingDatasetId}/provenance")
public ProvArtifactResource provenance(@PathParam("trainingDatasetId") Integer trainingDatasetId) throws FeaturestoreException, GenericException {
    String tdName = featurestore.getProject().getName() + "_" + Settings.ServiceDataset.TRAININGDATASETS.getName();
    DatasetPath targetEndpointPath;
    try {
        Dataset targetEndpoint = datasetController.getByName(featurestore.getProject(), tdName);
        targetEndpointPath = datasetHelper.getTopLevelDatasetPath(project, targetEndpoint);
    } catch (DatasetException ex) {
        throw new GenericException(RESTCodes.GenericErrorCode.ILLEGAL_ARGUMENT, Level.FINE, "training dataset not found");
    }
    this.provenanceResource.setContext(project, targetEndpointPath);
    TrainingDataset td = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
    this.provenanceResource.setArtifactId(td.getName(), td.getVersion());
    return provenanceResource;
}
Also used : TrainingDataset(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) TrainingDataset(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) GenericException(io.hops.hopsworks.exceptions.GenericException) DatasetException(io.hops.hopsworks.exceptions.DatasetException) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath)

Example 27 with TrainingDataset

use of io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset in project hopsworks by logicalclocks.

the class TrainingDatasetService method putTag.

@ApiOperation(value = "Create or update tags(bulk) for a training dataset", response = TagsDTO.class)
@PUT
@Path("/{trainingdatasetId}/tags/{name}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response putTag(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the training dataset", required = true) @PathParam("trainingdatasetId") Integer trainingdatasetId, @ApiParam(value = "Name of the tag", required = true) @PathParam("name") String name, @ApiParam(value = "Value to set for the tag") String value) throws MetadataException, FeaturestoreException, SchematizedTagException, DatasetException {
    verifyIdProvided(trainingdatasetId);
    Users user = jWTHelper.getUserPrincipal(sc);
    TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingdatasetId);
    AttachTagResult result = tagController.upsert(project, user, featurestore, trainingDataset, name, value);
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
    TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, project, featurestore.getId(), ResourceRequest.Name.TRAININGDATASETS.name(), trainingdatasetId, result.getItems());
    UriBuilder builder = uriInfo.getAbsolutePathBuilder();
    if (result.isCreated()) {
        return Response.created(builder.build()).entity(dto).build();
    } else {
        return Response.ok(builder.build()).entity(dto).build();
    }
}
Also used : TagsDTO(io.hops.hopsworks.common.tags.TagsDTO) TrainingDataset(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset) AttachTagResult(io.hops.hopsworks.common.tags.AttachTagResult) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) UriBuilder(javax.ws.rs.core.UriBuilder) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) 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) PUT(javax.ws.rs.PUT)

Example 28 with TrainingDataset

use of io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset in project hopsworks by logicalclocks.

the class TrainingDatasetService method getTransformationFunction.

@ApiOperation(value = "Get training dataset transformation functions", response = TrainingDatasetDTO.class)
@GET
@Path("/{trainingdatasetid}/transformationfunctions")
@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" })
public Response getTransformationFunction(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the trainingdatasetid", required = true) @PathParam("trainingdatasetid") Integer trainingDatasetId) throws FeaturestoreException {
    if (trainingDatasetId == null) {
        throw new IllegalArgumentException(RESTCodes.FeaturestoreErrorCode.TRAINING_DATASET_ID_NOT_PROVIDED.getMessage());
    }
    TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
    Users user = jWTHelper.getUserPrincipal(sc);
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TRANSFORMATIONFUNCTIONS);
    TransformationFunctionAttachedDTO transformationFunctionAttachedDTO = transformationFunctionBuilder.build(uriInfo, resourceRequest, user, project, trainingDataset);
    return Response.ok().entity(transformationFunctionAttachedDTO).build();
}
Also used : TransformationFunctionAttachedDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionAttachedDTO) TrainingDataset(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) 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 29 with TrainingDataset

use of io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset in project hopsworks by logicalclocks.

the class TrainingDatasetService method deleteTag.

@ApiOperation(value = "Delete tag attached to training dataset")
@DELETE
@Path("/{trainingDatasetId}/tags/{name}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteTag(@Context SecurityContext sc, @ApiParam(value = "Id of the trainingdatasetid", required = true) @PathParam("trainingDatasetId") Integer trainingDatasetId, @ApiParam(value = "Name of the tag", required = true) @PathParam("name") String name) throws DatasetException, MetadataException, SchematizedTagException, FeaturestoreException {
    verifyIdProvided(trainingDatasetId);
    Users user = jWTHelper.getUserPrincipal(sc);
    TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
    tagController.delete(project, user, featurestore, trainingDataset, name);
    return Response.noContent().build();
}
Also used : TrainingDataset(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) DELETE(javax.ws.rs.DELETE) 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)

Aggregations

TrainingDataset (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset)29 Users (io.hops.hopsworks.persistence.entity.user.Users)12 ArrayList (java.util.ArrayList)11 Feature (io.hops.hopsworks.common.featurestore.query.Feature)10 Filter (io.hops.hopsworks.common.featurestore.query.filter.Filter)10 FilterLogic (io.hops.hopsworks.common.featurestore.query.filter.FilterLogic)10 Path (javax.ws.rs.Path)10 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)9 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)9 SqlFilterLogic (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.SqlFilterLogic)9 TrainingDatasetFilter (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDatasetFilter)9 ApiOperation (io.swagger.annotations.ApiOperation)9 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)8 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)8 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)8 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)8 ExternalTrainingDataset (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.external.ExternalTrainingDataset)8 HopsfsTrainingDataset (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.hopsfs.HopsfsTrainingDataset)8 Produces (javax.ws.rs.Produces)8 Test (org.junit.Test)8