Skip to content

Requests

Models and Pipelines in UbiOps receive data through their REST API endpoint.

Before making a request, a Model or Pipeline should already have been created in the platform.

Model Requests using the WebApp

You can easily create model requests using the UbiOps WebApp. This comes in handy when testing if your model behaves as it should. The WebApp will create the API request for you.

You can test your model by going to the model version page.

  1. Click on Models in the sidebar on the left and then click on your model name and then on one of the versions. You should now be on the model version page.

  2. Now click CREATE DIRECT REQUEST and insert or upload the data you want to include in the test request. Click Create to create the request.

  3. When the model has finished processing you can see the results of your request.

Model Requests using the API

The following text describes how to send data to a Model or Pipeline using the UbiOps API and applies to both model as pipeline requests.

API Token

For sending data to a model through the UbiOps API you will need an API Token with the correct permissions.

You need to provide the project name, model name and version or pipeline name for which the request will be made. There are 2 types of requests: direct and batch requests. A direct request takes a single data point and keeps a connection open, after which the result is returned immediately. A batch request can take up to 250 data points (models) or 100 data points (pipelines), for which each of them, a separate request_id is returned with which the results can be retrieved at a later time.

  • Direct request is used to send one data point to the model. Available for models with both structured as plain input.
  • Batch request allows to send multiple data points to the model. Available for models with both structured as plain input.

To be able to make a model request, a model file should have been uploaded for the model version, which means the model version should be in active state.

  • Direct request is used to send one data point to the pipeline. Available for pipelines with both structured as plain input.
  • Batch request allows to send multiple data points to the pipeline. Available for pipeline with both structured as plain input.

In case of models/pipelines with structured input, you need to provide a JSON dictionary with the input fields of the model/pipeline as keys and the data as values. In case of batch request, you need to provide a list of dictionaries containing the input fields of the model/pipeline as keys and the data as values. In case of plain models, a string is required that will be sent as-is to the model. In case of batch request, a list of string input is required.

Making a batch request to a model in UbiOps

Info

If your model takes in a blob as input, you have to provide the id of the blob in the input.

Retrieve the request results through the API

The result of a direct request is always immediate, meaning that the result is returned as soon as its computed. If your model was idle before the request, this can take a bit longer than when the model was still active.

When you make a batch request, the following response is returned per data point:

[
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "status": "pending",
    "time_created": "2020-07-24T09:51:15.360Z"
  }
]

The status of the request is always pending upon initialization and will later change into processing, failed or completed.

After making the request, you can collect the result of the request with the request id returned upon making the request. You can either collect the result of a single request or the results of multiple requests.

For the results of one batch request, you can use the GET model requests method. For the results of one batch request, the GET pipeline requests method may be used.

The following actions are also permitted for batch requests:

  • Retrieve multiple batch model and pipeline requests: Retrieve the results of multiple batch requests in one call. This method takes in a list of the request id's.
  • Delete multiple batch model and pipeline requests: Delete the multiple batch requests in one call. This method takes in a list of the request id's. All batch requests that were not yet 'completed' or 'failed' are terminated.
  • List all batch model and pipeline requests: Give an overview of all batch requests for a model or pipeline. Selection and sorting options are available.
  • Delete a single batch model and pipeline request: Delete a single batch request and terminate it.

Requests Schedules

To make periodic requests to models and pipelines, you can use the Request Schedule functionality. See Requests Schedules for more information.