/** * Returns a Google Cloud ML Engine model loader. * * @param projectId Google project id. * @param modelId model id. * @param versionId model version id. */ static MlEngineLoader create(final String projectId, final String modelId, final String versionId) throws IOException, GeneralSecurityException { return ModelLoader.loaded(MlEngineModel.create(projectId, modelId, versionId))::get; }
/** * Returns a Google Cloud ML Engine model loader that references the default model. * * @param projectId Google project id. * @param modelId model id. */ static MlEngineLoader create(final String projectId, final String modelId) throws IOException, GeneralSecurityException { return ModelLoader.loaded(MlEngineModel.create(projectId, modelId))::get; }
/** * Returns a Google Cloud ML Engine model loader. * * @param id {@link Model.Id} needs to be created with the following format: * <pre> * "projects/{PROJECT_ID}/models/{MODEL_ID}/versions/{MODEL_VERSION}" * </pre> */ static MlEngineLoader create(final Model.Id id) throws IOException, GeneralSecurityException { return ModelLoader.loaded(MlEngineModel.create(id))::get; } }
/** * Returns a blocking {@link PreLoader}. Blocks till the model is loaded or a {@link Duration} * is met. * * @param loader model loader. * @param duration Amount of time that it should wait, if necessary, for model to be loaded. * @param <M> Underlying model instance. */ static <M extends Model<?>> PreLoader<M> preload( final ModelLoader<M> loader, final Duration duration) throws InterruptedException, ExecutionException, TimeoutException { return ModelLoader.loaded(loader.get(duration))::get; }