Important:

IBM Cloud Pak® for Data Version 4.8 will reach end of support (EOS) on 31 July, 2025. For more information, see the Discontinuance of service announcement for IBM Cloud Pak for Data Version 4.X.
Upgrade to IBM Software Hub Version 5.1 before IBM Cloud Pak for Data Version 4.8 reaches end of support. For more information, see Upgrading from IBM Cloud Pak for Data Version 4.8 to IBM Software Hub Version 5.1.

Attaching files to a factsheet using the Python client

Add file attachments to a factsheet to provide supplemental detail. For example, attach model visualizations or a requirements document to support the use case.

You can attach images or files that support your use case to a factsheet by using the AIGovFacts python client utility.

Service The required service is not available by default. An administrator must install the AI Factsheets service and dependent services on the Cloud Pak for Data platform. To determine whether the service is installed, open the Services catalog, and check whether the service is enabled.

Important:

This topic applies to the AI Factsheets service versions 4.8.0 through 4.8.2. If you are using the watsonx.governance service or AI Factsheets service 4.8.3 or later, see documentation for Governing in AI use cases.

If you want to define attachment definitions and attachment groups so that users can attach files to a factsheet by using the model inventory, see Administering AI Factsheets.

The code for attaching a file or image looks as follows:

model=facts_client.assets.get_model(model_id='94566964-de43-4cdf-8af4-10ad12e268db')
model.set_attachment_fact(file_to_upload="./artifacts/roc_curve.jpeg",description="Roc curve for the model",fact_id="roc_curve_001",html_rendering_hint="inline_image")

Once attached, the images display as follows:

File attachments for a factsheet

When the facts are added to a model, you can view them in the model details page in the Other Attachments section. From that section, you can preview, download and delete the file attachment or image facts.

Viewing attachments

How you view an attachment depends on the file type.

  • If the fact is of type image, then it shows up as inline image and users can preview, download, or delete the attachment.
  • If the fact is of type document, there is no inline image. Users can preview, download, or delete the file.
  • Attachments are included with reports generated from factsheets.
  • Attachment facts are not synced to OpenPages when integration with OpenPages is enabled.

Learn more

Parent topic: Managing an inventory of model assets