Python API Reference
Clarifai Python SDK API Reference
This is the API Reference documentation extracted from the source code.
App
class App(url=None, app_id=None, user_id=None, base_url="https://api.clarifai.com", pat=None, token=None, root_certificates_path=None, **kwargs)
App is a class that provides access to Clarifai API endpoints related to App information.
Parameters:
url(str) - The URL to initialize the app objectapp_id(str) - The App ID for the App to interact withuser_id(str) - The user ID of the ownerbase_url(str) - Base API url. Default "https://api.clarifai.com"pat(str) - A personal access token for authentication. Can be set as env var CLARIFAI_PATtoken(str) - A session token for authentication. Can be set as env var CLARIFAI_SESSION_TOKENroot_certificates_path(str) - Path to the SSL root certificates file**kwargs- Additional keyword arguments:name(str) - The name of the appdescription(str) - The description of the app
App.create_concepts
App.create_concepts(concept_ids, concepts=[])
Add concepts to the app.
Parameters:
concept_ids(List[str]) - List of concept IDs to addconcepts(List[str]) - Optional list of concept names
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
app.create_concepts(concept_ids=["concept_id_1", "concept_id_2"])
App.create_concept_relations
App.create_concept_relations(subject_concept_id, object_concept_ids, predicates)
Creates concept relations between concepts.
Parameters:
subject_concept_id(str) - Subject concept IDobject_concept_ids(List[str]) - Object concept IDspredicates(List[str]) - Relation predicates
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
app.create_concept_relations(
subject_concept_id="subject_id",
object_concept_ids=["object_id_1", "object_id_2"],
predicates=["predicate_1", "predicate_2"]
)
App.create_dataset
App.create_dataset(dataset_id, **kwargs)
Creates a dataset in the app.
Parameters:
dataset_id(str) - The dataset ID to create**kwargs- Additional dataset arguments
Returns:
- Dataset object for the created dataset
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
dataset = app.create_dataset(dataset_id="dataset_id")
App.create_model
App.create_model(model_id, **kwargs)
Creates a model in the app.
Parameters:
model_id(str) - The model ID to create**kwargs- Additional model arguments
Returns:
- Model object for the created model
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
model = app.create_model(model_id="model_id")
App.create_module
App.create_module(module_id, description, **kwargs)
Creates a module in the app.
Parameters:
module_id(str) - The module ID to createdescription(str) - Module description**kwargs- Additional module arguments
Returns:
- Module object for the created module
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
module = app.create_module(module_id="module_id", description="Module description")
App.create_workflow
App.create_workflow(config_filepath, generate_new_id=False, display=True)
Creates a workflow in the app.
Parameters:
config_filepath(str) - Path to workflow config YAML filegenerate_new_id(bool) - Generate new workflow ID if Truedisplay(bool) - Display workflow tree if True
Returns:
- Workflow object for the created workflow
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
workflow = app.create_workflow(config_filepath="config.yml")
App.dataset
App.dataset(dataset_id, dataset_version_id=None, **kwargs)
Returns a Dataset object.
Parameters:
dataset_id(str) - Dataset ID to getdataset_version_id(str) - Optional dataset version ID**kwargs- Additional arguments
Returns:
- Dataset object for the specified ID
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
dataset = app.dataset(dataset_id="dataset_id")
App.delete_concept_relations
App.delete_concept_relations(concept_id, concept_relation_ids=[])
Deletes concept relations for a concept.
Parameters:
concept_id(str) - Concept ID to delete relations forconcept_relation_ids(List[str]) - Optional specific relation IDs to delete
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
app.delete_concept_relations(concept_id="concept_id")
App.delete_dataset
App.delete_dataset(dataset_id)
Deletes a dataset by ID.
Parameters:
dataset_id(str) - Dataset ID to delete
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
app.delete_dataset(dataset_id="dataset_id")
App.delete_model
App.delete_model(model_id)
Deletes a model by ID.
Parameters:
model_id(str) - Model ID to delete
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
app.delete_model(model_id="model_id")
App.delete_module
App.delete_module(module_id)
Deletes a module by ID.
Parameters:
module_id(str) - Module ID to delete
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
app.delete_module(module_id="module_id")
App.delete_workflow
App.delete_workflow(workflow_id)
Deletes a workflow by ID.
Parameters:
workflow_id(str) - Workflow ID to delete
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
app.delete_workflow(workflow_id="workflow_id")
App.get_input_count
App.get_input_count()
Gets count of all inputs in the app.
Returns:
- Total number of processed inputs
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
count = app.get_input_count()
App.inputs
App.inputs()
Returns an Input object.
Returns:
- Inputs object for managing app inputs
App.list_concepts
App.list_concepts(page_no=None, per_page=None)
Lists all concepts in the app.
Parameters:
page_no(int) - Page number to listper_page(int) - Items per page
Yields:
- Concept objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
concepts = list(app.list_concepts())
App.list_datasets
App.list_datasets(page_no=None, per_page=None)
Lists all datasets in the app.
Parameters:
page_no(int) - Page number to listper_page(int) - Items per page
Yields:
- Dataset objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
datasets = list(app.list_datasets())
App.list_installed_module_versions
App.list_installed_module_versions(filter_by={}, page_no=None, per_page=None)
Lists installed module versions.
Parameters:
filter_by(dict) - Filters to applypage_no(int) - Page number to listper_page(int) - Items per page
Yields:
- Module objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
versions = list(app.list_installed_module_versions())
App.list_models
App.list_models(filter_by={}, only_in_app=True, page_no=None, per_page=None)
Lists models in the app.
Parameters:
filter_by(dict) - Filters to applyonly_in_app(bool) - Only list app models if Truepage_no(int) - Page number to listper_page(int) - Items per page
Yields:
- Model objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
models = list(app.list_models())
App.list_modules
App.list_modules(filter_by={}, only_in_app=True, page_no=None, per_page=None)
Lists modules in the app.
Parameters:
filter_by(dict) - Filters to applyonly_in_app(bool) - Only list app modules if Truepage_no(int) - Page number to listper_page(int) - Items per page
Yields:
- Module objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
modules = list(app.list_modules())
App.list_pipelines
App.list_pipelines(filter_by={}, only_in_app=True, page_no=None, per_page=None)
Lists all pipelines for the user.
Parameters:
filter_by(dict) - Filters to applyonly_in_app(bool) - Only list app pipelines if Truepage_no(int) - Page number to listper_page(int) - Items per page
Yields:
- Pipeline objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
pipelines = list(app.list_pipelines())
App.list_pipeline_steps
App.list_pipeline_steps(pipeline_id=None, filter_by={}, only_in_app=True, page_no=None, per_page=None)
Lists all pipeline steps for the user.
Parameters:
pipeline_id(str) - Optional pipeline ID to filter stepsfilter_by(dict) - Filters to applyonly_in_app(bool) - Only list app pipeline steps if Truepage_no(int) - Page number to listper_page(int) - Items per page
Yields:
- PipelineStep objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
pipeline_steps = list(app.list_pipeline_steps())
App.list_trainable_model_types
App.list_trainable_model_types()
Lists trainable model types.
Returns:
- List of trainable model type names
Example:
from clarifai.client.app import App
types = app.list_trainable_model_types()
App.list_workflows
App.list_workflows(filter_by={}, only_in_app=True, page_no=None, per_page=None)
Lists workflows in the app.
Parameters:
filter_by(dict) - Filters to applyonly_in_app(bool) - Only list app workflows if Truepage_no(int) - Page number to listper_page(int) - Items per page
Yields:
- Workflow objects
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
workflows = list(app.list_workflows())
App.model
App.model(model_id, model_version={'id': ""}, **kwargs)
Returns a Model object.
Parameters:
model_id(str) - Model ID to getmodel_version(Dict) - Optional model version info**kwargs- Additional arguments
Returns:
- Model object for specified ID
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
model = app.model(model_id="model_id", model_version={"id": "model_version_id"})
App.module
App.module(module_id, **kwargs)
Returns a Module object.
Parameters:
module_id(str) - Module ID to get**kwargs- Additional arguments
Returns:
- Module object for specified ID
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
module = app.module(module_id="module_id")
App.patch_dataset
App.patch_dataset(dataset_id, action='merge', **kwargs)
Updates a dataset.
Parameters:
dataset_id(str) - Dataset ID to updateaction(str) - Update action ('merge'/'overwrite'/'remove')**kwargs- Properties to update
Returns:
- Updated Dataset object
App.patch_model
App.patch_model(model_id, action='merge', **kwargs)
Updates a model.
Parameters:
model_id(str) - Model ID to updateaction(str) - Update action ('merge'/'overwrite'/'remove')**kwargs- Properties to update
Returns:
- Updated Model object
App.patch_workflow
App.patch_workflow(workflow_id, action='merge', config_filepath=None, **kwargs)
Updates a workflow by workflow id.
Parameters:
workflow_id(str) - The Workflow ID to patchaction(str) - Action to perform ('merge'/'overwrite'/'remove')config_filepath(str) - Optional path to workflow config YAML file**kwargs- Additional properties to update
Returns:
- Updated Workflow object
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
workflow = app.patch_workflow(workflow_id="workflow_id", description="New description")
App.search
App.search(**kwargs)
Returns a Search object for the user and app ID.
Parameters:
- See the Search class in clarifai.client.search for kwargs
Returns:
- Search object for the user and app ID
Example:
from clarifai.client.app import App
app = App(app_id="app_id", user_id="user_id")
search_client = app.search(top_k=12, metric="euclidean")