Installation

The package is available on pypi. Please use below command to install it.

$pip install -U ibm-aigov-facts-client

Requirements

  • Only Python 3.7 or newer is supported. ibm-cloud-sdk-core ==3.10.1 is required to be able to authenticate to the service.

  • For factsheet service, Watson Knowledge Catalog is a requirement

  • If using Space container, Watson Machine Learning is a requirement

  • If using Project container, Watson Studio is a requirement

Supported engines

  • Watson Machine Learning

  • External ML engines (i.e., AWS Sagemaker, Microsoft Azure etc.)

Note

  • For native learners in external ML engines, ONLY manual logging is supported.

Guidelines and example workflow

Note

  • Initiate facts client at the top of the notebook before importing anything.For external models, it can be imported in training custom scripts.

  • Each use case can be referred as Experiment and any training with one or different machine learning frameworks are considered as Run where each experiment can have multiple runs.

  • It is advised to use one Experiment for any given use case and notebook to avoid creating multiple experiments for no reason as that will impact lineage tracking and comparison.

  • To allow facts show with stored Watson machine learning model and lineage tracking, users should set custom meta attributes before storing model using given utility (see Watson Machine Learning Elements).

  • For native learners in external providers (i.e., AWS Sagemaker: Linear learner etc.), autolog is not supported, manual log option should be used.

  • When using external models, make sure to use same experiment name when initiating client to track notebook experiments with your model asset.

_images/basic_workflow.png _images/external_workflow.png

Basic logging elements

AIGovFactsClient

class FactsClientAdapter(experiment_name: Optional[str] = None, container_type: Optional[str] = None, container_id: Optional[str] = None, api_key: Optional[str] = None, set_as_current_experiment: Optional[bool] = False, enable_autolog: Optional[bool] = True, external_model: Optional[bool] = False, cloud_pak_for_data_configs: Optional[CloudPakforDataConfig] = None, disable_tracing: Optional[bool] = 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.

A way you might use me is:

For IBM 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)

For Cloud Pak for Data:

>>> 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)

OR use API_KEY

>>> 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_CP4D_version()
get_cpd_version() 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()

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

AIGovFactsClient.FrameworkSupportNames

class FrameworkSupportOptions

To view supported frameworks , use:

>>> client.FrameworkSupportNames.show()

To see only supported framework names , use:

>>> client.FrameworkSupportNames.get()

Set of Supported Frameworks for Auto logging. Manual log is not version dependent.

Available Options:

Name

Framework Name

Autolog

Manual Log

Version

scikit

sklearn

Y

Y

0.22.1 <= scikit-learn <= 1.1.2

Tensorflow

tensorflow

Y

Y

2.3.0 <= tensorflow <= 2.9.1

Keras

keras

Y

Y

2.3.0 <= keras <= 2.9.0

PySpark

pyspark

Y

Y

3.0.0 <= pyspark <= 3.4.0

Xgboost

xgboost

Y

Y

1.1.1 <= xgboost <= 1.6.1

LightGBM

lightgbm

Y

Y

2.3.1 <= lightgbm <= 3.3.2

PyTorch

pytorch

Y

Y

1.0.5 <= pytorch-lightning <= 1.7.1

Scikit learn

class FrameworkSupportSklearn

Current autolog support scope for Scikit learn.

Available Options:

Framework Name

Trigger Methods

Training Metrics

Parameters

Tags

Post Training Metrics

Search Estimators

sklearn

  • estimator.fit()

  • estimator.fit_predict()

  • estimator.fit_transform()

Classifier:

  • precision score

  • recall score

  • f1 score

  • accuracy score

If the classifier has method predict_proba

  • log loss

  • roc auc score

Regression:

  • mean squared error

  • root mean squared error

  • mean absolute error

  • r2 score

estimator.get_params(deep=True)

  • estimator class name(e.g. “LinearRegression”)

  • fully qualified estimator class name(e.g. “sklearn.linear_model._base.LinearRegression”)

Scikit-learn metric APIs:

  • model.score

  • metric APIs defined in the sklearn.metrics module

Note:

  • metric key format is: {metric_name}[-{call_index}]_{dataset_name}

  • if sklearn.metrics: metric_name is the metric function name

  • if model.score, then metric_name is {model_class_name}_score

If multiple calls are made to the same scikit-learn metric API

each subsequent call adds a “call_index” (starting from 2) to the metric key

Meta estimator:

  • Pipeline,

  • GridSearchCV ,

  • RandomizedSearchCV

It logs child runs with metrics for each set of

explored parameters, as well as parameters

for the best model and the best parameters (if available)

Note

  • In notebook setting, if post training metrics need to be logged, make sure including all calculations in one cell with estimator fit() call. Metrics calculation not part of the same cell will not be logged automatically.

  • Scikit-learn metric APIs invoked on derived objects do not log metrics

  • If user define a scorer which is not based on metric APIs in sklearn.metrics, then then post training metric autologging for the scorer is invalid

PySpark

class FrameworkSupportSpark

Current autolog support scope for Spark.

Available Options:

Framework Name

Trigger Methods

Training Metrics

Parameters

Tags

Post Training Metrics

Search Estimators

pyspark

estimator.fit(), except for

estimators (featurizers) under pyspark.ml.feature

Not Supported

estimator.params

If a param value is also an Estimator

then params in the the wrapped estimator will also be logged, the nested

param key will be {estimator_uid}.{param_name}

  • estimator class name(e.g. “LinearRegression”)

  • fully qualified estimator class name(e.g. “pyspark.ml.regression.LinearRegression”)

pyspark ML evaluators used under Evaluator.evaluate

  • metric key format is: {metric_name}[-{call_index}]_{dataset_name}

  • Metric name: Evaluator.getMetricName()

If multiple calls are made to the same pyspark ML evaluator metric API

each subsequent call adds a “call_index” (starting from 2) to the metric key

Meta estimator:

  • Pipeline,

  • CrossValidator,

  • TrainValidationSplit,

  • OneVsRest

It logs child runs with metrics for each set of

explored parameters, as well as parameters

for the best model and the best parameters (if available)

Note

  • In notebook setting, if post training metrics need to be logged, make sure including all calculations in one cell with estimator fit() call. Metrics calculation not part of the same cell will not be logged automatically.

  • Facts client can not find run information for other objects derived from a given prediction result (e.g. by doing some transformation on the prediction result dataset)

Keras

class FrameworkSupportKeras

Current autolog support scope for Keras.

Available Options:

Framework Name

Trigger Methods

Training Metrics

Parameters

keras

estimator.fit()

  • Training loss,

  • Validation loss,

  • User specified metrics,

Metricss related EarlyStopping callbacks:

  • stopped_epoch,

  • restored_epoch,

  • restore_best_weight,

  • last_epoch etc.

  • fit() or fit_generator() params,

  • Optimizer name,

  • Learning rate,

  • Epsilon,

Params related to EarlyStopping:

  • min-delta,

  • patience,

  • baseline,

  • restore_best_weights etc.

Note

  • EarlyStopping Integration with Keras AutoLogging will detect if an EarlyStopping callback is used in a fit() or fit_generator() call, and if the restore_best_weights parameter is set to be True, then MLflow will log the metrics associated with the restored model as a final, extra step. The epoch of the restored model will also be logged as the metric restored_epoch. This allows for easy comparison between the actual metrics of the restored model and the metrics of other models.If restore_best_weights is set to be False, then MLflow will not log an additional step.

  • Regardless of restore_best_weights, client will also log stopped_epoch, which indicates the epoch at which training stopped due to early stopping.

  • If training does not end due to early stopping, then stopped_epoch will be logged as 0.

  • Client will also log the parameters of the EarlyStopping callback, excluding mode and verbose

Tensorflow

class FrameworkSupportTensorflow

Current autolog support scope for Tensorflow.

Available Options:

Framework Name

Trigger Methods

Training Metrics

Parameters

tensorflow

estimator.fit()

  • Training loss,

  • Validation loss,

  • User specified metrics,

Metricss related EarlyStopping callbacks:

  • stopped_epoch,

  • restored_epoch,

  • restore_best_weight,

  • last_epoch etc.

TensorBoard metrics:

  • average_loss,

  • loss

Tensorflow Core:

  • tf.summary.scalar calls

  • fit() or fit_generator() params,

  • Optimizer name,

  • Learning rate,

  • Epsilon,

Params related to EarlyStopping:

  • min-delta,

  • patience,

  • baseline,

  • restore_best_weights etc.

Tensorboard params:

  • steps,

  • max_steps

XGBoost

class FrameworkSupportXGB

Current autolog support scope for XGBoost.

Available Options:

Framework Name

Trigger Methods

Training Metrics

Parameters

xgboost

  • xgboost.train(),

  • scikit-learn APIs.`fit()`

  • Metrics at each iteration (if evals specified),

  • Metrics at best iteration (if early_stopping_rounds specified)

  • params specified in xgboost.train or fit()

LightGBM

class FrameworkSupportLGBM

Current autolog support scope for LightGBM.

Available Options:

Framework Name

Trigger Methods

Training Metrics

Parameters

lightgbm

lightgbm.train()

  • Metrics at each iteration (if evals specified),

  • Metrics at best iteration (if early_stopping_rounds specified)

  • params specified in lightgbm.train

PyTorch

class FrameworkSupportPyTorch

Current autolog support scope for PyTorch.

Available Options:

Framework Name

Trigger Methods

Training Metrics

Parameters

pytorch

pytorch_lightning.Trainer()

i.e., models that subclass pytorch_lightning.LightningModule

  • Training loss,

  • Validation loss,

  • average_test_accuracy,

  • user defined metrics,

Metricss related EarlyStopping callbacks:

  • stopped_epoch,

  • restored_epoch,

  • restore_best_weight,

  • last_epoch etc.

  • fit() parameters,

  • optimizer name,

  • learning rate,

  • epsilon,

Params related to EarlyStopping:

  • min-delta,

  • patience,

  • baseline,

  • restore_best_weights etc.

