Search in sources :

Example 1 with MLModel

use of com.hortonworks.registries.model.data.MLModel in project registry by hortonworks.

the class MLModelRegistryResource method getModelInputFieldsById.

/**
 * Get model fields by id
 * <p>
 * curl -sS -X GET http://localhost:8080/api/v1/catalog/ml/models/1/fields/input
 * </p>
 * <pre>
 *{
 *      "responseCode":1000,
 *      "responseMessage":"Success",
 *      "entities":[
 *                      {"name": "fieldName", "type": "fieldType"}
 *                      ...
 *                      ...
 *                 ]
 *}
 * </pre>
 */
@GET
@Path("ml/models/{id}/fields/input")
@Produces(MediaType.APPLICATION_JSON)
@Timed
public Response getModelInputFieldsById(@PathParam("id") final Long modelId) throws Exception {
    MLModel modelInfo = modelRegistryService.getModelInfo(modelId);
    final List<MLModelField> fieldNames = modelRegistryService.getModelInputFields(modelInfo);
    return WSUtils.respondEntity(fieldNames, OK);
}
Also used : MLModel(com.hortonworks.registries.model.data.MLModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 2 with MLModel

use of com.hortonworks.registries.model.data.MLModel in project registry by hortonworks.

the class MLModelRegistryService method getModelInfo.

public MLModel getModelInfo(Long modelId) {
    MLModel modelInfo = new MLModel();
    modelInfo.setId(modelId);
    MLModel storedModelInfo = this.storageManager.get(modelInfo.getStorableKey());
    if (storedModelInfo == null) {
        throw EntityNotFoundException.byId(modelId.toString());
    }
    return storedModelInfo;
}
Also used : MLModel(com.hortonworks.registries.model.data.MLModel)

Example 3 with MLModel

use of com.hortonworks.registries.model.data.MLModel in project registry by hortonworks.

the class MLModelRegistryResource method getModelOutputFieldsById.

/**
 * Get model fields by id
 * <p>
 * curl -sS -X GET http://localhost:8080/api/v1/catalog/ml/models/1/fields/output
 * </p>
 * <pre>
 *{
 *      "responseCode":1000,
 *      "responseMessage":"Success",
 *      "entities":[
 *                      {"name": "fieldName", "type": "fieldType"}
 *                      ...
 *                 ]
 *}
 * </pre>
 */
@GET
@Path("ml/models/{id}/fields/output")
@Produces(MediaType.APPLICATION_JSON)
@Timed
public Response getModelOutputFieldsById(@PathParam("id") final Long modelId) throws Exception {
    MLModel modelInfo = modelRegistryService.getModelInfo(modelId);
    final List<MLModelField> fieldNames = modelRegistryService.getModelOutputFields(modelInfo);
    return WSUtils.respondEntity(fieldNames, OK);
}
Also used : MLModel(com.hortonworks.registries.model.data.MLModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 4 with MLModel

use of com.hortonworks.registries.model.data.MLModel in project registry by hortonworks.

the class MLModelRegistryService method getModelInfo.

public MLModel getModelInfo(String name) {
    List<QueryParam> queryParams = Collections.singletonList(new QueryParam(MLModel.NAME, name));
    Collection<MLModel> modelInfos = this.storageManager.find(ML_MODEL_NAME_SPACE, queryParams);
    if (modelInfos.size() == 0) {
        throw EntityNotFoundException.byName(name);
    }
    return modelInfos.iterator().next();
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) MLModel(com.hortonworks.registries.model.data.MLModel)

Example 5 with MLModel

use of com.hortonworks.registries.model.data.MLModel in project registry by hortonworks.

the class MLModelRegistryService method removeModelInfo.

public MLModel removeModelInfo(Long modelId) {
    MLModel modelInfo = new MLModel();
    modelInfo.setId(modelId);
    MLModel removedModelInfo = this.storageManager.remove(modelInfo.getStorableKey());
    if (removedModelInfo == null) {
        throw EntityNotFoundException.byId(modelId.toString());
    }
    return removedModelInfo;
}
Also used : MLModel(com.hortonworks.registries.model.data.MLModel)

Aggregations

MLModel (com.hortonworks.registries.model.data.MLModel)5 Timed (com.codahale.metrics.annotation.Timed)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 QueryParam (com.hortonworks.registries.common.QueryParam)1