Manage Workflows
Manage workflows
Manage via the UI
Edit Workflow
After creating your workflow, you can edit it at any time by navigating to its individual page and clicking the Edit workflow button in the upper-right section.
This allows you to make changes easily whenever needed.
For example, to add a text-to-audio node to your workflow, first locate it in the left sidebar. Drag the node and connect it to the preceding text-to-text node. Next, use the search box on the right side of the page to select the specific model you want for the text-to-audio conversion.
Once you've made your changes, click the Save as new version button to save the updated workflow under a new version — without exiting the workflow editor.
- You can easily switch between different versions by selecting the respective version ID from the left sidebar in the workflow editor.
- Clicking the Update Workflow button creates a new workflow version and exits the workflow editor, redirecting to the workflow's main page.
- You can add a maximum of 20 nodes in a single workflow.
- Ensure all connections between nodes are correctly set to avoid errors during execution.
Manage via the API
Get
Get all Workflows in an App
You can return all custom workflows in your app.
If you want to get a list of the workflows not within the scope of your app, you need to use your PAT while specifying the user_id
of their owner and the app_id
of the application that you’re accessing. For example, to get Clarifai's workflows in the main
app, you need to use your PAT while specifying Clarifai's user_id
as "clarifai" and app_id
as "main" in the request.
- Python SDK
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
from clarifai.client.app import App
# Your PAT (Personal Access Token) can be found in the Account's Security section
app = App(app_id="APP_ID", user_id="USER_ID", pat="YOUR_PAT")
for workflow in app.list_workflows(page_no=1,per_page=7):
print("Workflow ID: ", workflow.id)
###################################################################
# 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 Account's Security section
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_workflows_response = stub.ListWorkflows(
service_pb2.ListWorkflowsRequest(
user_app_id=userDataObject
),
metadata=metadata
)
if list_workflows_response.status.code != status_code_pb2.SUCCESS:
print(list_workflows_response.status)
raise Exception("List workflows failed, status: " + list_workflows_response.status.description)
for workflow in list_workflows_response.workflows:
print(f"The workflow {workflow.id} consists of these models:")
for workflow_node in workflow.nodes:
model = workflow_node.model
print(model.id)
print()
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////
// 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 Account's Security section
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 requestOptions = {
method: "GET",
headers: {
"Accept": "application/json",
"Authorization": "Key " + PAT,
},
};
fetch(
`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/workflows`,
requestOptions
)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
</script>
//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 Account's Security section
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.ListWorkflows(
{
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) {
throw new Error(
"List workflows failed, status: " + response.status.description
);
}
for (const workflow of response.workflows) {
console.log("The workflow " + workflow.id + " consists of these models:");
for (const workflowNode of workflow.nodes) {
const model = workflowNode.model;
console.log(model.id);
}
console.log();
}
}
);
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.StatusCode;
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));
MultiWorkflowResponse listWorkflowsResponse = stub.listWorkflows(
ListWorkflowsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.build());
if (listWorkflowsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List workflows failed, status: " + listWorkflowsResponse.getStatus());
}
for (Workflow workflow: listWorkflowsResponse.getWorkflowsList()) {
System.out.println("The workflow " + workflow.getId() + " consists of these models:");
for (WorkflowNode workflowNode: workflow.getNodesList()) {
Model model = workflowNode.getModel();
System.out.println(model.getId());
}
System.out.println();
}
}
}
<?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 Account's Security section
$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\ListWorkflowsRequest;
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
->ListWorkflows(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListWorkflowsRequest([
"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) {
throw new Exception(
"Failure response: " .
$response->getStatus()->getDescription() .
" " .
$response->getStatus()->getDetails()
);
}
// Print details of each workflow
foreach ($response->getWorkflows() as $workflow) {
echo "The workflow " . $workflow->getId() . " consists of these models:\n";
foreach ($workflow->getNodes() as $workflowNode) {
$model = $workflowNode->getModel();
echo $model->getId();
}
echo "\n";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/workflows/" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_PAT_HERE"
Output
Workflow ID: object_track
Workflow ID: video_track
Workflow ID: multimodal_to_text
Workflow ID: text_to_audio
Workflow ID: upscale_workflow
Workflow ID: image_generation
Workflow ID: text_generation
Get a Workflow by a Specific ID
You can return information about a specific workflow.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
############################################################################
# In this section, we set the user authentication, app ID, and workflow 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 Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change this to your own workflow ID
WORKFLOW_ID = 'my-custom-workflow'
##########################################################################
# 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_workflow_response = stub.GetWorkflow(
service_pb2.GetWorkflowRequest(
user_app_id=userDataObject,
workflow_id=WORKFLOW_ID
),
metadata=metadata
)
if get_workflow_response.status.code != status_code_pb2.SUCCESS:
print(get_workflow_response.status)
raise Exception("Get workflow failed, status: " + get_workflow_response.status.description)
workflow = get_workflow_response.workflow
print(f"The workflow consists of these models:")
for workflow_node in workflow.nodes:
model = workflow_node.model
print(model.id)
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and workflow 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 Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change this to your own workflow ID
const WORKFLOW_ID = "my-custom-workflow";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: "GET",
headers: {
"Accept": "application/json",
"Authorization": "Key " + PAT,
},
};
fetch(
`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/workflows/${WORKFLOW_ID}`,
requestOptions
)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
</script>
//index.js file
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and workflow 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 Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change this to your own workflow ID
const WORKFLOW_ID = "my-custom-workflow";
/////////////////////////////////////////////////////////////////////////////
// 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.GetWorkflow(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID,
},
workflow_id: WORKFLOW_ID,
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error(
"Get workflow failed, status: " + response.status.description
);
}
const workflow = response.workflow;
console.log("The workflow consists of these models:");
for (const workflowNode of workflow.nodes) {
const model = workflowNode.model;
console.log(model.id);
}
}
);
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.StatusCode;
public class ClarifaiExample {
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and workflow 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";
// Change this to your own workflow ID
static final String WORKFLOW_ID = "food-and-general";
///////////////////////////////////////////////////////////////////////////////////
// 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));
SingleWorkflowResponse getWorkflowResponse = stub.getWorkflow(
GetWorkflowRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setWorkflowId(WORKFLOW_ID)
.build()
);
if (getWorkflowResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Get workflow failed, status: " + getWorkflowResponse.getStatus());
}
Workflow workflow = getWorkflowResponse.getWorkflow();
System.out.println("The workflow consists of these models:");
for (WorkflowNode workflowNode: workflow.getNodesList()) {
Model model = workflowNode.getModel();
System.out.println(model.getId());
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
/////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and workflow 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 Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change this to your own workflow ID
$WORKFLOW_ID = "my-custom-workflow";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\GetWorkflowRequest;
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
->GetWorkflow(
// The request object carries the request along with the request status and other metadata related to the request itself
new GetWorkflowRequest([
"user_app_id" => $userDataObject,
"workflow_id" => $WORKFLOW_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) {
throw new Exception(
"Failure response: " .
$response->getStatus()->getDescription() .
" " .
$response->getStatus()->getDetails()
);
}
$workflow = $response->getWorkflow();
echo "The workflow consists of these models:" . "\n";
foreach ($workflow->getNodes() as $workflowNode) {
$model = $workflowNode->getModel();
echo $model->getId() . "\n";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/workflows/YOUR_WORKFLOW_ID_HERE" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_PAT_HERE"
Update
After creating a workflow, you can perform patch operations on it by merging, removing, or overwriting data. By default, all actions support overwriting, with specific behaviors for lists of objects.
- The
merge
action updates an existingkey:value
pair withkey:new_value
or appends to an existing list. For dictionaries, it merges objects that share a matchingid
field. - The
remove
action is only used to delete the workflow's cover image on the platform UI. - The
overwrite
action fully replaces an existing object with a new one.
Patch Workflow's Models
You can change a workflow; that is, change the models of which the workflow consists.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
###################################################################################
# In this section, we set the user authentication, app ID, and the details of the
# workflow 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 Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to update your own workflow
WORKFLOW_ID = 'my-custom-workflow'
NODE_ID_1 = 'audio-to-text'
MODEL_ID_1 = 'asr-wav2vec2-base-960h-english'
MODEL_VERSION_ID_1 = 'f4deae70a473492a8e2f9b7bb1dbee85'
NODE_ID_2 = 'text-summarization'
MODEL_ID_2 = 'text-summarization-english-distilbart-cnn-12-6'
MODEL_VERSION_ID_2 = '8279cec2221a4b1d9db774470940aebd'
NODE_ID_3 = 'english-to-french'
MODEL_ID_3 = 'translation-english-to-french-text'
MODEL_VERSION_ID_3 = 'c65a4a51c2b646fca5f0e4bf1ff200d7'
##########################################################################
# 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_workflows_response = stub.PatchWorkflows(
service_pb2.PatchWorkflowsRequest(
user_app_id=userDataObject,
action="overwrite",
workflows=[
resources_pb2.Workflow(
id=WORKFLOW_ID,
nodes=[
resources_pb2.WorkflowNode(
id=NODE_ID_1,
model=resources_pb2.Model(
id=MODEL_ID_1,
model_version=resources_pb2.ModelVersion(
id=MODEL_VERSION_ID_1
)
)
),
resources_pb2.WorkflowNode(
id=NODE_ID_2,
model=resources_pb2.Model(
id=MODEL_ID_2,
model_version=resources_pb2.ModelVersion(
id=MODEL_VERSION_ID_2
)
),
node_inputs=[
resources_pb2.NodeInput(node_id=NODE_ID_1)
]
),
resources_pb2.WorkflowNode(
id=NODE_ID_3,
model=resources_pb2.Model(
id=MODEL_ID_3,
model_version=resources_pb2.ModelVersion(
id=MODEL_VERSION_ID_3
)
),
node_inputs=[
resources_pb2.NodeInput(node_id=NODE_ID_2)
]
),
]
)
]
),
metadata=metadata
)
if patch_workflows_response.status.code != status_code_pb2.SUCCESS:
print(patch_workflows_response.status)
raise Exception("Patch workflows failed, status: " + patch_workflows_response.status.description)
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the details of the
// workflow 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 Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change these to update your own workflow
const WORKFLOW_ID = "my-custom-workflow";
const NODE_ID_1 = "audio-to-text";
const MODEL_ID_1 = "asr-wav2vec2-base-960h-english";
const MODEL_VERSION_ID_1 = "f4deae70a473492a8e2f9b7bb1dbee85";
const NODE_ID_2 = "text-summarization";
const MODEL_ID_2 = "text-summarization-english-distilbart-cnn-12-6";
const MODEL_VERSION_ID_2 = "8279cec2221a4b1d9db774470940aebd";
const NODE_ID_3 = "english-to-french";
const MODEL_ID_3 = "translation-english-to-french-text";
const MODEL_VERSION_ID_3 = "c65a4a51c2b646fca5f0e4bf1ff200d7";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const raw = JSON.stringify({
"user_app_id": {
"user_id": USER_ID,
"app_id": APP_ID
},
"action": "overwrite",
"workflows": [
{
"id": WORKFLOW_ID,
"nodes": [
{
"id": NODE_ID_1,
"model": {
"id": MODEL_ID_1,
"model_version": {
"id": MODEL_VERSION_ID_1
}
}
},
{
"id": NODE_ID_2,
"model": {
"id": MODEL_ID_2,
"model_version": {
"id": MODEL_VERSION_ID_2
}
},
"node_inputs": [
{
"node_id": NODE_ID_1
}
]
},
{
"id": NODE_ID_3,
"model": {
"id": MODEL_ID_3,
"model_version": {
"id": MODEL_VERSION_ID_3
}
},
"node_inputs": [
{
"node_id": NODE_ID_2
}
]
}
]
}
]
});
const requestOptions = {
method: "PATCH",
headers: {
"Accept": 'application/json',
"Authorization": 'Key ' + PAT
},
body: raw
};
fetch(`https://api.clarifai.com/v2/workflows`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the details of the
// workflow 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 Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change these to update your own workflow
const WORKFLOW_ID = "my-custom-workflow";
const NODE_ID_1 = "audio-to-text";
const MODEL_ID_1 = "asr-wav2vec2-base-960h-english";
const MODEL_VERSION_ID_1 = "f4deae70a473492a8e2f9b7bb1dbee85";
const NODE_ID_2 = "text-summarization";
const MODEL_ID_2 = "text-summarization-english-distilbart-cnn-12-6";
const MODEL_VERSION_ID_2 = "8279cec2221a4b1d9db774470940aebd";
const NODE_ID_3 = "english-to-french";
const MODEL_ID_3 = "translation-english-to-french-text";
const MODEL_VERSION_ID_3 = "c65a4a51c2b646fca5f0e4bf1ff200d7";
/////////////////////////////////////////////////////////////////////////////
// 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.PatchWorkflows(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID,
},
action: "overwrite",
workflows: [
{
id: WORKFLOW_ID,
nodes: [
{
id: NODE_ID_1,
model: {
id: MODEL_ID_1,
model_version: {
id: MODEL_VERSION_ID_1,
}
}
},
{
id: NODE_ID_2,
model: {
id: MODEL_ID_2,
model_version: {
id: MODEL_VERSION_ID_2
}
},
node_inputs: [
{
node_id: NODE_ID_1
}
]
},
{
id: NODE_ID_3,
model: {
id: MODEL_ID_3,
model_version: {
id: MODEL_VERSION_ID_3
}
},
node_inputs: [
{
node_id: NODE_ID_2
}
]
}
]
}
]
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error(
"Patch workflows 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.StatusCode;
public class ClarifaiExample {
///////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the details of the
// workflow 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 workflow
static final String WORKFLOW_ID = "my-custom-workflow";
static final String NODE_ID_1 = "audio-to-text";
static final String MODEL_ID_1 = "asr-wav2vec2-base-960h-english";
static final String MODEL_VERSION_ID_1 = "f4deae70a473492a8e2f9b7bb1dbee85";
static final String NODE_ID_2 = "text-summarization";
static final String MODEL_ID_2 = "text-summarization-english-distilbart-cnn-12-6";
static final String MODEL_VERSION_ID_2 = "8279cec2221a4b1d9db774470940aebd";
static final String NODE_ID_3 = "english-to-french";
static final String MODEL_ID_3 = "translation-english-to-french-text";
static final String MODEL_VERSION_ID_3 = "c65a4a51c2b646fca5f0e4bf1ff200d7";
///////////////////////////////////////////////////////////////////////////////////
// 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));
MultiWorkflowResponse patchWorkflowsResponse = stub.patchWorkflows(
PatchWorkflowsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setAction("overwrite")
.addWorkflows(
Workflow.newBuilder()
.setId(WORKFLOW_ID)
.addNodes(
WorkflowNode.newBuilder()
.setId(NODE_ID_1)
.setModel(
Model.newBuilder()
.setId(MODEL_ID_1)
.setModelVersion(ModelVersion.newBuilder().setId(MODEL_VERSION_ID_1))
)
)
.addNodes(
WorkflowNode.newBuilder()
.setId(NODE_ID_2)
.setModel(
Model.newBuilder()
.setId(MODEL_ID_2)
.setModelVersion(ModelVersion.newBuilder().setId(MODEL_VERSION_ID_2))
)
.addNodeInputs(NodeInput.newBuilder().setNodeId(NODE_ID_1))
)
.addNodes(
WorkflowNode.newBuilder()
.setId(NODE_ID_3)
.setModel(
Model.newBuilder()
.setId(MODEL_ID_3)
.setModelVersion(ModelVersion.newBuilder().setId(MODEL_VERSION_ID_3))
)
.addNodeInputs(NodeInput.newBuilder().setNodeId(NODE_ID_2))
)
).build()
);
if (patchWorkflowsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Patch workflows failed, status: " + patchWorkflowsResponse.getStatus());
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
//////////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the details of the
// workflow 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 Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to update your own workflow
$WORKFLOW_ID = "my-custom-workflow";
$NODE_ID_1 = "audio-to-text";
$MODEL_ID_1 = "asr-wav2vec2-base-960h-english";
$MODEL_VERSION_ID_1 = "f4deae70a473492a8e2f9b7bb1dbee85";
$NODE_ID_2 = "text-summarization";
$MODEL_ID_2 = "text-summarization-english-distilbart-cnn-12-6";
$MODEL_VERSION_ID_2 = "8279cec2221a4b1d9db774470940aebd";
$NODE_ID_3 = "english-to-french";
$MODEL_ID_3 = "translation-english-to-french-text";
$MODEL_VERSION_ID_3 = "c65a4a51c2b646fca5f0e4bf1ff200d7";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\PatchWorkflowsRequest;
use Clarifai\Api\Workflow;
use Clarifai\Api\WorkflowNode;
use Clarifai\Api\NodeInput;
use Clarifai\Api\Model;
use Clarifai\Api\ModelVersion;
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
->PatchWorkflows(
// The request object carries the request along with the request status and other metadata related to the request itself
new PatchWorkflowsRequest([
"user_app_id" => $userDataObject,
"action" => "overwrite",
"workflows" => [
new Workflow([
"id" => $WORKFLOW_ID,
"nodes" => [
new WorkflowNode([
"id" => $NODE_ID_1,
"model" => new Model([
"id" => $MODEL_ID_1,
"model_version" => new ModelVersion([
"id" => $MODEL_VERSION_ID_1,
]),
]),
]),
new WorkflowNode([
"id" => $NODE_ID_2,
"model" => new Model([
"id" => $MODEL_ID_2,
"model_version" => new ModelVersion([
"id" => $MODEL_VERSION_ID_2,
]),
]),
"node_inputs" => [
new NodeInput([
"node_id" => $NODE_ID_1,
]),
],
]),
new WorkflowNode([
"id" => $NODE_ID_3,
"model" => new Model([
"id" => $MODEL_ID_3,
"model_version" => new ModelVersion([
"id" => $MODEL_VERSION_ID_3,
]),
]),
"node_inputs" => [
new NodeInput([
"node_id" => $NODE_ID_2,
]),
],
]),
],
]),
],
]),
$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/workflows/" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_PAT_HERE" \
--data-raw '{
"action": "overwrite",
"workflows": [
{
"id": "my-custom-workflow",
"nodes": [
{
"id": "audio-to-text",
"model": {
"id": "asr-wav2vec2-base-960h-english",
"model_version": {
"id": "f4deae70a473492a8e2f9b7bb1dbee85"
}
}
},
{
"id": "text-summarization",
"model": {
"id": "text-summarization-english-distilbart-cnn-12-6",
"model_version": {
"id": "8279cec2221a4b1d9db774470940aebd"
}
},
"node_inputs": [
{
"node_id": "audio-to-text"
}
]
},
{
"id": "english-to-french",
"model": {
"id": "translation-english-to-french-text",
"model_version": {
"id": "c65a4a51c2b646fca5f0e4bf1ff200d7"
}
},
"node_inputs": [
{
"node_id": "text-summarization"
}
]
}
]
}
]
}'
Patch YAML Configuration, Description, etc
Below is an example of performing patch operations on a workflow, where the YAML configuration is updated, and changes are made to its description, notes, and image URL.
- Python SDK
from clarifai.client.app import App
app = App(app_id="YOUR_APP_ID_HERE", user_id="YOUR_USER_ID_HERE", pat="YOUR_PAT_HERE")
# Update an existing workflow to use a different yml configuration like "demographics"
WORKFLOW_ID = general_workflow.kwargs['id']
app.patch_workflow(workflow_id=WORKFLOW_ID, action="merge", config_filepath="configs/demographics.yml")
# Update workflow details, such as description, notes, etc
app.patch_workflow(workflow_id=WORKFLOW_ID, action="merge", description="description", notes="notes", image_url="https://samples.clarifai.com/metro-north.jpg")
# Remove the workflow's image by specifying the 'remove' action
app.patch_workflow(workflow_id=WORKFLOW_ID, action="remove", image_url="https://samples.clarifai.com/metro-north.jpg")
Delete
Be certain that you want to delete a particular workflow as the operation cannot be undone.
Delete Workflow by ID
You can delete a specific workflow.
- Python SDK
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
from clarifai.client.app import App
# Your PAT (Personal Access Token) can be found in the Account's Security section
app = App(app_id="APP_ID", user_id="USER_ID", pat="YOUR_PAT")
# Delete the workflow within an application
app.delete_workflow(workflow_id="workflow-id")
###################################################################################
# In this section, we set the user authentication, app ID, and the ID of the
# workflow 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 Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change this to delete your own workflow
WORKFLOW_ID = 'my-custom-workflow'
##########################################################################
# 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
delete_workflow_response = stub.DeleteWorkflow(
service_pb2.DeleteWorkflowRequest(
user_app_id=userDataObject,
workflow_id=WORKFLOW_ID
),
metadata=metadata
)
if delete_workflow_response.status.code != status_code_pb2.SUCCESS:
print(delete_workflow_response.status)
raise Exception("Delete workflow failed, status: " + delete_workflow_response.status.description)
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the ID of the
// workflow we want to delete. Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////////
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change this to delete your own workflow
const WORKFLOW_ID = "my-custom-workflow";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: "DELETE",
headers: {
"Accept": "application/json",
"Authorization": "Key " + PAT,
},
};
fetch(
`https://api.clarifai.com/v2/users/me/apps/${APP_ID}/workflows/${WORKFLOW_ID}`,
requestOptions
)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
</script>
//index.js file
//////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the ID of the
// workflow 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 Account's Security section
const PAT = "YOUR_PAT_HERE";
const APP_ID = "YOUR_APP_ID_HERE";
// Change this to delete your own workflow
const WORKFLOW_ID = "my-custom-workflow";
/////////////////////////////////////////////////////////////////////////////
// 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.DeleteWorkflow(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID,
},
workflow_id: WORKFLOW_ID,
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error(
"Delete workflow 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.BaseResponse;
import com.clarifai.grpc.api.status.StatusCode;
public class ClarifaiExample {
//////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the ID of the
// workflow 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 this to delete your own workflow
static final String WORKFLOW_ID = "my-custom-workflow";
///////////////////////////////////////////////////////////////////////////////////
// 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 deleteWorkflowResponse = stub.deleteWorkflow(
DeleteWorkflowRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setWorkflowId(WORKFLOW_ID)
.build()
);
if (deleteWorkflowResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Delete workflow failed, status: " + deleteWorkflowResponse.getStatus());
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
/////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and the ID of the
// workflow 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 Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change this to delete your own workflow
$WORKFLOW_ID = "my-custom-workflow";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\DeleteWorkflowRequest;
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
->DeleteWorkflow(
// The request object carries the request along with the request status and other metadata related to the request itself
new DeleteWorkflowRequest([
"user_app_id" => $userDataObject,
"workflow_id" => $WORKFLOW_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) {
throw new Exception(
"Failure response: " .
$response->getStatus()->getDescription() .
" " .
$response->getStatus()->getDetails()
);
}
?>
curl -X DELETE "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/workflows/YOUR_WORKFLOW_ID_HERE" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_PAT_HERE"
Output
2024-01-18 16:34:46 INFO clarifai.client.app: app.py:653
Workflow Deleted
code: SUCCESS
description: "Ok"
req_id: "a979f35e9c826bb9046f4d92879c6b7c"
Delete all Workflows
You can delete all custom workflows.
Instead of delete_all
, you can specify a list of workflow IDs to be deleted, using the ids
field.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- 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 Account's Security section
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
delete_workflows_response = stub.DeleteWorkflows(
service_pb2.DeleteWorkflowsRequest(
user_app_id=userDataObject,
delete_all=True
# ids = ['workflow_id_1', 'workflow_id_2'] # Specify a list of workflow IDs to be deleted
),
metadata=metadata
)
if delete_workflows_response.status.code != status_code_pb2.SUCCESS:
print(delete_workflows_response.status)
raise Exception("Delete workflows failed, status: " + delete_workflows_response.status.description)
<!--index.html file-->
<script>
/////////////////////////////////////////////////////////////////////
// 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 Account's Security section
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 raw = JSON.stringify({
"user_app_id": {
"user_id": USER_ID,
"app_id": APP_ID,
},
"delete_all": true,
//"ids": ['workflow_id_1', 'workflow_id_2'] // Specify a list of workflow IDs to be deleted
});
const requestOptions = {
method: "DELETE",
headers: {
"Accept": "application/json",
"Authorization": "Key " + PAT,
},
body: raw,
};
fetch(`https://api.clarifai.com/v2/workflows`, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
</script>
//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 Account's Security section
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.DeleteWorkflows(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID,
},
delete_all: true
//ids: ['workflow_id_1', 'workflow_id_2'] // Specify a list of workflow IDs to be deleted
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error(
"Delete workflows 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.BaseResponse;
import com.clarifai.grpc.api.status.StatusCode;
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));
BaseResponse deleteWorkflowsResponse = stub.deleteWorkflows(
DeleteWorkflowsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setDeleteAll(true)
.build()
);
if (deleteWorkflowsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Delete workflows failed, status: " + deleteWorkflowsResponse.getStatus());
}
}
}
<?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 Account's Security section
$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\DeleteWorkflowsRequest;
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
->DeleteWorkflows(
// The request object carries the request along with the request status and other metadata related to the request itself
new DeleteWorkflowsRequest([
"user_app_id" => $userDataObject,
"delete_all" => true,
]),
$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) {
throw new Exception(
"Failure response: " .
$response->getStatus()->getDescription() .
" " .
$response->getStatus()->getDetails()
);
}
?>
curl -X DELETE "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/workflows" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_PAT_HERE" \
--data-raw '{
"delete_all": true
}'
Export Workflow
You can easily export your entire workflow as a YAML file. This local copy enables convenient editing and offers the flexibility to create, reuse, or manage workflows with ease.
- Python SDK
from clarifai.client.workflow import Workflow
# Your PAT (Personal Access Token) can be found in the Account's Security section
workflow_url = "https://clarifai.com/clarifai/main/workflows/Demographics"
demographics_workflow = Workflow(
url=workflow_url , pat="YOUR_PAT"
)
demographics_workflow.export("demographics_workflow.yml")
"""
Now the parameters of each model can be changed and new workflow can be easily created by app.create_workflow().
Here we change the margin parameter of the image cropper node to be 1.5
- id: image-crop
model:
model_id: margin-100-image-crop-custom
model_type_id: image-crop
description: Custom crop model
output_info:
params:
margin: 1.5
"""