Inventory Management

This section focuses on the creation and management of inventory.

The inventory is a view where you can define an AI use case to request a new model, and then track the model and related assets through its lifecycle.

Attention

Important Information for Inventory Creation

To create an inventory in IBM Cloud, you need access to cloud object storage. Ensure you have the following roles:

  • Manager role for service access.

  • Administrator role for platform access in the cloud object storage (COS).

For the watsonx.governance Platform, the assigned role must have the following permissions:

  • Manage Catalogs: Allows the creation and management of catalogs.

  • Access Catalogs: Grants permission to view and add users as collaborators to catalogs.

create_inventory(self, name: str, description: str, cloud_object_storage_name: str = None) AIGovInventoryUtilities

Create a new inventory item.

This method creates an inventory item with the specified name and description.

Note:
  • If using IBM Cloud, provide the cloud_object_storage_name to properly associate the inventory with a Cloud Object Storage (COS) instance.

Parameters:
  • name (str): The name of the inventory item to be created.

  • description (str): A brief description of the inventory item.

  • cloud_object_storage_name (str, optional): The name of the cloud object storage instance to associate with the inventory. Required if using IBM Cloud.To retrieve the available COS instances, see the documentation for the get_cloud_object_storage_instances function.

Returns:

InventoryUtilities`: An instance of AIGovInventoryUtilities representing the created inventory item.

Example:

  1. Creating an inventory in the Watsonx.Governance platform:

    >>> inventory = client.assets.create_inventory(name="My Inventory", description="This is a test inventory.")
    
  2. Creating an inventory with a COS name in IBM Cloud:

    >>> inventory = client.assets.create_inventory(name="Data Inventory", description="Inventory for data storage", cloud_object_storage_name="my-cos-instance")
    
get_inventory(self, inventory_id: str) AIGovInventoryUtilities

Retrieve a specific inventory by its inventory_id.

This method fetches the details of a specific inventory item using its inventory_id. The returned inventory is represented as an instance of AIGovInventoryUtilities.

Parameters:

inventory_id (str): The unique identifier of the inventory item to retrieve.

Returns:

AIGovInventoryUtilities: An instance of AIGovInventoryUtilities representing the requested inventory item.

Example:
>>> inventory = client.assets.get_inventory(inventory_id="993738-383****")
list_inventories(self, name: str = None, exact_match: bool = False) list[AIGovInventoryUtilities]

List All Inventories

This method retrieves and returns a list of all inventories associated with the account. Each inventory item is represented as an instance of AIGovInventoryUtilities.

Args:
  • name (str, optional): The name of the inventory to filter the results. If provided, the method will search for inventories matching this name.

  • exact_match (bool, optional): If set to True, the method will perform an exact match on the inventory name. Default is False, which allows for partial matches.

Returns:

list[AIGovInventoryUtilities]: A list of AIGovInventoryUtilities instances, each representing an inventory item.

Examples:
>>> inventories = client.assets.list_inventories()  # Retrieve all inventories
>>> inventories = client.assets.list_inventories(name="sample")  # Retrieve inventories matching "sample"
>>> inventories = client.assets.list_inventories(name="sample", exact_match=True)  # Retrieve inventories with an exact match for "sample"