Note

  • Only PyTorch Lightning models are supported.

  • Vanilla PyTorch models that only subclass torch.nn.Module is not yet available.

Basic Utilities

Note

  • Following utlities are subject to local storage which facts client uses as an intermediary step. In case when using Watson Studio notebook environment, reloading notebooks sessions might cause exceptions to local storage thus these utilities will not function as expected but it does not impact results saved to factsheet and users would be able to see results through factsheet UI.

AIGovFactsClient.experiments

class Experiments(root_directory=None)

Bases: object

Utility to explore current experiments.

list_experiments(max_results: int = 100) DataFrame

List all active experiments.

Returns

DataFrame object.

Return type

Pandas.DataFrame

A way you might use me is:

>>> client.experiments.list_experiments()
get_current_experiment_id()

Shows current experiment id.

Returns

str

A way you might use me is:

>>> client.experiments.get_current_experiment_id()

AIGovFactsClient.runs

class Runs(root_directory=None)

Bases: object

Utilities to explore runs within any experiment.

list_runs_by_experiment(experiment_id: str, order_by: Optional[List[str]] = None) DataFrame

List all runs under any experiment

Parameters
  • experiment_id (str) – ID of the experiment.

  • order_by – List of order_by clauses. Currently supported values are metric.key, parameter.key, tag.key.For example, order_by=["tag.release ASC", "metric.training_score DESC"]

Returns

DataFrame object that satisfy the search expressions.

Return type

Pandas.DataFrame

A way you might use me is:

>>> client.runs.list_runs_by_experiment("1")
>>> client.runs.list_runs_by_experiment("1", order_by=["metric.training_score DESC"]))
get_current_run_id()

Shows current active run id.

Returns

str

A way you might use me is:

>>> client.runs.get_current_run_id()

Factsheet modify existing run elements

AIGovFactsClient.runs

class Runs(root_directory=None)

Bases: object

Utilities to explore runs within any experiment.

log_metric(run_id: str, key: str, value: float, step: Optional[int] = None) None

Log a metric against the run ID.

Parameters
  • run_id (str) – The unique id for run.

  • key (str) – Metric name.

  • value (float) – Metric value (float).

  • step (int) – Integer training step (iteration) at which was the metric calculated. Defaults to 0.

Returns

None

A way you might use me is:

>>> client.runs.log_metric(run_id, "mae", .77)
log_metrics(run_id: str, metrics: Dict[str, float], step: Optional[int] = None) None

Log multiple metrics for the given run.

Parameters
  • run_id (str) – The unique id for run.

  • metrics (dict) – Dictionary of metric_name: String -> value: Float.

  • step (int) – Integer training step (iteration) at which was the metric calculated. Defaults to 0.

Returns

None

A way you might use me is:

>>> client.runs.log_metrics(run_id, {"mse": 2000.00, "rmse": 50.00})
log_param(run_id: str, key: str, value: Any) None

Log a param against the run ID.

Parameters
  • run_id (str) – The unique id for run.

  • key (str) – Param name.

  • value – Param value.Value is converted to a string.

Returns

None

A way you might use me is:

>>> client.runs.log_param(run_id, "c", 1)
log_params(run_id, params: Dict[str, Any]) None

Log multiple params for the given run.

Parameters
  • run_id (str) – The unique id for run.

  • params (dict) – Dictionary of String -> value: (String, but will be string-ified if not)

Returns

None

A way you might use me is:

>>> client.runs.log_params(run_id, {"n_estimators": 3, "random_state": 42})
set_tags(run_id: str, tags: Dict[str, Any]) None

Log multiple tags for the given run.

Parameters
  • run_id (str) – The unique id for run.

  • tags (dict) – Dictionary of tags names: String -> value: (String, but will be string-ified if not)

Returns

None

A way you might use me is:

>>> client.runs.set_tags(run_id, {"engineering": "ML Platform",
"release.candidate": "RC1"})

Factsheet custom export elements

Note

  • Following export_payload utility to be used in cases when user needs something additional logged under any given training run. After autolog is done sending results to factsheet, user can use (see Factsheet modify existing run elements) utilities to add new metrics, params and tags as applicable to any given training run and export updated results to factsheet.

  • It is subject to local storage which facts client uses as an intermediary step. In case when using Watson Studio notebook environment, reloading notebooks sessions might cause exceptions to local storage thus these utilities will not function as expected. In cases like that, users are expected to reinitiate facts client using same experiment name, re-run training cells, update any results needed and export to factsheet.

  • To associate exported payload with Watson Machine learning model, custom meta attributes need to be set invoking prepare_model_meta().

AIGovFactsClient.export_facts

class ExportFacts(facts_service_client: FactsClientAdapter, **kwargs)

Bases: FactsheetServiceClientAutolog

Export updated payloads for any run

export_payload(run_id: str, root_directory: Optional[str] = None) DetailedResponse

Export single run to factsheet service.

Parameters
  • run_id (str) – Id of run to be exported

  • root_directory (str) – (Optional) Absolute path for directory containing experiments and runs.

Returns

A DetailedResponse containing the factsheet response result

Return type

DetailedResponse

A way you might use me is:

>>> client.export_facts.export_payload(<RUN_ID>)
prepare_model_meta(wml_client: object, meta_props: Dict[str, Any], experiment_name: Optional[str] = None) Dict

Add current experiment attributes to model meta properties

Parameters
  • wml_client (object) – Watson Machine learning client object.

  • meta_props (dict) – Current model meta properties.

  • experiment_name (str) – (Optional) Explicit name any experiment to be used.

Returns

A Dict containing the updated meta properties.

Return type

Dict

A way you might use me is:

>>> client.export_facts.prepare_model_meta(wml_client=<wml_client>,meta_props=<wml_model_meta_props>)
class ExportFactsManual(facts_service_client: FactsClientAdapter, **kwargs)

Bases: FactsheetServiceClientManual

Export payloads for any run tracked by manual log

export_payload_manual(run_id: str, root_directory: Optional[str] = None) DetailedResponse

Export single run to factsheet when using manual logging option. Use this option when client is initiated with enable_autolog=False and external_model=True

Parameters
  • run_id (str) – Id of run to be exported

  • root_directory (str) – (Optional) Absolute path for directory containing experiments and runs.

Returns

A DetailedResponse containing the factsheet response result

Return type

DetailedResponse

A way you might use me is:

>>> client.export_facts.export_payload_manual(<RUN_ID>)
prepare_model_meta(wml_client: object, meta_props: Dict[str, Any], experiment_name: Optional[str] = None) Dict

Add current experiment attributes to model meta properties

Parameters
  • wml_client (object) – Watson Machine learning client object.

  • meta_props (dict) – Current model meta properties.

  • experiment_name (str) – (Optional) Explicit name any experiment to be used.

Returns

A Dict containing the updated meta properties.

Return type

Dict

A way you might use me is:

>>> client.export_facts.prepare_model_meta(wml_client=<wml_client>,meta_props=<wml_model_meta_props>)

Factsheet manual log elements

Note

  • Use manual log if,
    • Model framework is not supported for AutoLogging

    • External models where framework not supported for autolog or model built with third party native frameworks in external platforms (Azure, Sagemaker etc.)

AIGovFactsClient.manual_log

class ManualLog(experiment_name=None, set_as_current_exp=None, root_dir=None)

Bases: object

Enables user to trace experiments from external machine learning engines manually.

start_trace(experiment_id: Optional[str] = None)

Start a tracing session when using manual log option. By default it uses the current experiment used in client initialization.

Parameters

experiment_id (str) – (Optional) ID of experiment. This will start logging session under specific experiment so runs will be under specific experiment.

A way you might use me is:

>>> client.manual_log.start_trace()
>>> client.manual_log.start_trace(experiment_id="1")
log_metric(key: str, value: float, step: Optional[int] = None) None

Log a metric against active run.

Parameters
  • key (str) – Metric name.

  • value (float) – Metric value (float).

  • step (int) – Integer training step (iteration) at which was the metric calculated. Defaults to 0.

Returns

None

A way you might use me is:

>>> client.manual_log.log_metric("mae", .77)
log_metrics(metrics: Dict[str, float], step: Optional[int] = None) None

Log multiple metrics under active run.

Parameters
  • metrics (dict) – Dictionary of metric_name: String -> value: Float.

  • step (int) – Integer training step (iteration) at which was the metric calculated. Defaults to 0.

Returns

None

A way you might use me is:

>>> client.manual_log.log_metrics({"mse": 2000.00, "rmse": 50.00})
log_param(key: str, value: Any) None

Log a param against active run.

Parameters
  • key (str) – Param name.

  • value – Param value.Value is converted to a string.

Returns

None

A way you might use me is:

>>> client.manual_log.log_param("c", 1)
log_params(params: Dict[str, Any]) None

Log multiple params under active run.

Parameters

params (dict) – Dictionary of String -> value: (String, but will be string-ified if not)

Returns

None

A way you might use me is:

>>> client.manual_log.log_params({"n_estimators": 3, "random_state": 42})
set_tag(key: str, value: Any) None

Log tag for active run.

Parameters
  • key (str) – Param name.

  • value – Param value.Value is converted to a string.

Returns

None

A way you might use me is:

>>> client.manual_log.set_tag("engineering", "ML Platform")
set_tags(tags: Dict[str, Any]) None

Log multiple tags for active run.

Parameters

tags (dict) – Dictionary of tags names: String -> value: (String, but will be string-ified if not)

Returns

None

A way you might use me is:

>>> client.manual_log.set_tags({"engineering": "ML Platform",
"release.candidate": "RC1"})
end_trace()

End a active session.

A way you might use me is:

>>> client.manual_log.end_trace()

Factsheet asset elements

Note

Sample custom facts definitions csv can be downloaded from here csv

AIGovFactsClient.Assets

class Assets(facts_client: FactsClientAdapter)
create_custom_facts_definitions(csvFilePath, type_name: Optional[str] = None, section_name: Optional[str] = None, overwrite=True)

