Search in sources :

Example 6 with TrainingDatasetDTO

use of io.hops.hopsworks.common.featurestore.trainingdatasets.TrainingDatasetDTO in project hopsworks by logicalclocks.

the class TrainingDatasetService method updateTrainingDataset.

/**
 * Endpoint for updating the metadata of a training dataset
 *
 * @param trainingdatasetid the id of the trainingDataset to update
 * @param trainingDatasetDTO the JSON payload with the new metadat
 * @return JSON representation of the updated trainingDataset
 * @throws FeaturestoreException
 * @throws DatasetException
 * @throws ProjectException
 */
@PUT
@Path("/{trainingdatasetid: [0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(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 = "Update a training datasets with a specific id from a featurestore", response = TrainingDatasetDTO.class)
public Response updateTrainingDataset(@Context SecurityContext sc, @ApiParam(value = "Id of the training dataset", required = true) @PathParam("trainingdatasetid") Integer trainingdatasetid, @ApiParam(value = "updateMetadata", example = "true") @QueryParam("updateMetadata") @DefaultValue("false") Boolean updateMetadata, @ApiParam(value = "updateStatsConfig", example = "true") @QueryParam("updateStatsConfig") @DefaultValue("false") Boolean updateStatsConfig, TrainingDatasetDTO trainingDatasetDTO) throws FeaturestoreException, ServiceException {
    if (trainingDatasetDTO == null) {
        throw new IllegalArgumentException("Input JSON for updating a Training Dataset cannot be null");
    }
    verifyIdProvided(trainingdatasetid);
    trainingDatasetDTO.setId(trainingdatasetid);
    Users user = jWTHelper.getUserPrincipal(sc);
    TrainingDatasetDTO oldTrainingDatasetDTO = trainingDatasetController.getTrainingDatasetWithIdAndFeaturestore(user, project, featurestore, trainingdatasetid);
    if (updateMetadata) {
        oldTrainingDatasetDTO = trainingDatasetController.updateTrainingDatasetMetadata(user, project, featurestore, trainingDatasetDTO);
        activityFacade.persistActivity(ActivityFacade.EDITED_TRAINING_DATASET + trainingDatasetDTO.getName(), project, user, ActivityFlag.SERVICE);
    }
    if (updateStatsConfig) {
        oldTrainingDatasetDTO = trainingDatasetController.updateTrainingDatasetStatsConfig(user, project, featurestore, trainingDatasetDTO);
    }
    GenericEntity<TrainingDatasetDTO> trainingDatasetDTOGenericEntity = new GenericEntity<TrainingDatasetDTO>(oldTrainingDatasetDTO) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(trainingDatasetDTOGenericEntity).build();
}
Also used : TrainingDatasetDTO(io.hops.hopsworks.common.featurestore.trainingdatasets.TrainingDatasetDTO) GenericEntity(javax.ws.rs.core.GenericEntity) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) 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)

Aggregations

TrainingDatasetDTO (io.hops.hopsworks.common.featurestore.trainingdatasets.TrainingDatasetDTO)6 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)5 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)5 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)5 Users (io.hops.hopsworks.persistence.entity.user.Users)5 ApiOperation (io.swagger.annotations.ApiOperation)5 Produces (javax.ws.rs.Produces)5 GenericEntity (javax.ws.rs.core.GenericEntity)5 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 List (java.util.List)2 Consumes (javax.ws.rs.Consumes)2 StatisticsConfigDTO (io.hops.hopsworks.common.featurestore.statistics.StatisticsConfigDTO)1 TrainingDataset (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset)1 TrainingDatasetFeature (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDatasetFeature)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Test (org.junit.Test)1