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