Search in sources :

Example 6 with FeaturestoreCode

use of io.hops.hopsworks.persistence.entity.featurestore.code.FeaturestoreCode in project hopsworks by logicalclocks.

the class CodeController method registerCode.

public FeaturestoreCode registerCode(Project project, Users user, Long codeCommitTimeStamp, String applicationId, TrainingDataset trainingDataset, String entityId, String databricksNotebook, byte[] databricksArchive, CodeActions.RunType type) throws ServiceException, FeaturestoreException {
    Inode codeInode = saveCode(project, user, applicationId, trainingDataset, entityId, databricksNotebook, databricksArchive, type);
    Timestamp commitTime = new Timestamp(codeCommitTimeStamp);
    FeaturestoreCode featurestoreCode = new FeaturestoreCode(commitTime, codeInode, trainingDataset, applicationId);
    return featurestoreCodeFacade.update(featurestoreCode);
}
Also used : Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) FeaturestoreCode(io.hops.hopsworks.persistence.entity.featurestore.code.FeaturestoreCode) Timestamp(java.sql.Timestamp)

Example 7 with FeaturestoreCode

use of io.hops.hopsworks.persistence.entity.featurestore.code.FeaturestoreCode in project hopsworks by logicalclocks.

the class CodeResource method post.

@POST
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Save new code")
@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 post(@Context UriInfo uriInfo, @Context SecurityContext sc, @QueryParam("entityId") String entityId, @QueryParam("type") CodeActions.RunType type, @QueryParam("databricksClusterId") String databricksClusterId, CodeDTO codeDTO) throws FeaturestoreException, DatasetException, HopsSecurityException, ServiceException, UserException {
    Users user = jWTHelper.getUserPrincipal(sc);
    String databricksNotebook = null;
    byte[] databricksArchive = null;
    CodeDTO dto;
    if (featuregroup != null) {
        FeaturestoreCode featurestoreCode = codeController.registerCode(project, user, codeDTO.getCommitTime(), codeDTO.getFeatureGroupCommitId(), codeDTO.getApplicationId(), featuregroup, entityId, databricksNotebook, databricksArchive, type);
        dto = codeBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.CODE), project, user, featuregroup, featurestoreCode, JupyterController.NotebookConversion.HTML);
    } else {
        FeaturestoreCode featurestoreCode = codeController.registerCode(project, user, codeDTO.getCommitTime(), codeDTO.getApplicationId(), trainingDataset, entityId, databricksNotebook, databricksArchive, type);
        dto = codeBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.CODE), project, user, trainingDataset, featurestoreCode, JupyterController.NotebookConversion.HTML);
    }
    return Response.ok().entity(dto).build();
}
Also used : FeaturestoreCode(io.hops.hopsworks.persistence.entity.featurestore.code.FeaturestoreCode) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) 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)

Aggregations

FeaturestoreCode (io.hops.hopsworks.persistence.entity.featurestore.code.FeaturestoreCode)7 AbstractFacade (io.hops.hopsworks.common.dao.AbstractFacade)2 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)2 Timestamp (java.sql.Timestamp)2 Query (javax.persistence.Query)2 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)1 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)1 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)1 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)1 FeatureGroupCommit (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit)1 Users (io.hops.hopsworks.persistence.entity.user.Users)1 ApiOperation (io.swagger.annotations.ApiOperation)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1