Collectors
Capture data for your application
Collectors capture input data for your app. They enable you to pipe in data from production models automatically, and are the key to unlocking many platform training capabilities like active learning.
Collectors are available with Essential and Enterprise plans to help you manage data ingestion at scale.
You can create app-level collectors to monitor specific models and specify sampling rules for triggering data ingestion. Collectors can only collect data from apps where you are the app owner.
Collector Parameters
Collector ID
Give your collector a useful and descriptive name.
Description
Provide additional details about your collector.
Pre-queue Workflow
In many scenarios, you will only want to ingest a sample, or subset of a given data source into your app. Pre-queue workflows allow you to pre-process your inputs so that you can sample and filter your new data before it is ever added to your app. Pre-queue workflows allow you to specify sampling rules for triggering data ingestion.
Common pre-queue workflows are designed to:
- Randomly sample inputs
- Filter inputs by metadata
- Filter inputs with a maximum probability below a given threshold
- Filter inputs with a minimum probability above a given threshold
- Filter specific concept probabilities above a given threshold
- Undertake knowledge graph mapping from public General model concepts to a custom model
At least one (pre-queue or post-queue) workflow ID is required. The input to this workflow is going to be the OUTPUT of the model. We recommend that you use fast and light-weight models in it as it will affect the speed of the predictions being made.
Post Inputs Key
Select the API key that you would like to use to allow new inputs to be posted to your app. This is the post-queue workflow ID of the workflow to run to after the collector has processed the queued input. This API key must have the PostInputs scope, since it grants the collector the authority to POST inputs to your app.
This workflow uses the original input to the model as input to the workflow so that you can run additional models as well on that input to decide whether to queue the model or not. If the workflow output has any field that is non-empty, then it will be passed on to POST /inputs to the destination app.
At least one (pre-queue or post-queue) workflow ID is required.
Source
Select the model that you would like to collect data from, and the collector will automatically post the new inputs to your app. Simply enter your model name, or model ID number. When the user predicts an input against this model, the input is going to be collected.
You need to specify the app ID and user ID where the model is located. If using a publicly available model, the model's user and app ID should be clarifai
and main
, respectively. Otherwise, the IDs should belong to the user who created the model. You also need to specify an API key ID where the inputs are going to be added.
See also Auto Annotation walkthrough.
The initialization code used in the following examples is outlined in detail on the client installation page.
Add Collector
Add a new collector to your application.
- Python
- NodeJS
- Java
- PHP
- cURL
###############################################################################
# In this section, we set the user authentication, app ID, and details of the
# collector we want to add. Change these strings to run your own example.
###############################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the portal under Authentification
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to add your own collector
COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE'
COLLECTOR_DESCRIPTION = 'YOUR_COLLECTOR_DESCRIPTION_HERE'
PRE_QUEUE_WORKFLOW_ID = 'YOUR_PRE_WORKFLOW_ID_HERE'
POST_QUEUE_WORKFLOW_ID = 'YOUR_POST_WORKFLOW_ID_HERE'
MODEL_ID = 'YOUR_MODEL_ID_HERE'
MODEL_VERSION_ID = 'YOUR_MODEL_VERSION_ID_HERE'
POST_INPUTS_KEY_ID = 'YOUR_API_KEY_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID) # The userDataObject is required when using a PAT
post_collectors_response = stub.PostCollectors(
service_pb2.PostCollectorsRequest(
user_app_id=userDataObject,
collectors=[
resources_pb2.Collector(
id=COLLECTOR_ID,
description=COLLECTOR_DESCRIPTION,
pre_queue_workflow_id=PRE_QUEUE_WORKFLOW_ID,
post_queue_workflow_id=POST_QUEUE_WORKFLOW_ID,
collector_source=resources_pb2.CollectorSource(
api_post_model_outputs_collector_source=resources_pb2.APIPostModelOutputsCollectorSource(
model_user_id=USER_ID,
model_app_id=APP_ID,
model_id=MODEL_ID,
model_version_id=MODEL_VERSION_ID,
post_inputs_key_id=POST_INPUTS_KEY_ID
)
)
)
]
),
metadata=metadata
)
if post_collectors_response.status.code != status_code_pb2.SUCCESS:
print(post_collectors_response.status)
raise Exception("Post collectors failed, status: " + post_collectors_response.status.description)
//index.js file
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details of the
// collector we want to add. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the portal under Authentification
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change these to add your own collector
const COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE';
const COLLECTOR_DESCRIPTION = 'YOUR_COLLECTOR_DESCRIPTION_HERE';
const PRE_QUEUE_WORKFLOW_ID = 'YOUR_PRE_WORKFLOW_ID_HERE';
const POST_QUEUE_WORKFLOW_ID = 'YOUR_POST_WORKFLOW_ID_HERE';
const MODEL_ID = 'YOUR_MODEL_ID_HERE';
const MODEL_VERSION_ID = 'YOUR_MODEL_VERSION_ID_HERE';
const POST_INPUTS_KEY_ID = 'YOUR_API_KEY_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.PostCollectors(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
collectors: [
{
id: COLLECTOR_ID,
description: COLLECTOR_DESCRIPTION,
pre_queue_workflow_id: PRE_QUEUE_WORKFLOW_ID,
post_queue_workflow_id: POST_QUEUE_WORKFLOW_ID,
collector_source: {
api_post_model_outputs_collector_source: {
model_user_id: USER_ID,
model_app_id: APP_ID,
model_id: MODEL_ID,
model_version_id: MODEL_VERSION_ID,
post_inputs_key_id: POST_INPUTS_KEY_ID
}
}
}
]
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
console.log(response.status);
throw new Error("Post collectors failed, status: " + response.status.description);
}
}
);
package com.clarifai.example;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
///////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details of the
// collector we want to add. Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these to add your own collector
static final String COLLECTOR_ID = "YOUR_COLLECTOR_ID_HERE";
static final String COLLECTOR_DESCRIPTION = "YOUR_COLLECTOR_DESCRIPTION_HERE";
static final String PRE_QUEUE_WORKFLOW_ID = "YOUR_PRE_WORKFLOW_ID_HERE";
static final String POST_QUEUE_WORKFLOW_ID = "YOUR_POST_WORKFLOW_ID_HERE";
static final String MODEL_ID = "YOUR_MODEL_ID_HERE";
static final String MODEL_VERSION_ID = "YOUR_MODEL_VERSION_ID_HERE";
static final String POST_INPUTS_KEY_ID = "YOUR_API_KEY_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiCollectorResponse postCollectorsResponse = stub.postCollectors(
PostCollectorsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.addCollectors(
Collector.newBuilder()
.setId(COLLECTOR_ID)
.setDescription(COLLECTOR_DESCRIPTION)
.setPreQueueWorkflowId(PRE_QUEUE_WORKFLOW_ID)
.setPostQueueWorkflowId(POST_QUEUE_WORKFLOW_ID)
.setCollectorSource(
CollectorSource.newBuilder()
.setApiPostModelOutputsCollectorSource(
APIPostModelOutputsCollectorSource.newBuilder()
.setModelUserId(USER_ID)
.setModelAppId(APP_ID)
.setModelId(MODEL_ID)
.setModelVersionId(MODEL_VERSION_ID)
.setPostInputsKeyId(POST_INPUTS_KEY_ID)
)
)
)
.build()
);
if (postCollectorsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Post collectors failed, status: " + postCollectorsResponse.getStatus());
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details of the
// collector we want to add. Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the portal under Authentification
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to add your own collector
$COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE';
$COLLECTOR_DESCRIPTION = 'YOUR_COLLECTOR_DESCRIPTION_HERE';
$PRE_QUEUE_WORKFLOW_ID = 'YOUR_PRE_WORKFLOW_ID_HERE';
$POST_QUEUE_WORKFLOW_ID = 'YOUR_POST_WORKFLOW_ID_HERE';
$MODEL_ID = 'YOUR_MODEL_ID_HERE';
$MODEL_VERSION_ID = 'YOUR_MODEL_VERSION_ID_HERE';
$POST_INPUTS_KEY_ID = 'YOUR_API_KEY_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\Api\Collector;
use Clarifai\ClarifaiClient;
use Clarifai\Api\PostCollectorsRequest;
use Clarifai\Api\CollectorSource;
use Clarifai\Api\APIPostModelOutputsCollectorSource;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->PostCollectors(
// The request object carries the request along with the request status and other metadata related to the request itself
new PostCollectorsRequest([
"user_app_id" => $userDataObject,
"collectors" => [
new Collector([
"id" => $COLLECTOR_ID,
"description" => $COLLECTOR_DESCRIPTION,
"pre_queue_workflow_id" => $PRE_QUEUE_WORKFLOW_ID,
"post_queue_workflow_id" => $POST_QUEUE_WORKFLOW_ID,
"collector_source" =>
new CollectorSource([
"api_post_model_outputs_collector_source" =>
new APIPostModelOutputsCollectorSource([
"model_user_id" => $USER_ID,
"model_app_id" => $APP_ID,
"model_id" => $MODEL_ID,
"model_version_id" => $MODEL_VERSION_ID,
"post_inputs_key_id" => $POST_INPUTS_KEY_ID
])
])
])
]
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
?>
curl -X POST "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/collectors" \
-H "Authorization: Key YOUR_PAT_HERE" \
-H "Content-Type: application/json" \
--data-raw '{
"collectors": [
{
"id": "YOUR_COLLECTOR_ID_HERE",
"description": "YOUR_COLLECTOR_DESCRIPTION_HERE",
"pre_queue_workflow_id": "YOUR_PRE_WORKFLOW_ID_HERE",
"post_queue_workflow_id": "YOUR_POST_WORKFLOW_ID_HERE",
"collector_source": {
"api_post_model_outputs_collector_source": {
"model_user_id": "YOUR_USER_ID_HERE",
"model_app_id": "YOUR_APP_ID_HERE",
"model_id": "YOUR_MODEL_ID_HERE",
"model_version_id": "YOUR_MODEL_VERSION_ID_HERE",
"post_inputs_key_id": "YOUR_API_KEY_HERE"
}
}
}
]
}'
Update Collector
Update an existing collector.
- Python
- NodeJS
- Java
- PHP
- cURL
###############################################################################
# In this section, we set the user authentication, app ID, and details of the
# collector we want to update. Change these strings to run your own example.
###############################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the portal under Authentification
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to update your own collector
COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE'
COLLECTOR_DESCRIPTION = 'YOUR_COLLECTOR_DESCRIPTION_HERE'
PRE_QUEUE_WORKFLOW_ID = 'YOUR_PRE_WORKFLOW_ID_HERE'
POST_QUEUE_WORKFLOW_ID = 'YOUR_POST_WORKFLOW_ID_HERE'
MODEL_ID = 'YOUR_MODEL_ID_HERE'
MODEL_VERSION_ID = 'YOUR_MODEL_VERSION_ID_HERE'
POST_INPUTS_KEY_ID = 'YOUR_KEY_ID_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID) # The userDataObject is required when using a PAT
patch_collectors_response = stub.PatchCollectors(
service_pb2.PatchCollectorsRequest(
user_app_id=userDataObject,
action = 'overwrite',
collectors=[
resources_pb2.Collector(
id=COLLECTOR_ID,
description=COLLECTOR_DESCRIPTION,
pre_queue_workflow_id=PRE_QUEUE_WORKFLOW_ID,
post_queue_workflow_id=POST_QUEUE_WORKFLOW_ID,
collector_source=resources_pb2.CollectorSource(
api_post_model_outputs_collector_source=resources_pb2.APIPostModelOutputsCollectorSource(
model_user_id=USER_ID,
model_app_id=APP_ID,
model_id=MODEL_ID,
model_version_id=MODEL_VERSION_ID,
post_inputs_key_id=POST_INPUTS_KEY_ID
)
)
)
]
),
metadata=metadata
)
if patch_collectors_response.status.code != status_code_pb2.SUCCESS:
print(patch_collectors_response.status)
raise Exception("Patch collectors failed, status: " + patch_collectors_response.status.description)
//index.js file
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details of the
// collector we want to update. Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the portal under Authentification
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change these to update your own collector
const COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE';
const COLLECTOR_DESCRIPTION = 'YOUR_NEW_COLLECTOR_DESCRIPTION_HERE';
const PRE_QUEUE_WORKFLOW_ID = 'YOUR_NEW_PRE_WORKFLOW_ID';
const POST_QUEUE_WORKFLOW_ID = 'YOUR_NEW_POST_WORKFLOW_ID';
const MODEL_ID = 'YOUR_NEW_MODEL_ID_HERE';
const MODEL_VERSION_ID = 'YOUR_NEW_MODEL_VERSION_ID_HERE';
const POST_INPUTS_KEY_ID = 'YOUR_API_KEY_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.PatchCollectors(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
action: "overwrite",
collectors: [
{
id: COLLECTOR_ID,
description: COLLECTOR_DESCRIPTION,
pre_queue_workflow_id: PRE_QUEUE_WORKFLOW_ID,
post_queue_workflow_id: POST_QUEUE_WORKFLOW_ID,
collector_source: {
api_post_model_outputs_collector_source: {
model_user_id: USER_ID,
model_app_id: APP_ID,
model_id: MODEL_ID,
model_version_id: MODEL_VERSION_ID,
post_inputs_key_id: POST_INPUTS_KEY_ID
}
}
}
]
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
console.log(response.status);
throw new Error("Patch collectors failed, status: " + response.status.description);
}
}
);
package com.clarifai.example;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
///////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details of the
// collector we want to update. Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these to update your own collector
static final String COLLECTOR_ID = "YOUR_COLLECTOR_ID_HERE";
static final String COLLECTOR_DESCRIPTION = "YOUR_NEW_COLLECTOR_DESCRIPTION_HERE";
static final String PRE_QUEUE_WORKFLOW_ID = "YOUR_NEW_PRE_WORKFLOW_ID";
static final String POST_QUEUE_WORKFLOW_ID = "YOUR_NEW_POST_WORKFLOW_ID";
static final String MODEL_ID = "YOUR_NEW_MODEL_ID_HERE";
static final String MODEL_VERSION_ID = "YOUR_NEW_MODEL_VERSION_ID_HERE";
static final String POST_INPUTS_KEY_ID = "YOUR_API_KEY_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiCollectorResponse patchCollectorsResponse = stub.patchCollectors(
PatchCollectorsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setAction("overwrite")
.addCollectors(
Collector.newBuilder()
.setId(COLLECTOR_ID)
.setDescription(COLLECTOR_DESCRIPTION)
.setPreQueueWorkflowId(PRE_QUEUE_WORKFLOW_ID)
.setPostQueueWorkflowId(POST_QUEUE_WORKFLOW_ID)
.setCollectorSource(
CollectorSource.newBuilder()
.setApiPostModelOutputsCollectorSource(
APIPostModelOutputsCollectorSource.newBuilder()
.setModelUserId(USER_ID)
.setModelAppId(APP_ID)
.setModelId(MODEL_ID)
.setModelVersionId(MODEL_VERSION_ID)
.setPostInputsKeyId(POST_INPUTS_KEY_ID)
)
)
)
.build()
);
if (patchCollectorsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Post collectors failed, status: " + patchCollectorsResponse.getStatus());
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and details of the
// collector we want to update. Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the portal under Authentification
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to update your own collector
$COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE';
$COLLECTOR_DESCRIPTION = 'YOUR_NEW_COLLECTOR_DESCRIPTION_HERE';
$PRE_QUEUE_WORKFLOW_ID = 'YOUR_NEW_PRE_WORKFLOW_ID';
$POST_QUEUE_WORKFLOW_ID = 'YOUR_NEW_POST_WORKFLOW_ID';
$MODEL_ID = 'YOUR_NEW_MODEL_ID_HERE';
$MODEL_VERSION_ID = 'YOUR_NEW_MODEL_VERSION_ID_HERE';
$POST_INPUTS_KEY_ID = 'YOUR_API_KEY_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\Api\Collector;
use Clarifai\ClarifaiClient;
use Clarifai\Api\PatchCollectorsRequest;
use Clarifai\Api\CollectorSource;
use Clarifai\Api\APIPostModelOutputsCollectorSource;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->PatchCollectors(
// The request object carries the request along with the request status and other metadata related to the request itself
new PatchCollectorsRequest([
"user_app_id" => $userDataObject,
"action" => "overwrite",
"collectors" => [
new Collector([
"id" => $COLLECTOR_ID,
"description" => $COLLECTOR_DESCRIPTION,
"pre_queue_workflow_id" => $PRE_QUEUE_WORKFLOW_ID,
"post_queue_workflow_id" => $POST_QUEUE_WORKFLOW_ID,
"collector_source" =>
new CollectorSource([
"api_post_model_outputs_collector_source" =>
new APIPostModelOutputsCollectorSource([
"model_user_id" => $USER_ID,
"model_app_id" => $APP_ID,
"model_id" => $MODEL_ID,
"model_version_id" => $MODEL_VERSION_ID,
"post_inputs_key_id" => $POST_INPUTS_KEY_ID
])
])
])
]
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
?>
curl -X PATCH "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/collectors" \
-H "Authorization: Key YOUR_PAT_HERE" \
-H "Content-Type: application/json" \
--data-raw '{
"action": "overwrite",
"collectors": [
{
"id": "YOUR_COLLECTOR_ID_HERE",
"description": "YOUR_NEW_COLLECTOR_DESCRIPTION_HERE",
"pre_queue_workflow_id": "YOUR_NEW_PRE_WORKFLOW_ID_HERE",
"post_queue_workflow_id": "YOUR_NEW_POST_WORKFLOW_ID_HERE",
"collector_source": {
"api_post_model_outputs_collector_source": {
"model_user_id": "YOUR_USER_ID_HERE",
"model_app_id": "YOUR_APP_ID_HERE",
"model_id": "YOUR_NEW_MODEL_ID_HERE",
"model_version_id": "YOUR_NEW_MODEL_VERSION_ID_HERE",
"post_inputs_key_id": "YOUR_API_KEY_HERE"
}
}
}
]
}'
List Collectors
List all the collectors. See Pagination on how to control which page gets displayed.
- Python
- NodeJS
- Java
- PHP
- cURL
##################################################################
# In this section, we set the user authentication and app ID.
# Change these strings to run your own example.
##################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the portal under Authentification
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID) # The userDataObject is required when using a PAT
list_collectors_response = stub.ListCollectors(
service_pb2.ListCollectorsRequest(user_app_id=userDataObject),
metadata=metadata
)
if list_collectors_response.status.code != status_code_pb2.SUCCESS:
print(list_collectors_response.status)
raise Exception("List collectors failed, status: " + list_collectors_response.status.description)
for collector in list_collectors_response.collectors:
print(collector)
#print(list_collectors_response.collectors)
//index.js file
//////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the portal under Authentification
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.ListCollectors(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
}
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
console.log(response.status);
throw new Error("List collectors failed, status: " + response.status.description);
}
for (const collector of response.collectors) {
console.log(collector);
}
}
);
package com.clarifai.example;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiCollectorResponse listCollectorsResponse = stub.listCollectors(
ListCollectorsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.build()
);
if (listCollectorsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List collectors failed, status: " + listCollectorsResponse.getStatus());
}
for (Collector collector : listCollectorsResponse.getCollectorsList()) {
System.out.println(collector);
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
//////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the portal under Authentification
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\ListCollectorsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListCollectors(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListCollectorsRequest([
"user_app_id" => $userDataObject
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
foreach ($response->getCollectors() as $collector){
print $collector->serializeToJsonString(). "<br>";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/collectors" \
-H "Authorization: Key YOUR_PAT_HERE" \
-H "Content-Type: application/json"
Get Collector
Return details of a certain collector.
- Python
- NodeJS
- Java
- PHP
- cURL
#####################################################################################
# In this section, we set the user authentication, app ID, and ID of the collector
# we want its details. Change these strings to run your own example.
#####################################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the portal under Authentification
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change this to get your own collector
COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID) # The userDataObject is required when using a PAT
get_collector_response = stub.GetCollector(
service_pb2.GetCollectorRequest(
user_app_id=userDataObject,
collector_id=COLLECTOR_ID
),
metadata=metadata
)
if get_collector_response.status.code != status_code_pb2.SUCCESS:
print(get_collector_response.status)
raise Exception("Get collector failed, status: " + get_collector_response.status.description)
print(get_collector_response.collector)
//index.js file
//////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and ID of the collector
// we want its details. Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the portal under Authentification
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change this to get your own collector
const COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.GetCollector(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
collector_id: COLLECTOR_ID
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
console.log(response.status);
throw new Error("Get collector failed, status: " + response.status.description);
}
console.log(response.collector);
}
);
package com.clarifai.example;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and ID of the collector
// we want its details. Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change this to get your own collector
static final String COLLECTOR_ID = "YOUR_COLLECTOR_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
SingleCollectorResponse getCollectorResponse = stub.getCollector(
GetCollectorRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setCollectorId(COLLECTOR_ID)
.build()
);
if (getCollectorResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Get collector failed, status: " + getCollectorResponse.getStatus());
}
System.out.println(getCollectorResponse.getCollector());
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
//////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and ID of the collector
// we want its details. Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the portal under Authentification
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change this to get your own collector
$COLLECTOR_ID = 'YOUR_COLLECTOR_ID_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\GetCollectorRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->GetCollector(
// The request object carries the request along with the request status and other metadata related to the request itself
new GetCollectorRequest([
"user_app_id" => $userDataObject,
"collector_id" => $COLLECTOR_ID
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
print $response->getCollector()->serializeToJsonString();
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/collectors/YOUR_COLLECTOR_ID_HERE" \
-H "Authorization: Key YOUR_PAT_HERE" \
-H "Content-Type: application/json"
Delete Collector
Delete a collector.
- Python
- NodeJS
- Java
- PHP
- cURL
######################################################################################
# In this section, we set the user authentication, app ID, and IDs of the collectors
# we want to delete. Change these strings to run your own example.
######################################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the portal under Authentification
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to delete your own collectors
COLLECTOR_ID_1 = 'YOUR_COLLECTOR_ID_HERE'
COLLECTOR_ID_2 = 'YOUR_COLLECTOR_ID_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)
delete_collectors_response = stub.DeleteCollectors(
service_pb2.DeleteCollectorsRequest(
user_app_id=userDataObject,
ids=[COLLECTOR_ID_1, COLLECTOR_ID_2],
#delete_all=True #Uncomment to delete all your collectors
),
metadata=metadata
)
if delete_collectors_response.status.code != status_code_pb2.SUCCESS:
print(delete_collectors_response.status)
raise Exception("Delete collectors failed, status: " + delete_collectors_response.status.description)
//index.js file
///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and IDs of the collectors
// we want to delete. Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the portal under Authentification
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change these to delete your own collectors
const COLLECTOR_ID_1 = 'YOUR_COLLECTOR_ID_HERE';
const COLLECTOR_ID_2 = 'YOUR_COLLECTOR_ID_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.DeleteCollectors(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
ids: [COLLECTOR_ID_1, COLLECTOR_ID_2],
//delete_all: true //Uncomment to delete all your collectors
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
console.log(response.status);
throw new Error("Delete collectors failed, status: " + response.status.description);
}
console.log(response.collector);
}
);
package com.clarifai.example;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
////////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and IDs of the collectors
// we want to delete. Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these to delete your own collectors
static final String COLLECTOR_ID_1 = "YOUR_COLLECTOR_ID_HERE";
static final String COLLECTOR_ID_2 = "YOUR_COLLECTOR_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
BaseResponse deleteCollectorsResponse = stub.deleteCollectors(
DeleteCollectorsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.addIds(COLLECTOR_ID_1)
.addIds(COLLECTOR_ID_2)
.build()
);
if (deleteCollectorsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Delete collectors failed, status: " + deleteCollectorsResponse.getStatus());
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and IDs of the collectors
// we want to delete. Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the portal under Authentification
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to delete your own collectors
$COLLECTOR_ID_1 = 'YOUR_COLLECTOR_ID_HERE';
$COLLECTOR_ID_2 = 'YOUR_COLLECTOR_ID_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\DeleteCollectorsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->DeleteCollectors(
// The request object carries the request along with the request status and other metadata related to the request itself
new DeleteCollectorsRequest([
"user_app_id" => $userDataObject,
"ids"=> [
$COLLECTOR_ID_1, $COLLECTOR_ID_2
],
//"delete_all" => true // Uncomment to delete all your collectors
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
?>
curl -X DELETE "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/collectors" \
-H "Authorization: Key YOUR_PAT_HERE" \
-H "Content-Type: application/json" \
--data-raw '{
"ids": ["YOUR_COLLECTOR_ID_HERE", "YOUR_COLLECTOR_ID_HERE"]
}'