Setup

Note

  • Either API_KEY from IBM Cloud or Cloud Pak for Data details should be used when initiating client

  • If using IBM Cloud API_KEY or Cloud pak for Data details and it is not for external models, container type of either project or space and related container id should be specified

class FactsClientAdapter(experiment_name: str = None, container_type: str | None = None, container_id: str | None = None, api_key: str | None = None, set_as_current_experiment: bool | None = False, enable_autolog: bool | None = True, external_model: bool | None = False, cloud_pak_for_data_configs: CloudPakforDataConfig = None, disable_tracing: bool | None = False, enable_push_framework: bool | None = False)

Bases: FactsAuthClient

AI GOVERNANCE FACTS CLIENT

Variables:

version (str) – Returns version of the python library.

Parameters:
  • experiment_name (str) – Name of the Experiment.

  • container_type (str) – (Optional) Name of the container where model would be saved. Currently supported options are SPACE or PROJECT. It is (Required) when using Watson Machine Learning.

  • container_id (str) – (Optional) container id specific to container type.It is (Required) when using Watson Machine Learning.

  • set_as_current_experiment (bool) – (Optional) if True new experiment will not be created if experiment already exists with same experiment name.By default set to False.

  • enable_autolog (bool) – (Optional) if False, manual log option will be available. By default set to True.

  • external_model (bool) – (Optional) if True, external models tracing would be enabled. By default set to False.

  • cloud_pak_for_data_configs (CloudPakforDataConfig) – (Optional) Cloud pak for data cluster details.

  • disable_tracing (bool) – (Optional) if True, tracing and logging utilities will be disabled. Default to False.

  • enable_push_framework (bool) – (Optional) if True, enable_push_framework support will be enabled. Default to False.

The way to use is:

Watsonx Governance Factsheet(Cloud)

>>> from ibm_aigov_facts_client import AIGovFactsClient
>>> client = AIGovFactsClient(api_key=<API_KEY>, experiment_name="test",container_type="space or project",container_id=<space_id or project_id>)

If using existing experiment as current:

>>> client = AIGovFactsClient(api_key=<API_KEY>, experiment_name="test",container_type="space",container_id=<space_id>,set_as_current_experiment=True)

If using external models with manual log:

>>> client= AIGovFactsClient(api_key=API_KEY,experiment_name="external",enable_autolog=False,external_model=True)

If using external models with Autolog:

>>> client= AIGovFactsClient(api_key=API_KEY,experiment_name="external",external_model=True)

If using push framework:

client = AIGovFactsClient(api_key=<API_KEY>, experiment_name="test",container_type="space or project",container_id=<space_id or project_id>,enable_push_framework=True)

Cloud Pak for Data (On Prem)

>>> from ibm_aigov_facts_client import AIGovFactsClient,CloudPakforDataConfig
>>> cpd_creds=CloudPakforDataConfig(service_url="<hosturl>",username="<username>",password="<password>")
>>> client = AIGovFactsClient(experiment_name="<name of experiment>",container_type="<space or project>",container_id="<space_id or project_id>",cloud_pak_for_data_configs=cpd_creds)

If API_KEY is available

>>> from ibm_aigov_facts_client import AIGovFactsClient,CloudPakforDataConfig
>>> cpd_creds=CloudPakforDataConfig(service_url="<hosturl>",username="<username>",api_key="<api_key>")
>>> client = AIGovFactsClient(experiment_name="<name of experiment>",container_type="<space or project>",container_id="<space_id or project_id>",cloud_pak_for_data_configs=cpd_creds)

If Cloud Pak for Data platform has IAM enabled:

>>> from ibm_aigov_facts_client import AIGovFactsClient,CloudPakforDataConfig
>>> cpd_creds=CloudPakforDataConfig(service_url="<hosturl>",username="<username>",password="<password>",bedrock_url="<cluster bedrock url>")
>>> client = AIGovFactsClient(experiment_name="<name of experiment>",container_type="<space or project>",container_id="<space_id or project_id>",cloud_pak_for_data_configs=cpd_creds )

if disable tracing as a whole and use other features like custom facts and facts definitions

>>> client = AIGovFactsClient(container_type=<project or space>,container_id=<space or project id>,cloud_pak_for_data_configs=creds,disable_tracing=True)
>>> client = AIGovFactsClient(external_model=True,cloud_pak_for_data_configs=creds,disable_tracing=True)

For Standalone use in localhost without factsheet functionality:

>>> from ibm_aigov_facts_client import AIGovFactsClient
>>> client = AIGovFactsClient(experiment_name="test")
get_access_token()

Method to get IAM access token

The way to use me is:

>>> client.get_access_token()

Retrieve Installed Version

get_cpd_version(self) str

Get Cloud Pak for Data version. If it’s cloud then it’ll return as SaaS

Return type:

CP4D version or SaaS if it’s cloud.

The way to use me is:

>>> client.assets.get_cpd_version()