Utility to add custom facts attribute properties of model or model usecase.

Parameters
  • csvFilePath (str) – File path of csv having the asset properties.

  • type_name (str) – Asset type user needs to add/update. Current options are modelfacts_user,`model_entry_user`. Default is set to modelfacts_user.

  • section_name (str) – Custom name to show for custom attribute section. Applies only to model_entry_user type.

  • overwrite (bool) – (Optional) Merge or replace current properties. Default is True.

A way you might use me is:

>>> client.assets.create_custom_facts_definitions("Asset_type_definition.csv") # uses default type `modelfacts_user` type
>>> client.assets.create_custom_facts_definitions("Asset_type_definition.csv",type_name="model_entry_user", localized_name=<custom name for attributes section>,overwrite=False)
get_facts_definitions(type_name: str, container_type: Optional[str] = None, container_id: Optional[str] = None) Dict

Get all facts definitions

Parameters
  • type_name (str) – Asset fact type. Current options are modelfacts_user and model_entry_user.

  • container_type (str) – (Optional) Asset container type. Options are project, space or catalog. Default to container type used when initiating client.

  • container_id (str) – (Optional) Asset container id. Default to container id when initiating client

Return type

dict

A way you might use me is:

>>> client.assets.get_facts_definitions(type_name=<fact type>) # uses container type and id used initializing facts client
>>> client.assets.get_facts_definitions(type_name=<fact type>,container_type=<container type>,container_id=<container id>)
get_prompt(prompt_id: Optional[str] = None, container_type: Optional[str] = None, container_id: Optional[str] = None) AIGovAssetUtilities

Get prompt asset.

Parameters
  • prompt_id (str) – Id of the prompt asset.

  • container_type (str) – Name of the container where prompt is saved. Currently supported container_type are space or project.

  • container_id (str) – Id of the container where prompt asset is saved.

Return type

AIGovAssetUtilities

The way to use me is:

>>> client.assets.get_prompt(prompt_id=<prompt_id>,container_type=<project>,container_id=<project id>)
get_model(model_id: Optional[str] = None, container_type: Optional[str] = None, container_id: Optional[str] = None, wml_stored_model_details: Optional[dict] = None, is_prompt: bool = False)

Get model asset.

Parameters
  • model_id (str) – (Optional) Id of the model asset.

  • container_type (str) – (Optional) Name of the container where model is saved. Currently supported container_type are space or project. For external models it is not needed and defaulted to catalog.

  • container_id (str) – (Optional) Id of the container where model asset is saved. For external models, it refers to catalog id where model stub is saved. if not provided for external models,if available and user have access, default platform asset catalog is used

  • wml_stored_model_details (dict) – (Optional) Watson machine learning model details. Applied to Watson Machine Learning models only.

Return type

ModelAssetUtilities

The way to use me is:

>>> client.assets.get_model(model_id=<model_id>) # uses container type and id used to initiate client
>>> client.assets.get_model(model_id=<model id>,container_type=<space or project>,container_id=<space or project id>)
>>> client.assets.get_model(wml_stored_model_details=<wml model details>) # uses model id, container type and id part of model details

for external models,

>>> client.assets.get_model(model_id=<model_id>) # uses available platform asset catalog id as container_id
>>> client.assets.get_model(model_id=<model_id>,container_id=<catalog id>)
get_ai_usecase(id: str, catalog_id: Optional[str] = None) AIUsecaseUtilities

Get AI usecase asset.

Parameters
  • ai_usecase_id (str) – Id of the ai usecase.

  • catalog_id (str) – Id of the catalog where ai usecase is saved.

Return type

AIUsecaseUtilities

The way to use me is:

>>> client.assets.get_ai_usecase(ai_usecase_id=<ai usecase id>, catalog_id=<catalog id>)
get_model_usecase(model_usecase_id: str, catalog_id: Optional[str] = None, is_prompt: bool = False) ModelUsecaseUtilities

Get model usecase asset.

Parameters
  • model_usecase_id (str) – Id of the model usecase.

  • catalog_id (str) – Id of the catalog where model usecase is saved.

Return type

ModelUsecaseUtilities

The way to use me is:

>>> client.assets.get_model_usecase(model_usecase_id=<model usecase id>, catalog_id=<catalog id>)
get_default_inventory_details()

Retrieves details for the default inventory along with the username also.

Usage:
>>> client.assets.get_default_inventory_details()
remove_asset(asset_id: str, container_type: Optional[str] = None, container_id: Optional[str] = None)

Remove a model or prompt or model usecase asset

Parameters
  • asset_id (str) – Id of the asset

  • container_type (str, optional) – container where asset is stored, defaults to container type use when initiating client

  • container_id (str, optional) – container id where asset is stored, defaults to container id used when initiating client. For external models, if not provided, uses available platform asset catalog.

Raises

ClientError – Report exception details

The way you can use me is :

>>> client.assets.remove_asset(asset_id=<model or model usecase id>)
>>> client.assets.remove_asset(asset_id=<model or model usecase id>,container_type=<space,project or catalog>, container_id=<container id>)
list_model_usecases(catalog_id: str = None) list

Warning

ibm_aigov_facts_client.factsheet.assets.Assets.list_model_usecases is deprecated. This method will be removed in a future release.Use client.assets.get_model_usecases() instead.

Returns WKC Model usecase assets

Parameters

catalog_id (str) – Catalog ID where registered model usecase. if not provided, dafault shows all model usecases in all catalogs across all accounts to which the user has access.

Returns

All WKC Model usecase assets for a catalog

Return type

list

Example:

>>> client.assets.list_model_usecases(catalog_id=<catalog_id>)
>>> client.assets.list_model_usecases()
create_model_usecase(catalog_id: Optional[str] = None, name: Optional[str] = None, description: Optional[str] = None) ModelUsecaseUtilities

Returns WKC Model usecase

Parameters
  • catalog_id (str) – Catalog ID where this model usecase needs to create.

  • name (str) – Name of model usecase

  • description (str) – (Optional) Model usecase description

Return type

ModelUsecaseUtilities

Returns

WKC Model usecase asset

Example:

>>> client.assets.create_model_usecase(catalog_id=<catalog_id>,name=<model usecase name>,description=<model usecase description>)
get_ai_usecases(catalog_id: Optional[str] = None) list

Returns AI usecase assets

Parameters

catalog_id (str) – (Optional) Catalog ID where AI usecase are registered. if not provided, dafault shows all AI usecases in all catalogs across all accounts to which the user has access.

Return type

list(AIUsecaseUtilities)

Returns

All AI usecase assets for a catalog

Example:

>>> client.assets.get_ai_usecases(catalog_id=<catalog_id>)
>>> client.assets.get_ai_usecases()
get_model_usecases(catalog_id: Optional[str] = None, is_prompt: bool = False) list

Returns WKC Model usecase assets

Parameters

catalog_id (str) – (Optional) Catalog ID where model usecase are registered. if not provided, dafault shows all model usecases in all catalogs across all accounts to which the user has access.

Return type

list(ModelUsecaseUtilities)

Returns

All WKC Model usecase assets for a catalog

Example:

>>> client.assets.get_model_usecases(catalog_id=<catalog_id>)
>>> client.assets.get_model_usecases()
get_PAC_id() str

Get Platform Asset Catalog ( PAC ) ID.

Return type

PAC ID

The way to use me is:

>>> client.assets.get_PAC_id()
get_attachment_definitions(type_name: Optional[str] = None) List

Get all attachment fact definitions for model or model_usecase. Supported for CPD version >=4.6.5

Returns

All attachment fact definitions for model or model_usecase

Return type

list()

The way to use me is:

>>> client.assets.get_attachment_definitions(type_name=<model or model_usecase>)
create_ai_usecase(catalog_id: Optional[str] = None, name: Optional[str] = None, description: Optional[str] = None, status: Optional[str] = None, risk: Optional[str] = None, tags: Optional[list] = None) AIUsecaseUtilities

Returns AI usecase

Parameters
  • catalog_id (str) – Catalog ID where this model usecase needs to create.

  • name (str) – Name of model usecase

  • description (str) – (Optional) Model usecase description

  • status (str) – (Optional) AI Usecase status. It can be one of the following keywords: “draft”, “awaiting development”, “developed”, “promoted to pre-production”, “Deployed for validation”, “Validated”, “Approved”, “Promoted to production”, “Deployed for operation”, “In operation”, “Under revision”, “Decommissioned”

  • risk (str) – (Optional) AI Usecase risk. It can be one of the following keywords: “High”, “Medium”, “Low”, “Custom”, “None”

  • tags (list) – (Optional) AI usecase tags. Provide list of tags, for example [“usecase for prod”,”model for prod”]

Return type

AIUsecaseUtilities

Returns

AI usecase asset

Example:

>>> client.assets.create_ai_usecase(catalog_id=<catalog_id>,name=<AI usecase name>,description=<AI usecase description>)

Model helpers:

Note

When using get/set environments APIs, some important points to note are:

  • Change is not allowed when model is saved in project. You need to promote to space first.

  • Change is not allowed when model is monitored in Watson OpenScale.

  • Switching from TEST` to DEVELOP` environment is not allowed.

  • TEST environment is similar to DEPLOY in Cloud pak for data UI until 4.6.3 release. There is no difference in functionalities. From 4.6.3 onwards the environment will be called/showed as TEST in Cloud pak for data platform.

class ModelAssetUtilities

Model asset utilities. Running client.assets.model() makes all methods in ModelAssetUtilities object available to use.

get_info(verbose=False) Dict

Get model object details

Parameters

verbose (bool, optional) – If True, returns additional model details. Defaults to False

Return type

dict

The way to use me is:

>>> get_model.get_info()
>>> get_model.get_info(verbose=True)
get_tracking_model_usecase() ModelUsecaseUtilities

Get model use case associated to the model.

Return type

