ibm_aigov_facts_client.factsheet.asset_utils_me module
- class ModelUsecaseUtilities(assets_client: Assets, model_id: str = None, model_usecase_id: str = None, container_type: str = None, container_id: str = None, facts_type: str = None)
Bases:
objectModel use case utilities. Running client.assets.model_usecase() makes all methods in ModelUsecaseUtilities object available to use.
- classmethod from_dict(_dict: Dict) ModelUsecaseUtilities
Initialize a ModelUsecaseUtilities object from a json dictionary.
- to_dict() Dict
Return a json dictionary representing this model.
- 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") # allowed if attribute property `is_array` is true. >>> model_usecase.set_custom_fact(fact_id="custom_string",value=["test","test2"])
- 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"]})
- set_new_owner(owner_iam_id: str) str
Assign a new owner to the AI use case model.
- Args:
owner_iam_id (str): IAM ID of the new owner (e.g., IBMid0).
- Returns:
str: Response JSON on successful owner assignment.
- Raises:
Exception: If the owner assignment fails.
- set_asset_collaborator(user_iam_id: str) str
Adds a collaborator to the asset using the given IAM ID.
- Parameters:
user_iam_id (str): IAM ID of the user to be added.
- Raises:
ClientError: If IAM ID is empty. Exception: If the request fails.
- remove_asset_collaborator(user_iam_id: str) str
Removes a collaborator from the asset using the given IAM ID.
- Parameters:
user_iam_id (str): IAM ID of the user to be removed.
- Raises:
ClientError: If IAM ID is empty. Exception: If the request fails.
- 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: 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, fact_id: str, description: str = None, html_rendering_hint: str = None, allow_large_files: bool = False) None
Set attachment fact for given model use case.
- Parameters:
file_to_upload (str) – Attachment file path to upload.
fact_id (str) – Fact id for the attachment.
description (str) – (Optional) Description about the attachment file.
html_rendering_hint (str) – (Optional) HTML rendering hint. Available options are in ibm_aigov_facts_client.utils.enums.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:
fact_id (str) – Fact id for the attachment
description (str) – (Optional) Description about the cell facts attachment file
A way to use me is:
model_usecase.set_cell_attachment_fact(description='<file description>', fact_id='<custom fact id>')
- has_attachment(fact_id: 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: str = None, format: str = 'dict')
List available attachment 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’). Defaults to ‘dict’.
A way to use me is:
Use this format if using output for set_custom_fact():
model_usecase.list_attachments(format="str") model_usecase.list_attachments() # Get all attachment facts # Filter by associated fact_id_1. model_usecase.list_attachments(filter_by_factid="fact_id_1")
- get_download_URL(attachment_id: str) str
Constructs and returns the download URL for a given attachment.
- Args:
attachment_id (str): The unique identifier of the attachment.
- Returns:
str: The URL that can be used to download the specified attachment.
- Raises:
ValueError: If the attachment_id is invalid or if there is an issue generating the URL.
- Example:
>>> url = ai_usecase.get_download_URL(attachment_id="12345") >>> print(url)
- 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: ApproachUtilities = None)
Returns WKC Model usecase removed approach. Supported for CPD version >=4.7.0
- Parameters:
approach (ApproachUtilities) – Object or instance of ApproachUtilities
- Return type:
None
- Returns:
WKC Model usecase approach is removed
Example,:
ai_usecase.remove_approach(approach=ApproachUtilities)
- create_approach(name: str = None, description: str = None, icon: str = None, color: str = None) ApproachUtilities
Returns WKC Model usecase approach. Supported for CPD version >=4.7.0
- Parameters:
name (str) – Name of approach
description (str) – (Optional) Description of approach
icon (str) – (Optional) Approach’s icon
color (str) – (Optional) Approach’s color
- Return type:
- Returns:
WKC Model usecase approach
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:
ai_usecase.get_approaches()
- get_approach(approach_id: str = None) ApproachUtilities
Returns WKC Model usecase approaches. Supported for CPD version >=4.7.0
- Parameters:
approach_id (str) – Approach ID
- Return type:
- Returns:
Specific WKC Model usecase approach
Example,:
ai_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: 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: str = None, model_asset_id: 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>)
- list_all_associated_workspaces() None
Lists all associated workspaces for a given AI usecase in tabular format. The method will display the associated workspaces for all the phases.
- Returns:
None
Example:
client.assets.ai_usecase.list_all_associated_workspaces()
- list_associated_workspaces_by_phase(phase_name: Phases = None) list
Lists all associated workspaces for a given AI usecase in tabular format. The method will display the filtered associated workspaces, filtered by the phase name passed.
- Parameters:
phase_name (str) – Phase name. Available options are in
Phases- Returns:
list
Example:
client.assets.ai_usecase.list_associated_workspaces_by_phase(phase_name='<valid phase name>')
- add_workspaces_associations(workspace_id: str = None, workspace_type: str = None, phase_name: str = None)
Associate a workspace to a particular AI usecase under a specified phase.
- Parameters:
workspace_id (str) – Project ID or space ID which needs to be associated with the selected usecase.
workspace_type (str) – Should be “project” when passing a project ID as workspace_id. If a space ID is passed for workspace_id, the workspace_type will be “space”.
phase_name (str) – Phase name, should be one of ‘develop’, ‘validate’, or ‘operate’. Available options are in
Phases.
- Returns:
None
Example:
client.assets.ai_usecase.add_workspaces_associations(workspace_id='<project or space id>', workspace_type='<"project" or "space">', phase_name='<valid phase name>')
- remove_workspace_associations(workspace_ids: list = None) None
Removes association of one or more workspaces at once from a particular AI usecase, irrespective of the phase they are in. The disassociation works only if there are no tracked assets in the workspace(s) to be removed. User should have edit access to the usecase.
- Parameters:
workspace_ids (list) – List of workspace IDs to be disassociated. For example: workspace_ids=[project_id_1, space_id_1].
- Returns:
None
Example:
client.assets.model_usecase.remove_workspace_associations(workspace_ids=[<project id>, <space id>])