use of io.hops.hopsworks.common.serving.ServingWrapper in project hopsworks by logicalclocks.
the class ServingService method put.
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@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.SERVING }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Create or update a serving instance")
public Response put(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "serving specification", required = true) ServingView serving) throws ServingException, ServiceException, KafkaException, ProjectException, UserException, InterruptedException, ExecutionException, UnsupportedEncodingException {
Users user = jWTHelper.getUserPrincipal(sc);
if (serving == null) {
throw new IllegalArgumentException("serving was not provided");
}
ServingWrapper servingWrapper = serving.getServingWrapper();
servingUtil.validateUserInput(servingWrapper, project);
servingController.put(project, user, servingWrapper);
ServingView servingView = new ServingView(servingWrapper);
UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(String.valueOf(servingView.getId()));
GenericEntity<ServingView> servingEntity = new GenericEntity<ServingView>(servingView) {
};
return Response.created(builder.build()).entity(servingEntity).build();
}
use of io.hops.hopsworks.common.serving.ServingWrapper in project hopsworks by logicalclocks.
the class ServingService method get.
@GET
@Path("/{servingId}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.SERVING }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get info about a serving instance for the project", response = ServingView.class)
public Response get(@Context SecurityContext sc, @ApiParam(value = "Id of the Serving instance", required = true) @PathParam("servingId") Integer servingId) throws ServingException, KafkaException, CryptoPasswordNotFoundException {
if (servingId == null) {
throw new IllegalArgumentException("servingId was not provided");
}
ServingWrapper servingWrapper = servingController.get(project, servingId);
ServingView servingView = new ServingView(servingWrapper);
GenericEntity<ServingView> servingEntity = new GenericEntity<ServingView>(servingView) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(servingEntity).build();
}
use of io.hops.hopsworks.common.serving.ServingWrapper in project hopsworks by logicalclocks.
the class ServingView method getServingWrapper.
@JsonIgnore
public ServingWrapper getServingWrapper() {
ServingWrapper servingWrapper = new ServingWrapper(new Serving(id, name, description, modelPath, modelName, modelVersion, predictor, requestedInstances, batchingEnabled, modelServer, servingTool));
servingWrapper.setKafkaTopicDTO(kafkaTopicDTO);
return servingWrapper;
}
use of io.hops.hopsworks.common.serving.ServingWrapper in project hopsworks by logicalclocks.
the class ServingService method getAll.
@GET
@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.SERVING }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get the list of serving instances for the project", response = ServingView.class, responseContainer = "List")
public Response getAll(@QueryParam("model") String modelName, @QueryParam("status") ServingStatusEnum status, @QueryParam("name") String servingName, @Context SecurityContext sc) throws ServingException, KafkaException, CryptoPasswordNotFoundException {
// if filter by name, return a single serving
if (!Strings.isNullOrEmpty(servingName)) {
ServingWrapper servingWrapper = servingController.get(project, servingName);
ServingView servingView = new ServingView(servingWrapper);
GenericEntity<ServingView> servingEntity = new GenericEntity<ServingView>(servingView) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(servingEntity).build();
}
List<ServingWrapper> servingDAOList = servingController.getAll(project, modelName, status);
ArrayList<ServingView> servingViewList = new ArrayList<>();
for (ServingWrapper servingWrapper : servingDAOList) {
servingViewList.add(new ServingView(servingWrapper));
}
GenericEntity<ArrayList<ServingView>> genericListServingView = new GenericEntity<ArrayList<ServingView>>(servingViewList) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(genericListServingView).build();
}
Aggregations