ModelUsecaseUtilities

A way you might use me is:

>>> model.get_tracking_model_usecase()
add_tracking_model_usecase(model_usecase_name: str = None, model_usecase_desc: str = None, model_usecase_id: str = None, model_usecase_catalog_id: str = None, grc_model_id: str = None)

Warning

ibm_aigov_facts_client.factsheet.asset_utils_model.ModelAssetUtilities.add_tracking_model_usecase is deprecated. This method will be removed in a future release.Use model.track() instead.

Link Model to model use case. Model asset should be stored in either Project or Space and corrsponding ID should be provided when registering to model use case.

Parameters
  • model_usecase_name (str) – (Optional) New model use case name. Used only when creating new model use case.

  • model_usecase_desc (str) – (Optional) New model use case description. Used only when creating new model use case.

  • model_usecase_id (str) – (Optional) Existing model use case to link with.

  • model_usecase_catalog_id (str) – (Optional) Catalog ID where model use case exist.

  • grc_model_id (str) – (Optional) Openpages model id. Only applicable for CPD environments.

For new model use case:

>>> model.add_tracking_model_usecase(model_usecase_name=<name>,model_usecase_desc=<description>)

For linking to existing model use case:

>>> model.add_tracking_model_usecase(model_usecase_id=<model use case id to link with>,model_usecase_catalog_id=<model use case catalog id>)
remove_tracking_model_usecase()

Warning

ibm_aigov_facts_client.factsheet.asset_utils_model.ModelAssetUtilities.remove_tracking_model_usecase is deprecated. This method will be removed in a future release.Use model.untrack() instead.

Unregister from model use case

Example for IBM Cloud or CPD:

>>> model.remove_tracking_model_usecase()
set_custom_fact(fact_id: str, value: Any) None

Set custom fact by given id.

Parameters
  • fact_id (str) – Custom fact id.

  • value (any) – Value of custom fact. It can be string, integer, date. if custom fact definition attribute is_array is set to True, value can be a string or list of strings.

A way you might use me is:

>>> model.set_custom_fact(fact_id="custom_int",value=50)
>>> model.set_custom_fact(fact_id="custom_string",value="test")
>>> model.set_custom_fact(fact_id="custom_string",value=["test","test2"]) # allowed if attribute property `is_array` is true.
set_custom_facts(facts_dict: Dict[str, Any]) None

Set multiple custom facts.

Parameters

facts_dict (dict) – Multiple custom facts. Example: {id: value, id1: value1, …}

A way you might use me is:

>>> model.set_custom_facts({"fact_1": 2, "fact_2": "test", "fact_3":["data1","data2"]})
get_custom_fact_by_id(fact_id: str)

Get custom fact value/s by id

Parameters

fact_id (str) – Custom fact id to retrieve.

A way you might use me is:

>>> model.get_custom_fact_by_id(fact_id="fact_id")
get_custom_facts() Dict

Get all defined custom facts for modelfacts_user fact type.

Return type

dict

A way you might use me is:

>>> model.get_custom_facts()
get_all_facts() Dict

Get all facts related to asset.

Return type

dict

A way you might use me is:

>>> model.get_all_facts()
get_facts_by_type(facts_type: Optional[str] = None) Dict

Get custom facts by asset type.

Parameters

facts_type (str) – (Optional) Custom facts asset type. Default to modelfacts_user type. For Openpages facts, use modelfacts_user_op.

Return type

dict

A way you might use me is:

>>> model.get_facts_by_type(facts_type=<type name>)
remove_custom_fact(fact_id: str) None

Remove custom fact by id

Parameters

fact_id (str) – Custom fact id value/s to remove.

A way you might use me is:

>>> model.remove_custom_fact(fact_id=<fact_id>)
remove_custom_facts(fact_ids: List[str]) None

Remove multiple custom facts

Parameters

fact_ids (list) – Custom fact ids to remove.

A way you might use me is:

>>> model.remove_custom_facts(fact_ids=["id1","id2"])
get_environment_type() Dict

Get current environement details for related model asset. .

Return type

dict

A way you might use me is:

>>> model.get_environment_type()
set_environment_type(from_container: str, to_container: str) None

Set current container for model asset. For available options check ModelEntryContainerType

Parameters
  • from_container (str) – Container name to move from

  • to_container (str) – Container name to move to

A way you might use me is:

>>> model.set_environment_type(from_container="test",to_container="validate")
set_attachment_fact(file_to_upload, description: str, fact_id: str, html_rendering_hint: Optional[str] = None) None

Set attachment fact for given asset. Supported for CPD version >=4.6.5.

Parameters
  • file_to_upload (str) – Attachment file path to upload

  • description (str) – Description about the attachment file

  • fact_id (str) – Fact id for the attachment

  • html_rendering_hint (str) – (Optional) html rendering hint. Available options are in RenderingHints

A way to use me is:

>>> model.set_attachment_fact(file_to_upload="./artifacts/image.png",description=<file description>,fact_id=<custom fact id>)
>>> model.set_attachment_fact(file_to_upload="./artifacts/image.png",description=<file description>,fact_id=<custom fact id>,html_rendering_hint=<render hint>)
set_cell_attachment_fact(description: str, fact_id: str) None

Set attachment fact using captured cell output. Supported for CPD version >=4.6.5.

Parameters
  • description (str) – Description about the cell facts attachment file

  • fact_id (str) – Fact id for the attachment

A way to use me is:

>>> model.set_cell_attachment_fact(description=<file description>,fact_id=<custom fact id>)
has_attachment(fact_id: Optional[str] = None) bool

Check if attachment/s exist. Supported for CPD version >=4.6.5

Parameters

fact_id (str, optional) – Id of attachment fact

Return type

bool

The way to use me is :

>>> model.has_attachment()
>>> model.has_attachment(fact_id=<fact id>)
list_attachments(filter_by_factid: Optional[str] = None, format: str = 'dict')

List available attachments facts. Supported for CPD version >=4.6.5

Parameters
  • filter_by_factid (str) – (Optional) Fact id for the attachment to filter by

  • format (str) – Result output format. Default to dict. Available options are in FormatType

A way to use me is:

>>> model.list_attachments(format="str") # use this format if using output for `set_custom_fact()`
>>> model.list_attachments() # get all attachment facts
>>> model.list_attachments(filter_by_factid=<"fact_id_1">) # filter by associated fact_id_1
remove_attachment(fact_id: str)

Remove available attachments facts for given id.Supported for CPD version >=4.6.5

Parameters

fact_id (str) – Fact id of the attachment

A way to use me is:

>>> model.remove_attachment(fact_id=<fact id of attachment>)
remove_all_attachments()

Remove all attachments facts for given asset. Supported for CPD version >=4.6.5

A way to use me is:

>>> model.remove_all_attachments()
get_experiment(experiment_name: Optional[str] = None) NotebookExperimentUtilities

Get notebook experiment. Supported for CPD version >=4.6.4

A way to use me is:

>>> exp=model.get_experiment() # returns  experiment
>>> exp=model.get_experiment(experiment_name="test") # In case notebook experiment not available, you can initiate a new one and run to add details.
track(model_usecase: Optional[ModelUsecaseUtilities] = None, approach: Optional[ApproachUtilities] = None, grc_model: Optional[dict] = None, version_number: Optional[str] = None, version_comment: Optional[str] = None)

Link Model to model use case. Model asset should be stored in either Project or Space and corrsponding ID should be provided when registering to model use case.

Supported for CPD version >=4.7.0

Parameters
  • model_usecase (ModelUsecaseUtilities) – Instance of ModelUsecaseUtilities

  • approach (ApproachUtilities) – Instance of ApproachUtilities

  • grc_model (str) – (Optional) Openpages model id. Only applicable for CPD environments. This should be dictionary, output of get_grc_model()

  • version_number (str) – Version number of model. supports either a semantic versioning string or one of the following keywords for auto-incrementing based on the latest version in the approach: “patch”, “minor”, “major”

  • version_comment (str) – (Optional) An optional comment describing the changes made in this version

Return type

ModelAssetUtilities

For tracking model with model usecase:

>>> model.track(model_usecase=<instance of ModelUsecaseUtilities>,approach=<instance of ApproachUtilities>,version_number=<version>)
untrack()

Unlink model from it’s usecase and approach

Example for IBM Cloud or CPD:

>>> model.untrack()
get_version() Dict

Get model version details. Supported for CPD version >=4.7.0

Return type

dict

The way to use me is:

>>> get_model.get_version()
get_name() str

Returns model name

Returns

Model name

Return type

str

Example: >>> get_model.get_name()

get_id() str

Returns model ID

Returns

Model ID

Return type

str

Example: >>> get_model.get_id()

get_container_id() str

Returns model container ID

Returns

Model container ID

Return type

str

Example: >>> get_model.get_container_id()

get_container_type() str

Returns model container type

Returns

Model container type

Return type

str

Example: >>> get_model.get_container_type()

get_description() str

Returns model description

Returns

Model description

Return type

str

Example: >>> get_model.get_description()

get_deployments() List

Get all deployment details for the external model. Supported for CPD version >=4.7.0

Returns

All deployment details for external model

Return type

list(Deployment)

The way to use me is: >>> get_model.get_deployments()

delete_deployments(deployment_ids: Optional[list] = None)

Returns Delete the deployments in external model. Supported for CPD version >=4.7.0

Parameters

deployment_ids (list) – List of deployment ID’s to be deleted. Provide deployment_ids in a list.

Return type

None

Returns

External model deployments are deleted.

The way to use me is: >>> get_model.delete_deployments([deployment_ids])

add_deployments(deployments: Optional[list] = None) list

Returns Add deployments in external model. Supported for CPD version >=4.7.0

Parameters

deployments (list) – List of deployments to be added. Provide deployments in a list.

Return type

list(Deployment)

Returns

External model deployments are added

The way to use me is: >>> get_model.add_deployments([{“id”:”<id>”,”name”:”<name>”,”type”:”<type>”,”scoring_endpoint”:”<scoring_endpoint>”,”description”:”<description>”}])

