Tracking an AI asset in a notebook

If you are using the watsonx.governance or AI Factsheets service (version 4.8.3 or later), learn how to track and govern AI assets in a notebook.

To track an AI asset programmatically, use the Python client documentation or the IBM_AIGOV_FACTS_CLIENT documentation to register an asset and add it to an AI use case.

The sample code demonstrates how to register and track a machine learning model.

Tracking an AI asset

If your model is in a notebook, you can insert code to register the model with an AI use case.

  1. Create a use case:
model_usecase_catalog_id = "b54179b3-d6f9-4886-bd48-a248c60d1f36" # Specify the catalog to store the use case
model_usecase_name="model_usecase_name_here"
model_usecase_desc="model usecase for data here"

model_usecase = facts_client.assets.create_model_usecase(catalog_id=model_usecase_catalog_id,name=model_usecase_name,description=model_usecase_desc)
model_usecase.get_info(True)
  1. Create an approach in the use case:
name_approach = model_usecase.create_approach(name="nameapproach",description="approach for data here")
name_approach.get_info()
  1. Retrieve the approach:
retrieve_approaches = model_usecase.get_approaches()
name_approach = model_usecase.get_approach(approach_id=retrieve_approaches[0].get_id())
  1. Track the model in the use case:
wml_model = facts_client.assets.get_model(model_id="your model id ",container_type="project",container_id="container id")## model id is the auto ai model id
wml_model.track(model_usecase=model_usecase,approach=name_approach,version_number="major",version_comment="name model major version")

For details on using Python commands to interact with AI use cases, see Python client documentation and the IBM_AIGOV_FACTS_CLIENT documentation.

Learn more

Parent topic: Tracking assets in an AI use case.