Search in sources :

Example 41 with GenericException

use of io.hops.hopsworks.exceptions.GenericException in project hopsworks by logicalclocks.

the class ElasticService method featurestoreSearch.

/**
 * Searches for content inside all featurestore. Hits 'featurestore' index
 * <p/>
 * @param searchTerm
 * @param sc
 * @return
 */
@ApiOperation(value = "Search all featurestores", notes = "featurestore documents: featuregroups, features, training datasets", response = ElasticFeaturestoreDTO.class)
@GET
@Path("featurestore/{searchTerm}")
@Produces(MediaType.APPLICATION_JSON)
public Response featurestoreSearch(@PathParam("searchTerm") String searchTerm, @QueryParam("docType") @DefaultValue("ALL") FeaturestoreDocType docType, @QueryParam("from") @ApiParam(value = "search pointer position, if none given, it defaults to 0") Integer from, @QueryParam("size") @ApiParam(value = "search page size, if none give, it defaults to 100." + "Cannot be negative and cannot be bigger than 10000") Integer size, @Context SecurityContext sc) throws ServiceException, ElasticException, GenericException {
    if (Strings.isNullOrEmpty(searchTerm)) {
        throw new GenericException(RESTCodes.GenericErrorCode.ILLEGAL_ARGUMENT, Level.WARNING, "no search term provided");
    }
    Users user = jWTHelper.getUserPrincipal(sc);
    if (from == null) {
        from = 0;
    }
    if (size == null) {
        size = 100;
    }
    ElasticFeaturestoreDTO dto = elasticFeaturestoreBuilder.build(user, new ElasticFeaturestoreRequest(searchTerm, docType, from, size));
    return Response.ok().entity(dto).build();
}
Also used : ElasticFeaturestoreDTO(io.hops.hopsworks.api.elastic.featurestore.ElasticFeaturestoreDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ElasticFeaturestoreRequest(io.hops.hopsworks.api.elastic.featurestore.ElasticFeaturestoreRequest) GenericException(io.hops.hopsworks.exceptions.GenericException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 42 with GenericException

use of io.hops.hopsworks.exceptions.GenericException 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 43 with GenericException

use of io.hops.hopsworks.exceptions.GenericException in project hopsworks by logicalclocks.

the class FeaturegroupService method provenance.

@Path("/{featureGroupId}/provenance")
public ProvArtifactResource provenance(@PathParam("featureGroupId") Integer featureGroupId) throws FeaturestoreException, GenericException {
    DatasetPath targetEndpointPath;
    try {
        Dataset targetEndpoint = featurestoreController.getProjectFeaturestoreDataset(featurestore.getProject());
        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);
    Featuregroup fg = featuregroupController.getFeaturegroupById(featurestore, featureGroupId);
    this.provenanceResource.setArtifactId(fg.getName(), fg.getVersion());
    return provenanceResource;
}
Also used : Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) 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)

Aggregations

GenericException (io.hops.hopsworks.exceptions.GenericException)43 Users (io.hops.hopsworks.persistence.entity.user.Users)17 Project (io.hops.hopsworks.persistence.entity.project.Project)16 ProjectException (io.hops.hopsworks.exceptions.ProjectException)13 DatasetException (io.hops.hopsworks.exceptions.DatasetException)12 ServiceException (io.hops.hopsworks.exceptions.ServiceException)12 IOException (java.io.IOException)12 Path (javax.ws.rs.Path)11 ElasticException (io.hops.hopsworks.exceptions.ElasticException)10 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)10 JobException (io.hops.hopsworks.exceptions.JobException)9 ProvenanceException (io.hops.hopsworks.exceptions.ProvenanceException)9 Produces (javax.ws.rs.Produces)9 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)8 ArrayList (java.util.ArrayList)8 TransactionAttribute (javax.ejb.TransactionAttribute)8 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)6 UserException (io.hops.hopsworks.exceptions.UserException)6 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)6 HdfsUsers (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)6