Model use case helpers

class ModelUsecaseUtilities

Model use case utilities. Running client.assets.model_usecase() makes all methods in ModelUsecaseUtilities object available to use.

get_info(verbose=False) Dict

Get model use case details

Parameters

verbose (bool, optional) – If True, returns additional model details. Defaults to False

Return type

dict

The way to use me is:

>>> get_model_usecase.get_info()
>>> get_model_usecase.get_info(verbose=True)
get_tracked_models() list

Get models tracked in model use case

Returns

physical model details for all models in model use case

Return type

list[dict]

set_custom_fact(fact_id: str, value: Any) None

Set custom fact by given id.

Parameters
  • fact_id (str) – Custom fact id.

  • value (any) – Value of custom fact. It can be string, integer, date. if custom fact definition attribute is_array is set to True, value can be a string or list of strings.

A way you might use me is:

>>> model_usecase.set_custom_fact(fact_id="custom_int",value=50)
>>> model_usecase.set_custom_fact(fact_id="custom_string",value="test")
>>> model_usecase.set_custom_fact(fact_id="custom_string",value=["test","test2"]) # allowed if attribute property `is_array` is true.
set_custom_facts(facts_dict: Dict[str, Any]) None

Set multiple custom facts.

Parameters

facts_dict (dict) – Multiple custom facts. Example: {id: value, id1: value1, …}

A way you might use me is:

>>> model_usecase.set_custom_facts({"fact_1": 2, "fact_2": "test", "fact_3":["data1","data2"]})
get_custom_fact_by_id(fact_id: str)

Get custom fact value/s by id

Parameters

fact_id (str) – Custom fact id to retrieve.

A way you might use me is:

>>> model_usecase.get_custom_fact_by_id(fact_id="fact_id")
get_custom_facts() Dict

Get all defined custom facts for model_entry_user fact type.

Return type

dict

A way you might use me is:

>>> model_usecase.get_custom_facts()
get_all_facts() Dict

Get all facts related to asset.

Return type

dict

A way you might use me is:

>>> model_usecase.get_all_facts()
get_facts_by_type(facts_type: Optional[str] = None) Dict

Get custom facts by asset type.

Parameters

facts_type (str) – (Optional) Custom facts asset type.

Return type

dict

A way you might use me is:

>>> model_usecase.get_facts_by_type(facts_type=<type name>)
>>> model_usecase.get_facts_by_type() # default to model_entry_user type
remove_custom_fact(fact_id: str) None

Remove custom fact by id

Parameters

fact_id (str) – Custom fact id value/s to remove.

A way you might use me is:

>>> model_usecase.remove_custom_fact(fact_id=<fact_id>)
remove_custom_facts(fact_ids: List[str]) None

Remove multiple custom facts ids

Parameters

fact_ids (list) – Custom fact ids to remove.

A way you might use me is:

>>> model_usecase.remove_custom_facts(fact_ids=["id1","id2"])
set_attachment_fact(file_to_upload, description: str, fact_id: str, html_rendering_hint: Optional[str] = None) None

Set attachment fact for given model use case. Supported for CPD version >=4.6.5

Parameters
  • file_to_upload (str) – Attachment file path to upload

  • description (str) – Description about the attachment file

  • fact_id (str) – Fact id for the attachment

  • html_rendering_hint (str) – (Optional) html rendering hint. Available options are in RenderingHints

A way to use me is:

>>> model_usecase.set_attachment_fact(file_to_upload="./artifacts/image.png",description=<file description>,fact_id=<custom fact id>)
>>> model_usecase.set_attachment_fact(file_to_upload="./artifacts/image.png",description=<file description>,fact_id=<custom fact id>,html_rendering_hint=<render hint>)
set_cell_attachment_fact(description: str, fact_id: str) None

Set attachment fact using captured cell output. Supported for CPD version >=4.6.5.

Parameters
  • description (str) – Description about the cell facts attachment file

  • fact_id (str) – Fact id for the attachment

A way to use me is:

>>> model_usecase.set_cell_attachment_fact(description=<file description>,fact_id=<custom fact id>)
has_attachment(fact_id: Optional[str] = None) bool

Check if attachment/s exist. Supported for CPD version >=4.6.5

Parameters

fact_id (str, optional) – Id of attachment fact

Return type

bool

The way to use me is :

>>> model_usecase.has_attachment()
>>> model_usecase.has_attachment(fact_id=<fact id>)
list_attachments(filter_by_factid: Optional[str] = None, format: str = 'dict')

List available attachments facts. Supported for CPD version >=4.6.5

Parameters
  • filter_by_factid (str) – (Optional) Fact id for the attachment to filter by

  • format (str) – Result output format (dict or str). Default to dict.

A way to use me is:

>>> model_usecase.list_attachments(format="str") # use this format if using output for `set_custom_fact()`
>>> model_usecase.list_attachments() # get all attachment facts
>>> model_usecase.list_attachments(filter_by_factid=<"fact_id_1">) # filter by associated fact_id_1
remove_attachment(fact_id: str)

Remove available attachments facts for given id. Supported for CPD version >=4.6.5

Parameters

fact_id (str) – Fact id of the attachment

A way to use me is:

>>> model_usecase.remove_attachment(fact_id=<fact id of attachment>)
remove_all_attachments()

Remove all attachments facts for given asset. Supported for CPD version >=4.6.5

A way to use me is:

>>> model_usecase.remove_all_attachments()
remove_approach(approach: Optional[ApproachUtilities] = None)

Returns WKC Model usecase removed approache. Supported for CPD version >=4.7.0

Parameters

approach (ApproachUtilities) – Object or instance of ApproachUtilities

Return type

None

Returns

WKC Model usecase approache is removed

Example: >>> client.assets.model_usecase.remove_approach(approach=ApproachUtilities)

create_approach(name: Optional[str] = None, description: Optional[str] = None) ApproachUtilities

Returns WKC Model usecase approache. Supported for CPD version >=4.7.0

Parameters
  • name (str) – Name of approach

  • description (str) – (Optional) Description of approach

Return type

ApproachUtilities

Returns

WKC Model usecase approache

Example: >>> client.assets.model_usecase.create_approach(name=<approach name>,description=<approach description>) >>> client.assets.model_usecase.create_approach(name=<approach name>)

get_approaches() list

Returns list of WKC Model usecase approaches. Supported for CPD version >=4.7.0

Returns

All WKC Model usecase approaches

Return type

list(ApproachUtilities)

Example: >>> client.assets.model_usecase.get_approaches()

get_approach(approach_id: Optional[str] = None) ApproachUtilities

Returns WKC Model usecase approaches. Supported for CPD version >=4.7.0

Parameters

approach_id (str) – Approach ID

Return type

ApproachUtilities

Returns

Specific WKC Model usecase approache

Example: >>> client.assets.model_usecase.get_approach(approach_id=<approach_id>)

get_grc_models() list

Returns list of WKC Models associated with Openpages for a particular model usecase

Returns

All WKC Models associated with Openpages for a particular model usecase

Return type

list()

Example: >>> client.assets.model_usecase.get_grc_models()

get_grc_model(id: Optional[str] = None)

Returns list WKC Model associated with Openpages for a particular model usecase

Returns

WKC Model associated with Openpages for a particular model usecase

Return type

dictionary

Example: >>> client.assets.model_usecase.get_grc_model(id=<grc_model_id>)

get_name() str

Returns model usecase name

Returns

Model usecase name

Return type

str

Example: >>> client.assets.model_usecase.get_name()

get_id() str

Returns model usecase asset ID

Returns

Model usecase asset ID

Return type

str

Example: >>> client.assets.model_usecase.get_id()

get_container_id() str

Returns model usecase container ID

Returns

Model usecase container ID

Return type

str

Example: >>> client.assets.model_usecase.get_container_id()

get_container_type() str

Returns model usecase container type

Returns

Model usecase container type

Return type

str

Example: >>> client.assets.model_usecase.get_container_type()

get_description() str

Returns model usecase description

Returns

Model usecase description

Return type

str

Example: >>> client.assets.model_usecase.get_description()

relate_models(reference_model_asset_id: Optional[str] = None, model_asset_id: Optional[str] = None)

Returns Update master_id for a model

Returns

Update master_id for a model, now both models will be in same row.

Return type

None

Example: >>> client.assets.model_usecase.get_grc_model(id=<grc_model_id>)

Notebook experiment management utils

Note

  • You can only use these api once the model is saved either in Stuio using Watson Machine Learning or as external models in Catalog.

  • Once the model is available, set the model using model=facts_client.assets.get_model() and you can use model.get_experiment() so all experiment management utilities APIs will be available to use.

Experiment management utilities

class NotebookExperimentUtilities

Model notebook experiment utilities. Running client.assets.model() makes all methods in NotebookExperimentUtilities object available to use.

get_info()

Get experiment info. Supported for CPD version >=4.6.4

A way to use me is:

>>> exp=model.get_experiment()
>>> exp.get_info()
get_run(run_id: Optional[str] = None) NotebookExperimentRunsUtilities

Get run object available in notebook experiment. Supported for CPD version >=4.6.4

A way to use me is:

>>> run=exp.get_run() # returns latest run object available
>>> run=exp.get_run(run_id=run_id) # you can get specific run object
get_all_runs()

Get all runs available in notebook experiment. Supported for CPD version >=4.6.4

A way to use me is:

>>> exp.get_all_runs()

Runs management utilities

class NotebookExperimentRunsUtilities

Model notebook experiment runs utilities. Running client.assets.model() makes all methods in NotebookExperimentUtilities object available to use.

get_info()

Get run info. Supported for CPD version >=4.6.4

A way to use me is:

>>> run=exp.get_run() # returns latest if run_id is not given
>>> run.get_info()
set_custom_metric(metric_id: str, value: float) None

Set model training metric

