use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getPreparedStatements.
@ApiOperation(value = "Get prepared statements used to generate model serving vector from training dataset query", response = ServingPreparedStatementDTO.class)
@GET
@Path("/{trainingdatasetid}/preparedstatements")
@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 getPreparedStatements(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the trainingdatasetid", required = true) @PathParam("trainingdatasetid") Integer trainingDatsetId, @ApiParam(value = "get batch serving vectors", example = "false") @QueryParam("batch") @DefaultValue("false") boolean batch) throws FeaturestoreException {
verifyIdProvided(trainingDatsetId);
Users user = jWTHelper.getUserPrincipal(sc);
ServingPreparedStatementDTO servingPreparedStatementDTO = preparedStatementBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.PREPAREDSTATEMENTS), project, user, featurestore, trainingDatsetId, batch);
return Response.ok().entity(servingPreparedStatementDTO).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getByName.
/**
* Endpoint for getting a list of training dataset based on the name
*
* @param name name of the training dataset to get
* @return return a JSON representation of the training dataset with the given id
* @throws FeaturestoreException
*/
@GET
@Path("/{name: [a-z0-9_]*(?=[a-z])[a-z0-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 a list of training datasets with a specific name, filter by version", response = List.class)
public Response getByName(@ApiParam(value = "Name of the training dataset", required = true) @PathParam("name") String name, @ApiParam(value = "Filter by a specific version") @QueryParam("version") Integer version, @Context SecurityContext sc) throws FeaturestoreException, ServiceException {
verifyNameProvided(name);
Users user = jWTHelper.getUserPrincipal(sc);
List<TrainingDatasetDTO> trainingDatasetDTO;
if (version == null) {
trainingDatasetDTO = trainingDatasetController.getWithNameAndFeaturestore(user, project, featurestore, name);
} else {
trainingDatasetDTO = Arrays.asList(trainingDatasetController.getWithNameVersionAndFeaturestore(user, project, featurestore, name, version));
}
GenericEntity<List<TrainingDatasetDTO>> trainingDatasetGeneric = new GenericEntity<List<TrainingDatasetDTO>>(trainingDatasetDTO) {
};
return Response.ok().entity(trainingDatasetGeneric).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method compute.
@POST
@Path("/{trainingDatasetId}/compute")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Setup a job to compute and write a training dataset", response = JobDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.DATASET_VIEW, ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response compute(@Context UriInfo uriInfo, @Context SecurityContext sc, @PathParam("trainingDatasetId") Integer trainingDatasetId, TrainingDatasetJobConf trainingDatasetJobConf) throws FeaturestoreException, ServiceException, JobException, ProjectException, GenericException {
verifyIdProvided(trainingDatasetId);
Users user = jWTHelper.getUserPrincipal(sc);
TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
Map<String, String> writeOptions = null;
if (trainingDatasetJobConf.getWriteOptions() != null) {
writeOptions = trainingDatasetJobConf.getWriteOptions().stream().collect(Collectors.toMap(OptionDTO::getName, OptionDTO::getValue));
}
Jobs job = fsJobManagerController.setupTrainingDatasetJob(project, user, trainingDataset, trainingDatasetJobConf.getQuery(), trainingDatasetJobConf.getOverwrite(), writeOptions, trainingDatasetJobConf.getSparkJobConfiguration());
JobDTO jobDTO = jobsBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.JOBS), job);
return Response.created(jobDTO.getHref()).entity(jobDTO).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getAll.
/**
* Endpoint for getting a list of all training datasets in the feature store.
*
* @return a JSON representation of the training datasets in the features store
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get the list of training datasets for a featurestore", response = TrainingDatasetDTO.class, responseContainer = "List")
public Response getAll(@Context SecurityContext sc) throws ServiceException, FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
List<TrainingDatasetDTO> trainingDatasetDTOs = trainingDatasetController.getTrainingDatasetsForFeaturestore(user, project, featurestore);
GenericEntity<List<TrainingDatasetDTO>> trainingDatasetsGeneric = new GenericEntity<List<TrainingDatasetDTO>>(trainingDatasetDTOs) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(trainingDatasetsGeneric).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getTag.
@ApiOperation(value = "Get tag attached to a training dataset", response = TagsDTO.class)
@GET
@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 getTag(@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, @BeanParam TagsExpansionBeanParam tagsExpansionBeanParam) throws DatasetException, MetadataException, FeaturestoreException, SchematizedTagException {
verifyIdProvided(trainingDatasetId);
Users user = jWTHelper.getUserPrincipal(sc);
TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
Map<String, String> result = new HashMap<>();
result.put(name, tagController.get(project, user, featurestore, trainingDataset, name));
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
resourceRequest.setExpansions(tagsExpansionBeanParam.getResources());
TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, project, featurestore.getId(), ResourceRequest.Name.TRAININGDATASETS.name(), trainingDatasetId, result);
return Response.status(Response.Status.OK).entity(dto).build();
}
Aggregations