Parameters
  • metric_id (str) – Metric key name

  • value (float) – Metric value

Raises

ClientError – Raises client error for exceptions

Returns

None

A way to use me is:

>>> model.set_custom_metric(metric_key=<key>,value=<value>)
set_custom_metrics(metrics_dict: Dict[str, Any]) None

Set model training metrics

Parameters

metrics_dict (dict) – Metric key,value pairs.

Raises

ClientError – Raises client error for exceptions

Returns

None

A way to use me is:

>>> model.set_custom_metrics(metrics_dict={"training_score":0.955, "training_mse":0.911})
set_custom_param(param_id: str, value: str) None

Set model training param

Parameters
  • param_id (str) – Param key name

  • value (str) – Param value

Raises

ClientError – Raises client error for exceptions

Returns

None

A way to use me is:

>>> model.set_custom_param(param_id=<key>,value=<value>)
set_custom_params(params_dict: Dict[str, Any]) None

Set model training params

Parameters

params_dict (dict) – Params key,value pairs.

Raises

ClientError – Raises client error for exceptions

Returns

None

A way to use me is:

>>> model.set_custom_params(params_dict={"num_class":3,"early_stopping_rounds":10})
set_custom_tag(tag_id: str, value: str) None

Set model training tag

Parameters
  • tag_id (str) – Tag key name

  • value (str) – Tag value

Raises

ClientError – Raises client error for exceptions

Returns

None

A way to use me is:

>>> model.set_custom_tag(tag_id=<key>,value=<value>)
set_custom_tags(tags_dict: Dict[str, Any]) None

Set model training tags

Parameters

tags_dict (dict) – Tags key,value pairs.

Raises

ClientError – Raises client error for exceptions

Returns

None

A way to use me is:

>>> model.set_custom_tags(tags_dict={"tag1":<value>,"tag2":<value>})
get_custom_metric(metric_id: str) List

Get custom metric value by id

Parameters

metric_id (str) – Custom metric id to retrieve.

Return type

list

A way you might use me is:

>>> model.get_custom_metric_by_id(metric_id="<metric_id>")
get_custom_metrics(metric_ids: Optional[List[str]] = None) List

Get all logged custom metrics

Parameters

metrics_ids (list) – (Optional) Metrics ids to get. If not provided, returns all metrics available for the latest run

Return type

list[dict]

A way you might use me is:

>>> model.get_custom_metrics() # uses last logged run
>>> model.get_custom_metrics(metric_ids=["id1","id2"]) # uses last logged run
get_custom_param(param_id: str) Dict

Get custom param value by id

Parameters

param_id (str) – Custom param id to retrieve.

Return type

list

A way you might use me is:

>>> model.get_custom_param(param_id="<param_id>")
get_custom_params(param_ids: Optional[List[str]] = None) List

Get all logged params

Parameters

param_ids (list) – (Optional) Params ids to get. If not provided, returns all params available for the latest run

Return type

list[dict]

A way you might use me is:

>>> model.get_custom_params() # uses last logged run
>>> model.get_custom_params(param_ids=["id1","id2"]) # uses last logged run
get_custom_tag(tag_id: str) Dict

Get custom tag value by id

Parameters

tag_id (str) – Custom tag id to retrieve.

Return type

dict

A way you might use me is:

>>> model.get_custom_tag(tag_id="<tag_id>")
get_custom_tags(tag_ids: Optional[List[str]] = None) List

Get all logged tags

Parameters

tag_ids (list) – (Optional) Tags ids to get. If not provided, returns all tags available for the latest run

Return type

list[dict]

A way you might use me is:

>>> model.get_custom_tags() # uses last logged run
>>> model.get_custom_tags(tag_ids=["id1","id2"]) # uses last logged run
remove_custom_metric(metric_id: str) None

Remove metric by id

Parameters

metric_id (str) – Metric id to remove.

A way you might use me is:

>>> model.remove_custom_metric(metric_id=<metric_id>)
remove_custom_metrics(metric_ids: List[str]) None

Remove multiple metrics

Parameters

metric_ids (list) – Metric ids to remove from run.

A way you might use me is:

>>> model.remove_custom_metrics(metric_ids=["id1","id2"]) #uses last logged run
remove_custom_param(param_id: str) None

Remove param by id

Parameters

param_id (str) – Param id to remove.

A way you might use me is:

>>> model.remove_custom_param(param_id=<param_id>)
remove_custom_params(param_ids: List[str]) None

Remove multiple params

Parameters

param_ids (list) – Param ids to remove from run.

A way you might use me is:

>>> model.remove_custom_params(param_ids=["id1","id2"])
remove_custom_tag(tag_id: str) None

Remove tag by id

Parameters

tag_id (str) – Tag id to remove.

A way you might use me is:

>>> model.remove_custom_tag(tag_id=<tag_id>)
remove_custom_tags(tag_ids: List[str]) None

Remove multiple tags

Parameters

tag_ids (list) – Tag ids to remove from run.

A way you might use me is:

>>> model.remove_custom_tags(tag_ids=["id1","id2"])

Capture cell facts

Magic command: %%capture_cell_facts

Note

  • Using capture_cell_facts magic command on top of any cell will capture cell outputs and write to a html file which can be used to set as attachment under any defined custom facts.

  • Captured cell facts are written to temp dir {cur dir}/captured_cell_facts/Captured_Cell_Output.html

  • Each cell run output will overwrite the previous temp html file of captured cell facts. Each command output is captured as a snippet html.

  • Two args are supported with the magic command:

    • -po or --printmsgonly: print statements are only captured from any given cell

    • -cc or --capturecode: capture cell codes as well with output

  • In case of any cell mix of print messages and images or tables etc., it will capture everything except messages using print(). If you want to capture all, please use display() in place of print() method.

  • Once facts are captured, you can use `set_cell_attachment_fact()` api to attach it to any custom fact id.

Custom elements

Watson Machine Learning Elements

prepare_model_meta(self, wml_client: object, meta_props: Dict[str, Any], experiment_name: Optional[str] = None) Dict

Add current experiment attributes to model meta properties

Parameters
  • wml_client (object) – Watson Machine learning client object.

  • meta_props (dict) – Current model meta properties.

  • experiment_name (str) – (Optional) Explicit name any experiment to be used.

Returns

A Dict containing the updated meta properties.

Return type

Dict

A way you might use me is:

>>> client.export_facts.prepare_model_meta(wml_client=<wml_client>,meta_props=<wml_model_meta_props>)

FactSheetElements

Note

Sample csv can be downloaded from here csv

class FactSheetElements(api_key=None, cp4d_details: Optional[CloudPakforDataConfig] = None)

Bases: object

Factsheet elements

Parameters
  • api_key (str) – (Optional) IBM Cloud API key.

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

replace_asset_properties(csvFilePath, type_name=None, overwrite=True)

Warning

ibm_aigov_facts_client.factsheet.factsheet_utility.FactSheetElements.replace_asset_properties is deprecated. This method will be removed in a future release.Use client.assets.create_custom_facts_definitions() instead.

Utility to add custom asset properties of model or model usecase.

Parameters
  • csvFilePath (str) – File path of csv having the asset properties.

  • type_name (str) – Asset type user needs to update. Current options are modelfacts_user and model_entry_user. Default is set to modelfacts_user.

  • overwrite (bool) – (Optional) Merge or replace current properties. Default is True.

A way you might use me is:

For IBM Cloud:

>>> from ibm_aigov_facts_client import FactSheetElements
>>> client = FactSheetElements(api_key=API_KEY)
>>> client.replace_asset_properties("Asset_type_definition.csv")
>>> client.replace_asset_properties("Asset_type_definition.csv",type_name="model_entry_user", overwrite=False)

For Cloud Pak for Data:

>>> from ibm_aigov_facts_client import FactSheetElements
>>> client = FactSheetElements(cp4d_details=<CPD credentials>)
>>> client.replace_asset_properties("Asset_type_definition.csv")
>>> client.replace_asset_properties("Asset_type_definition.csv",type_name="model_entry_user", overwrite=False)
register_model_entry(model_entry_props: ModelEntryProps)

Warning

ibm_aigov_facts_client.factsheet.factsheet_utility.FactSheetElements.register_model_entry is deprecated. This method will be removed in a future release.Use client.assets.get_model().add_tracking_model_usecase() instead.

Link Model to Model Usecase. Model asset should be stored in either Project or Space and corrsponding ID should be provided when registering to model usecase.

Parameters

mdoel_entry_props (ModelEntryProps) – Properties about model asset and model usecase catalog.

For IBM Cloud:

>>> from ibm_aigov_facts_client import FactSheetElements
>>> from ibm_aigov_facts_client.supporting_classes.factsheet_utils import ModelEntryProps
>>> client = FactSheetElements(api_key=API_KEY)

For new model usecase:

>>> props=ModelEntryProps(
            model_entry_catalog_id=<catalog_id>,
            asset_id=<model_asset_id>,
            model_entry_name=<name>,
            model_entry_desc=<description>,
            project_id=<project_id>
            )
>>> client.register_model_entry(model_entry_props=props)

For linking to existing model usecase:

>>> props=ModelEntryProps(
            asset_id=<model_asset_id>,
            model_entry_catalog_id=<catalog_id>,
            model_entry_id=<model_entry_id to link>,
            space_id_id=<space_id>
            )
>>> client.register_model_entry(model_entry_props=props)

For CPD, initialization changes only:

>>> from ibm_aigov_facts_client import FactSheetElements
>>> from ibm_aigov_facts_client.supporting_classes.factsheet_utils import CloudPakforDataConfig
>>> creds=CloudPakforDataConfig(service_url=<host url>,username=<user name>,password=<password>)
>>> client = FactSheetElements(cp4d_details=creds)
unregister_model_entry(asset_id, catalog_id=None, project_id=None, space_id=None)

Warning

ibm_aigov_facts_client.factsheet.factsheet_utility.FactSheetElements.unregister_model_entry is deprecated. This method will be removed in a future release.Use client.assets.get_model().remove_tracking_model_usecase() instead.

Unregister WKC Model Usecase

Parameters
  • asset_id (str) – WKC model usecase id

  • catalog_id (str) – (Optional) Catalog ID where asset is stored

  • project_id (str) – (Optional) Project ID where the model exist

  • space_id (str) – (Optional) Space ID where model exist

Example for IBM Cloud or CPD:

>>> client.unregister_model_entry(asset_id=<model id>,project_id=<cpd_project_id>)
>>> client.unregister_model_entry(asset_id=<model id>,space_id=<cpd_space_id>)
>>> client.unregister_model_entry(asset_id=<model id>,catalog_id=<catalog_id>)
list_model_entries(catalog_id=None) Dict

Warning

ibm_aigov_facts_client.factsheet.factsheet_utility.FactSheetElements.list_model_entries is deprecated. This method will be removed in a future release.Use client.assets.list_model_usecases() instead.

Returns all WKC Model Usecase assets for a catalog

Parameters

catalog_id (str) – (Optional) Catalog ID where you want to register model, if None list from all catalogs

Returns

All WKC Model Usecase assets for a catalog

Return type

dict

Example:

>>> client = FactSheetElements(cp4d_details=creds) or client = FactSheetElements(api_key=API_KEY)
>>> client.list_model_entries()
>>> client.list_model_entries(catalog_id=<catalog_id>)

ExternalModelFactsElements

Note

Sample formats can be downloaded from here txt

class ExternalModelFactsElements(facts_client: FactsClientAdapter)

Bases: object

save_external_model_asset(model_identifier: str, name: str, description: str = None, model_details: ModelDetails = None, schemas: ExternalModelSchemas = None, training_data_reference: TrainingDataReference = None, deployment_details: DeploymentDetails = None, model_entry_props: ModelEntryProps = None, catalog_id: str = None) ModelAssetUtilities

Warning

Parameter(s) model_entry_props deprecated. Use save_external_model_asset().add_tracking_model_usecase() to create/link to model usecase instead. This param(s) will be removed in a future release.;

Save External model assets in catalog and (Optional) link to model usecase. By default external model is goig to save in Platform Asset Catalog ( PAC ), if user wants to save it to different catalog user has to pass catalog_id parameter.

Parameters
  • model_identifier (str) – Identifier specific to ML providers (i.e., Azure ML service: service_id, AWS Sagemaker:model_name)

  • name (str) – Name of the model

  • description (str) – (Optional) description of the model

  • model_details (ModelDetails) – (Optional) Model details. Supported only after CP4D >= 4.7.0

  • schemas (ExternalModelSchemas) – (Optional) Input and Output schema of the model

  • training_data_reference (TrainingDataReference) – (Optional) Training data schema

  • deployment_details (DeploymentDetails) – (Optional) Model deployment details

  • model_entry_props (ModelEntryProps) – (Optional) Properties about model usecase and model usecase catalog.

  • catalog_id (str) – (Optional) catalog id as external model can be saved in catalog itslef..

Return type

ModelAssetUtilities

If using external models with manual log option, initiate client as:

from ibm_aigov_facts_client import AIGovFactsClient
client= AIGovFactsClient(api_key=API_KEY,experiment_name="external",enable_autolog=False,external_model=True)

If using external models with Autolog, initiate client as:

from ibm_aigov_facts_client import AIGovFactsClient
client= AIGovFactsClient(api_key=API_KEY,experiment_name="external",external_model=True)

If using external models with no tracing, initiate client as:

from ibm_aigov_facts_client import AIGovFactsClient
client= AIGovFactsClient(api_key=API_KEY,external_model=True,disable_tracing=True)

If using Cloud pak for Data:

creds=CloudPakforDataConfig(service_url="<HOST URL>",
                            username="<username>",
                            password="<password>")

client = AIGovFactsClient(experiment_name=<experiment_name>,external_model=True,cloud_pak_for_data_configs=creds)

Payload example by supported external providers:

Azure ML Service:

from ibm_aigov_facts_client.supporting_classes.factsheet_utils import DeploymentDetails,TrainingDataReference,ExternalModelSchemas

external_schemas=ExternalModelSchemas(input=input_schema,output=output_schema)
trainingdataref=TrainingDataReference(schema=training_ref)
deployment=DeploymentDetails(identifier=<service_url in Azure>,name="deploymentname",deployment_type="online",scoring_endpoint="test/score")

client.external_model_facts.save_external_model_asset(model_identifier=<service_id in Azure>
                                                            ,name=<model_name>
                                                            ,model_details=<model_stub_details>
                                                            ,deployment_details=deployment
                                                            ,schemas=external_schemas
                                                            ,training_data_reference=tdataref)

client.external_model_facts.save_external_model_asset(model_identifier=<service_id in Azure>
                                                            ,name=<model_name>
                                                            ,model_details=<model_stub_details>
                                                            ,deployment_details=deployment
                                                            ,schemas=external_schemas
                                                            ,training_data_reference=tdataref,
                                                            ,catalog_id=<catalog_id>) Different catalog_id other than Platform Asset Catalog (PAC)

AWS Sagemaker:

external_schemas=ExternalModelSchemas(input=input_schema,output=output_schema)
trainingdataref=TrainingDataReference(schema=training_ref)
deployment=DeploymentDetails(identifier=<endpoint_name in Sagemaker>,name="deploymentname",deployment_type="online",scoring_endpoint="test/score")

client.external_model_facts.save_external_model_asset(model_identifier=<model_name in Sagemaker>
                                                            ,name=<model_name>
                                                            ,model_details=<model_stub_details>
                                                            ,deployment_details=deployment
                                                            ,schemas=external_schemas
                                                            ,training_data_reference=tdataref)


client.external_model_facts.save_external_model_asset(model_identifier=<model_name in Sagemaker>
                                                            ,name=<model_name>
                                                            ,model_details=<model_stub_details>
                                                            ,deployment_details=deployment
                                                            ,schemas=external_schemas
                                                            ,training_data_reference=tdataref,
                                                            ,catalog_id=<catalog_id>) Different catalog_id other than Platform Asset Catalog (PAC)

NOTE:

If you are are using Watson OpenScale to monitor this external model the evaluation results will automatically become available in the external model.

  • To enable that automatic sync of evaluation results for Sagemaker model make sure to use the Sagemaker endpoint name when creating the external model in the notebook

  • To enable that for Azure ML model make sure to use the scoring URL.

Example format: https://southcentralus.modelmanagement.azureml.net/api/subscriptions/{az_subscription_id}/resourceGroups/{az_resource_group}/ providers/Microsoft.MachineLearningServices/workspaces/{az_workspace_name}/services/{az_service_name}?api-version=2018-03-01-preview

model usecase props example, IBM Cloud and CPD:

>>> from ibm_aigov_facts_client.supporting_classes.factsheet_utils import ModelEntryProps,DeploymentDetails,TrainingDataReference,ExternalModelSchemas

Older way:

For new model usecase:

>>> props=ModelEntryProps(
            model_entry_catalog_id=<catalog_id>,
            model_entry_name=<name>,
            model_entry_desc=<description>
            )

For linking to existing model usecase:

>>> props=ModelEntryProps(
            model_entry_catalog_id=<catalog_id>,
            model_entry_id=<model_entry_id to link>
            )
>>> client.external_model_facts.save_external_model_asset(model_identifier=<model_name in Sagemaker>
                                                                ,name=<model_name>
                                                                ,model_details=<model_stub_details>
                                                                ,deployment_details=deployment
                                                                ,schemas=external_schemas
                                                                ,training_data_reference=tdataref
                                                                ,model_entry_props= props)

Current and go forward suggested way:

external_model=client.external_model_facts.save_external_model_asset(model_identifier=<service_id in Azure>
                                                    ,name=<model_name>
                                                    ,model_details=<model_stub_details>
                                                    ,deployment_details=deployment
                                                    ,schemas=external_schemas
                                                    ,training_data_reference=tdataref)

Create and link to new model usecase:

>>> external_model.add_tracking_model_usecase(model_usecase_name=<entry name>, model_usecase_catalog_id=<catalog id>)

Link to existing model usecase:

>>> external_model.add_tracking_model_usecase(model_usecase_id=<model_usecase_id>, model_usecase_catalog_id=<catalog id>)

To remove model usecase:

>>> external_model.remove_tracking_model_usecase()
unregister_model_entry(asset_id, catalog_id)

Warning

ibm_aigov_facts_client.factsheet.external_modelfacts_utility.ExternalModelFactsElements.unregister_model_entry is deprecated. This method will be removed in a future release.Use save_external_model_asset().remove_tracking_model_usecase() instead.

Unregister WKC Model usecase

Parameters
  • asset_id (str) – WKC model usecase id

  • catalog_id (str) – Catalog ID where asset is stored

Example for IBM Cloud or CPD:

>>> client.external_model_facts.unregister_model_entry(asset_id=<model asset id>,catalog_id=<catalog_id>)
list_model_entries(catalog_id=None) list

Warning

ibm_aigov_facts_client.factsheet.external_modelfacts_utility.ExternalModelFactsElements.list_model_entries is deprecated. This method will be removed in a future release.Use client.assets.list_model_usecases() instead.

Returns all WKC Model usecase assets for a catalog

Parameters

catalog_id (str) – (Optional) Catalog ID where you want to register model, if None list from all catalogs

Returns

All WKC Model usecase assets for a catalog

Return type

list

Example:

>>> client.external_model_facts.list_model_entries()
>>> client.external_model_facts.list_model_entries(catalog_id=<catalog_id>)

HELPER CLASSES

ExternalModelSchemas

class ExternalModelSchemas(input: List[Dict], output: Optional[List[Dict]] = None)

External model schema

Attr List[Dict] input

Model input data schema

Attr List[Dict] output

(optional) Model output data schema

TrainingDataReference

class TrainingDataReference(type: Optional[str] = None, id: Optional[str] = None, connection: Optional[Dict] = None, location: Optional[Dict] = None, schema: Optional[Dict] = None)

Training data schema definition

Attr str type

Type of training data reference. It has values as fs, url, data_asset or connection_asset.

Attr str id

ID of training data reference.

Attr Dict connection

(Optional) Connection details

Attr Dict location

(Optional) Location details

Attr Dict schema

Model training data schema

If type is fs, the parameters that user needs to input are - location.path If type is url, the parameters that user needs to provide are - training_data_references[].id and connection.url If type is data_asset, then - location.href If type is connection_asset, then location.file_name or location.table_name, connection.href

DeploymentDetails

class DeploymentDetails(identifier: str, name: str, deployment_type: str, scoring_endpoint: Optional[str] = None, description: Optional[str] = None)

External model deployment details

Attr str identifier

Deployment identifier specific to providers.

Attr str name

Name of the deployment

Attr str deployment_type

Deployment type (i.e., online)

Attr str scoring_endpoint

Deployment scoring endpoint url.

Attr str description

(Optional) Description of the deployment

CloudPakforDataConfig

class CloudPakforDataConfig(service_url: str, username: str, password: Optional[str] = None, api_key: Optional[str] = None, disable_ssl_verification: bool = True, bedrock_url: Optional[str] = None)

Configurations for Cloud Pak for Data environment

Attr str service_url

Host URL of Cloud Pak for Data environment.

Attr str username

Environment username

Attr str password

Environment password

Attr str api_key

Environment api_key if IAM enabled

Attr bool disable_ssl_verification

Disable SSL verification. Default is True.

Attr str bedrock_url

(Optional) Foundational services (common-services-route ) url. User needs to get this url from CP4D admin. This url is required only when iam-integration is enabled on CP4D 4.0.x cluster.

ModelEntryProps

class ModelEntryProps(model_entry_catalog_id: str, asset_id: Optional[str] = None, model_catalog_id: Optional[str] = None, model_entry_id: Optional[str] = None, model_entry_name: Optional[str] = None, model_entry_desc: Optional[str] = None, project_id: Optional[str] = None, space_id: Optional[str] = None, grc_model_id: Optional[str] = None)

Model usecase Properties

Attr str model_entry_catalog_id

Catalog ID where model usecase exist.

Attr str asset_id

Published model/asset ID. It is optional for external models ONLY.

Attr str model_catalog_id

(Optional) Catalog Id where model exist.

Attr str model_entry_id

(Optional) Existing Model usecase to link with.

Attr str model_entry_name

(Optional) New model usecase name. Used only when creating new model usecase.

Attr str model_entry_description

(Optional) New model usecase description. Used only when creating new model usecase.

Attr str project_id

(Optional) Project ID where the model exist.Not applicable for external models.

Attr str space_id

(Optional) Space ID where model exist Not applicable for external models.

Attr str grc_model_id

(Optional) Openpages model id. Only applicable for CPD environments.

MISCELLANEOUS

ENUMS

class ContainerType

Bases: object

Describes possible container types. Client initialization works for SPACE or PROJECT only. Contains: [PROJECT,SPACE,CATALOG]

PROJECT = 'project'
SPACE = 'space'
CATALOG = 'catalog'
class FormatType

Bases: object

Describes output formats options Contains: [DICT,STR]

DICT = 'dict'
STR = 'str'
class ModelEntryContainerType

Bases: object

Describes possible model usecase container types. Contains: [DEVELOP,TEST,VALIDATE,OPERATE]

DEVELOP = 'develop'
TEST = 'test'
VALIDATE = 'validate'
OPERATE = 'operate'
class AllowedDefinitionType

Bases: object

Describes possible CAMS data types for definitions. Contains: [INTEGER,STRING,DATE]

INTEGER = 'int'
STRING = 'str'
DATE = 'date'
class FactsType

Bases: object

Describes possible Factsheet custom asset types. Only MODEL_FACTS_USER and MODEL_USECASE_USER supported when creating definitions. Contains: [MODEL_FACTS_USER,MODEL_USECASE_USER,MODEL_FACTS_USER_OP,MODEL_FACTS_SYSTEM,MODEL_FACTS_GLOBAL]

  • The modelfacts user AssetType to capture the user defined attributes of a model

  • The model usecase user asset type to capture user defined attributes of a model usecase

  • The modelfacts user AssetType to capture the user defined attributes of a model to be synced to OpenPages

  • The modelfacts system AssetType to capture the system defined attributes of a model

  • The modelfacts global AssetType to capture the global attributes of physical model (external model)

MODEL_FACTS_USER = 'modelfacts_user'
MODEL_USECASE_USER = 'model_entry_user'
MODEL_FACTS_USER_OP = 'modelfacts_user_op'
MODEL_FACTS_SYSTEM = 'modelfacts_system'
MODEL_FACTS_GLOBAL = 'modelfacts_global'
class RenderingHints

Bases: object

Describes rendering hints for attachment facts. Contains: [INLINE_HTML,INLINE_IMAGE,LINK_DOWNLOAD,LINK_NEW_TAB]

INLINE_HTML = 'inline_html'
INLINE_IMAGE = 'inline_image'
class AttachmentFactDefinitionType

Bases: object

Describes possible Factsheet attachment definition types. Only MODEL_TYPE and MODEL_USECASE_TYPE are supported. Contains: [MODEL_TYPE,MODEL_USECASE_TYPE]

  • The model to list attachment fact definitions for all models defined.

  • The model_usecase to list attachment fact definitions for all model usecases defined.

MODEL_TYPE = 'model'
MODEL_USECASE_TYPE = 'model_usecase'
class Status

Bases: object

Describes possible status types. Contains: [DRAFT,AWAITING_DEVELOPMENT,DEVELOPED,PROMPTED_TO_PRE_PRODUCTION,DEPLOYED_FOR_VALIDATION,VALIDATED,APPROVED,PROMPTED_TO_PRODUCTION,DEPLOYED_FOR_OPERATION,IN_OPERATION,UNDER_REVISION,DECOMMISSIONED]

DRAFT = 'draft'
AWAITING_DEVELOPMENT = 'Awaiting development'
DEVELOPED = 'Developed'
PROMPTED_TO_PRE_PRODUCTION = 'Promoted to pre-production'
DEPLOYED_FOR_VALIDATION = 'Deployed for validation'
VALIDATED = 'Validated'
APPROVED = 'Approved'
PROMPTED_TO_PRODUCTION = 'Promoted to production'
DEPLOYED_FOR_OPERATION = 'Deployed for operation'
IN_OPERATION = 'In operation'
UNDER_REVISION = 'Under revision'
DECOMMISSIONED = 'Decommissioned'
class Risk

Bases: object

Describes possible risk types. Contains: [HIGH,MEDIUM,LOW,CUSTOM,NONE]

HIGH = 'high'
MEDIUM = 'medium'
LOW = 'low'
CUSTOM = 'custom'
NONE = 'none'
class Provider

Bases: object

Describes possible provider types. Contains: [WATSON_MACHINE_LEARNING,AMAZON_SAGEMAKER,AZURE_MACHINE_LEARNING,CUSTOM_MACHINE_LEARNING,SPSS_COLLABORATION_AND_DEPLOYMENT_SERVICES,AZURE_MACHINE_LEARNING_SERVICE]

WATSON_MACHINE_LEARNING = 'Watson Machine Learning'
AMAZON_SAGEMAKER = 'Amazon SageMaker'
AZURE_MACHINE_LEARNING = 'Microsoft Azure ML Studio'
CUSTOM_MACHINE_LEARNING = 'Custom Environment'
SPSS_COLLABORATION_AND_DEPLOYMENT_SERVICES = 'IBM SPSS Collaboration and Deployment Services'
AZURE_MACHINE_LEARNING_SERVICE = 'Microsoft Azure ML Service'
class Icon

Bases: object

Describes possible icon types. Contains: [PACKAGES,SPROUT,TREE,NEURAL_NETWORK,ROCKET,CODE,LINEAR,LOGISTIC,DECISION_TREE,SUPPORT_VECTOR_MACHINES,NETWORK,UNRELATED,

DIMENSIONS,BOT,CHAT_BOT,IMAGE,SCALE,FINANCE,PIGGY_BANK,DELIVERY,FACTORY,ELECTRONICS,IDEA,RECYCLE,GLOBE,LANGUAGE,GIFT,ZOMBIE]

PACKAGES = 'Packages'
SPROUT = 'Sprout'
TREE = 'Tree'
NEURAL_NETWORK = 'Neural-network'
ROCKET = 'Rocket'
CODE = 'Code'
LINEAR = 'Linear'
LOGISTIC = 'Logistic'
DECISION_TREE = 'Decision-tree'
SUPPORT_VECTOR_MACHINES = 'Support-vector-machines'
NETWORK = 'Network'
UNRELATED = 'Nnrelated'
DIMENSIONS = 'Dimensions'
BOT = 'Bot'
CHAT_BOT = 'Chat-bot'
IMAGE = 'Image'
SCALE = 'Scale'
FINANCE = 'Finance'
PIGGY_BANK = 'Piggy-bank'
DELIVERY = 'Delivery'
FACTORY = 'Factory'
ELECTRONICS = 'Electronics'
IDEA = 'Idea'
RECYCLE = 'Recycle'
GLOBE = 'Globe'
LANGUAGE = 'Language'
GIFT = 'Gift'
ZOMBIE = 'Zombie'
class Color

Bases: object

Describes possible color types. Contains: [GRAY,GREEN,TEAL,CYAN,BLUE,PURPLE,MAGENTA,RED,ORANGE,YELLOW]

GRAY = 'Gray'
GREEN = 'Green'
TEAL = 'Teal'
CYAN = 'Cyan'
BLUE = 'Blue'
PURPLE = 'Purple'
MAGENTA = 'Magenta'
RED = 'Red'
ORANGE = 'Orange'
YELLOW = 'Yellow'