Welcome to IBM Watson OpenScale Python SDK’s 3.0.41 documentation!
Python client library to quickly get started with IBM Watson OpenScale.
ibm_watson_openscale
is a python library that allows to work with Watson OpenScale service on IBM Cloud.
Test and deploy your models as APIs for application development, share with colleagues using this python library.
Installation
The package is available on pypi.
To install, use pip
:
$pip install -U ibm-watson-openscale
Requirements
Watson OpenScale service instance, you can create instance using this link. Only Python 3.5 or newer is supported.
ibm-cloud-sdk-core >= 1.1
is required to be able to authenticate to the service.
Breaking changes log
Watson Machine Learning instances in regions other than US-South (Dallas) are not officially supported.
Only one deployment per subscription is supported.
Supported engines
Watson Machine Learning
Custom Machine Learning (following this specification)
Microsoft Azure Machine Learning Studio (deployments of type new)
Amazon SageMaker Machine Learning
SPSS Collaboration and Deployment Services
API
To start working with the client library you need Watson OpenScale service credentials.
Credentials can be found under Credentials tab of your service instance (IBM Cloud).
An OpenScale Python SDK v2 uses an ibm-cloud-sdk-core
package to authenticate with the service.
For more detailed description of the authentication, please visit:
IBM Cloud SDK Core
Below is presented the programmatically version of client initialization. All necessary credentials must be provided
during APIClient
object creation.
Only authenticator
parameter is required, but have in mind that passing only authenticator
parameter,
the default options will be used (service_url
= “https://api.aiopenscale.cloud.ibm.com”
and service_instance_id
will be retrieved automatically)
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_watson_openscale import APIClient
service_credentials = {
"apikey": "*****",
"url": "https://api.aiopenscale.cloud.ibm.com"
}
authenticator = IAMAuthenticator(
apikey=service_credentials['apikey']
)
# default value of service_url = "https://api.aiopenscale.cloud.ibm.com",
# service_instance_id retrieved automatically
client = APIClient(
authenticator=authenticator
)
# or
# service_instance_id retrieved automatically
client = APIClient(
service_url=service_credentials['url'],
authenticator=authenticator
)
# or
client = APIClient(
service_url=service_credentials['url'],
service_instance_id="230a8e9f-2453-4c2d-a560-2a75399210bf"
authenticator=authenticator
)
In case of CP4D environments, CloudPakForDataAuthenticator
class should be used (instead of IAMAuthenticator
)
Note: If you have multiple instances of OpenScale running on CP4D env then you can use following code to get list of service_instance_ids for which you have access to
import urllib3
urllib3.disable_warnings()
from ibm_watson_openscale.utils.client_utils import get_my_instance_ids
my_instances = get_my_instance_ids(url, <username>, password=<password>,apikey = <apikey>): # Pass either password or apikey but not both
print(my_instances)
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
from ibm_watson_openscale import APIClient
service_credentials = {
"url": "******",
"username": "*****",
"password": "*****"
}
authenticator = CloudPakForDataAuthenticator(
url=service_credentials['url'],
username=service_credentials['username'],
password=service_credentials['password'],
disable_ssl_verification=True
)
# default value of service_url = "https://api.aiopenscale.cloud.ibm.com",
# service_instance_id retrieved automatically
client = APIClient(
authenticator=authenticator
)
# or
# service_instance_id retrieved automatically
client = APIClient(
service_url=service_credentials['url'],
authenticator=authenticator
)
# or
client = APIClient(
service_url=service_credentials['url'],
service_instance_id="230a8e9f-2453-4c2d-a560-2a75399210bf"
authenticator=authenticator
)
# or
#
# Use this if you have CP4D 4.0.x and iam integration is enabled.
# bedrock_url is nothing but the foundational services (common-services-route ) url. User needs to get this url from CP4D admin.
client = APIClient(
service_url=service_credentials['url'],
service_instance_id="230a8e9f-2453-4c2d-a560-2a75399210bf"
authenticator=authenticator,
bedrock_url = <COMMON_SERVICES_URL>
)
You could initialize the client from environmental variables directly or from configuration file.
The service_name must be identical in the configuration file and passed to the new_instance()
class method of the client
File with configuration:
# bm-credentials.env
OpenScale_URL=https://api.aiopenscale.cloud.ibm.com
OpenScale_AUTH_TYPE=iam
OpenScale_APIKEY=ncn92u92benfi2nec0292ebicm02
OpenScale_AUTH_URL=https://iam.cloud.ibm.com/identity/token
How to use new_instance()
class method:
from ibm_watson_openscale import APIClient
import os
os.environ["IBM_CREDENTIALS_FILE"] = "path_to_credential_file/ibm-credentials.env"
ai_client = APIClient.new_instance(service_name='OpenScale')
Basic SDK’s elements
APIClient
- class WatsonOpenScaleV2Adapter(authenticator: BearerTokenAuthenticator | CloudPakForDataAuthenticator | IAMAuthenticator | CloudPak40ForDataAuthenticator | None = None, service_url: str | None = None, service_instance_id: str | None = None, bedrock_url: str | None = None, header={})[source]
Bases:
WatsonOpenScaleV2
Watson OpenScale client.
- Variables:
version (str) – Returns version of the python library.
authenticator (IAMAuthenticator, CloudPakForDataAuthenticator) – Returns passed authenticator.
data_marts (ibm_watson_openscale.data_marts.DataMarts) – Manages data_marts module
service_providers (ibm_watson_openscale.service_providers.ServiceProviders) – Manages service_providers module
subscriptions (ibm_watson_openscale.subscriptions.Subscriptions) – Manages subscriptions module
data_sets (ibm_watson_openscale.data_sets.DataSets) – Manages data_sets module
monitor_definitions (ibm_watson_openscale.monitor_definitions.MonitorDefinitions) – Manages monitor_definitions module
monitor_instances (ibm_watson_openscale.monitor_instances.MonitorInstances) – Manages monitor_instances module
metrics (AIMetrics) – Allow you to compute metrics
#:var business_applications: Manages business_applications module #:vartype business_applications: ibm_watson_openscale.business_applications.BusinessApplications
A way you might use me is:
>>> from ibm_watson_openscale import APIClient >>> client = APIClient(authenticator=authenticator, service_url=service_url) # client will use default service_instance_id >>> client = APIClient(authenticator, service_url) # client will use default service_url and default service_instance_id >>> client = APIClient(authenticator=authenticator, service_url=service_url, service_instance_id=service_instance_id) >>> client = APIClient(authenticator=authenticator, service_url=service_url, service_instance_id=service_instance_id,bedrock_url=bedrock_url ) >>> client = APIClient(authenticator, service_url, service_instance_id)
- classmethod new_instance(service_name: str | None = None) WatsonOpenScaleV2Adapter [source]
This class method should be used only if you have stored your credentials in the separate file or in the ENV variable.
- Parameters:
service_name – Unique name of the service to configure.
- Returns:
ibm_watson_openscale.APIClient
A way you might use me is:
>>> from ibm_watson_openscale import APIClient >>> client = APIClient.new_instance(service_name="openscale-1") >>> client = APIClient.new_instance(service_name="openscale-2") >>> client = APIClient.new_instance("openscale")
APIClient.data_marts
- class DataMarts(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
DataMarts
Manages Database instance.
- show(limit: int | None = 10, project_id: str | None = None, space_id: str | None = None) None [source]
Show Data marts. By default 10 records will be shown.
- Parameters:
A way you might use me is:
>>> client.data_marts.show() >>> client.data_marts.show(limit=20) >>> client.data_marts.show(limit=None)
- add(name: str = None, description: str = None, service_instance_crn: str = None, internal_database: bool = None, database_configuration: DatabaseConfigurationRequest = None, force: bool = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse [source]
Add the data mart. Configure database connection for the data mart.
- Parameters:
name (str) – (optional) Name of the data mart.
description (str) – (optional) Description of the data mart.
service_instance_crn (str) – (optional) Can be omitted if user token is used for authorization.
internal_database (bool) – (optional) If true the internal database managed by AI OpenScale is provided for the user.
database_configuration (DatabaseConfigurationRequest) – (optional) Database configuration ignored if internal database is requested (internal_database is true).
force (bool) – (optional) force update of metadata and db credentials (assumption is that the new database is already prepared and populated).
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataMartDatabaseResponse result
A way you might use me is:
>>> from ibm_watson_openscale import * >>> client.data_marts.add( background_mode=False, name="My Data Mart", description="Description of the data mart...", database_configuration=DatabaseConfigurationRequest( database_type='postgresql', instance_id='crn:v1:bluemix:public:databases-for-postgresql:us-south:a/***', credentials=PrimaryStorageCredentialsLong( hostname='some hostname', username='some username', password='some password', db='database name', port=50000, ssl=True, sslmode='verify-full', certificate_base64='***' ), location=LocationSchemaName( schema_name='name of the database schema' ) ) )
- delete(data_mart_id: str, force: bool = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse [source]
Delete the data mart.
- Parameters:
data_mart_id (str) – ID of the data mart.
force (bool) – (optional) force hard delete.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
A way you might use me is:
>>> client.data_marts.delete( background_mode=False, data_mart_id='id of the datamart', force=True )
- get(data_mart_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Get data mart with the given id.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataMartDatabaseResponse result
- list(*, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
List all data marts.
The method returns the data mart confugrations as an object.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataMartDatabaseResponseCollection result
- patch(data_mart_id: str, json_patch_operation: List[JsonPatchOperation], *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Update a data mart.
- Parameters:
data_mart_id (str) – ID of the data mart.
json_patch_operation (List[JsonPatchOperation])
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataMartDatabaseResponse result
APIClient.service_providers
- class ServiceProviders(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
ServiceProviders
Manages Service Provider instance.
- show(limit: int | None = 10, show_deleted: bool | None = None, service_type: str | None = None, instance_id: str | None = None, operational_space_id: str | None = None, deployment_space_id: str | None = None, integrated_project_id: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) None [source]
Show service providers. By default 10 records will be shown.
- Parameters:
limit (int) – maximal number of fetched rows. By default set to 10. (optional)
show_deleted (bool) – (optional) show also resources pending delete.
service_type (str) – (optional) Type of service.
instance_id (str) – (optional) comma-separated list of IDs.
operational_space_id (str) – (optional) comma-separated list of IDs.
deployment_space_id (str) – (optional) comma-separated list of IDs.
integrated_project_id (str) – (optional) comma-separated list of IDs.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
headers (dict) – A dict containing the request headers
A way you might use me is:
>>> client.service_providers.show() >>> client.service_providers.show(limit=20) >>> client.service_providers.show(limit=None)
- add(name: str, service_type: str = None, description: str = None, credentials: MLCredentials = None, request_headers: object = None, operational_space_id: str = None, deployment_space_id: str = None, integrated_project_id: str = None, group_ids: List[str] = None, user_ids: List[str] = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse [source]
Add service provider.
Assosiate external Machine Learning service instance with the OpenScale DataMart.
- Parameters:
name (str) – Name of the ML service instance.
service_type (str) – (optional) machine learning service type (azure_machine_learning_studio is a preferred alias for azure_machine_learning and should be used in new service bindings).
description (str) – (optional)
credentials (MLCredentials) – (optional)
request_headers (object) – (optional) map header name to header value.
operational_space_id (str) – (optional) Reference to Operational Space. Allowed values are ‘production’ and ‘pre_production’
deployment_space_id (str) – (optional) Reference to V2 Space ID
integrated_project_id (str) – (optional) Project ID.
group_ids (List[str]) – (optional) Access control list of group id of Cloud Pak for Data (Only available for OpenScale on Cloud Pak for Data >= 4.0.6 with ENABLE_GROUP_AUTH being true).
user_ids (List[str]) – (optional) Access control list of user id of Cloud Pak for Data (Only available for OpenScale on Cloud Pak for Data >= 4.0.6 with ENABLE_GROUP_AUTH being true).
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with ServiceProviderResponse result
A way you may use me when WML is located on same cluster
>>> from ibm_watson_openscale import * >>> added_service_provider_info = client.service_providers.add( background_mode=False, name="WML instance", service_type=ServiceTypes.WATSON_MACHINE_LEARNING, deployment_space_id = <SPACE_ID>, operational_space_id = "production" credentials=WMLCredentialsCloud( url='<URL>', username='<USERNAME>', password='<PASSWORD>' ) )
A way you may use me when WML is located on different CP4D cluster (Available only on CP4D 4.0 or higher)
>>> from ibm_watson_openscale import * >>> from ibm_watson_openscale.supporting_classes.enums import * >>> added_service_provider_info = client.service_providers.add( background_mode=False, name="WML instance", service_type=ServiceTypes.WATSON_MACHINE_LEARNING, deployment_space_id = <SPACE_ID>, operational_space_id = "production" credentials=WMLCredentialsCloud( url = '<URL>', username='<USERNAME>, apikey='APIKEY>', wml_location = CP4DWMLLocation.CPD_REMOTE ) )
A way you may use me when WML is located on IBM Cloud
>>> from ibm_watson_openscale import * >>> from ibm_watson_openscale.supporting_classes.enums import * >>> added_service_provider_info = client.service_providers.add( background_mode=False, name="WML instance", service_type=ServiceTypes.WATSON_MACHINE_LEARNING, deployment_space_id = <SPACE_ID>, operational_space_id = "production" credentials=WMLCredentialsCloud( url = '<URL>', apikey='APIKEY>', wml_location = CP4DWMLLocation.CLOUD_REMOTE ) )
- delete(service_provider_id: str, force: bool = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse [source]
Delete service provider.
Detach Machine Learning service provider.
- Parameters:
service_provider_id (str) – ID of the ML service provider.
force (bool) – (optional) force hard delete.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
A way you may use me:
>>> client.service_providers.delete( background_mode=False, service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5', force=True )
- list_assets(data_mart_id: str, service_provider_id: str, deployment_id: str | None = None, deployment_space_id: str | None = None, project_id: str | None = None, space_id: str | None = None) Response [source]
Listing all deployments and assets for specific data_mart and service_provider.
- Parameters:
data_mart_id (str) – ID of the data_mart (required)
service_provider_id (str) – ID of the service_provider (required)
deployment_id (str) – ID of the deployment (optional), when used, only specific deployment is returned
deployment_space_id (str) – (optional) Reference to V2 Space ID
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
Response
A way you may use me:
>>> response = client.service_providers.list_assets( data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5', deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5' ) >>> print(response.result) {'count': 1, 'resources': [{'entity': {'asset': {'asset_id': '997b1474-00d2-4g05-ac02-287ebfc603b5', 'asset_type': 'model', 'created_at': '2020-01-13T09:15:26.586Z', 'name': 'AIOS Spark Credit Risk model', 'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/published_models/997b1474-00d2-4g05-ac02-287ebfc603b5'}, 'asset_properties': {'asset_revision': '997b1474-00d2-4g05-ac02-287ebfc603b5', 'input_data_schema': {'fields': [{'metadata': {}, 'name': 'CheckingStatus', 'nullable': True, 'type': 'string'}, ... 'label_column': 'Risk', 'model_type': 'mllib-2.3', 'runtime_environment': 'spark-2.3', 'training_data_schema': {'fields': [{'metadata': {}, 'name': 'CheckingStatus', 'nullable': True, 'type': 'string'}, ... 'description': 'Description of deployment', 'name': 'AIOS Spark Credit Risk deployment', 'scoring_endpoint': {'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5/online'}, 'type': 'online'}, 'metadata': {'created_at': '2020-01-13T09:15:26.607Z', 'guid': '997b1474-00d2-4g05-ac02-287ebfc603b5', 'modified_at': '2020-01-13T09:15:26.848Z', 'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5'}}]} >>> response = client.service_providers.list_assets( data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5' deployment_id='997b1474-00d2-4g05-ac02-287ebfc603b5', deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5' )
- get_deployment_asset(data_mart_id: str, service_provider_id: str, deployment_id: str, deployment_space_id: str | None = None, project_id: str | None = None, space_id: str | None = None) Response [source]
Listing all deployments and assets for specific data_mart and service_provider.
- Parameters:
data_mart_id (str) – ID of the data_mart (required)
service_provider_id (str) – ID of the service_provider (required)
deployment_id (str) – ID of the deployment (required), when used, only specific deployment is returned
deployment_space_id (str) – Reference to V2 Space ID (required)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
Response
A way you may use me:
>>> response = client.service_providers.list_assets( data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5', deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5' ) >>> print(response.result) {'entity': {'asset': {'asset_id': '997b1474-00d2-4g05-ac02-287ebfc603b5', 'asset_type': 'model', 'created_at': '2020-01-13T09:15:26.586Z', 'name': 'AIOS Spark Credit Risk model', 'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/published_models/997b1474-00d2-4g05-ac02-287ebfc603b5'}, 'asset_properties': {'asset_revision': '997b1474-00d2-4g05-ac02-287ebfc603b5', 'input_data_schema': {'fields': [{'metadata': {}, 'name': 'CheckingStatus', 'nullable': True, 'type': 'string'}, ... 'label_column': 'Risk', 'model_type': 'mllib-2.3', 'runtime_environment': 'spark-2.3', 'training_data_schema': {'fields': [{'metadata': {}, 'name': 'CheckingStatus', 'nullable': True, 'type': 'string'}, ... 'description': 'Description of deployment', 'name': 'AIOS Spark Credit Risk deployment', 'scoring_endpoint': {'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5/online'}, 'type': 'online'}, 'metadata': {'created_at': '2020-01-13T09:15:26.607Z', 'guid': '997b1474-00d2-4g05-ac02-287ebfc603b5', 'modified_at': '2020-01-13T09:15:26.848Z', 'url': 'https://us-south.ml.cloud.ibm.com/v3/wml_instances/997b1474-00d2-4g05-ac02-287ebfc603b5/deployments/997b1474-00d2-4g05-ac02-287ebfc603b5'}} >>> response = client.service_providers.get_deployment_asset( data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5' deployment_id='997b1474-00d2-4g05-ac02-287ebfc603b5', deployment_space_id='6574djd4-00d2-4g05-ac02-287ebfc603b5' )
- get(service_provider_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Get a specific service provider.
Get the assosiated Machine Learning service provider details.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with ServiceProviderResponse result
- list(*, project_id: str | None = None, space_id: str | None = None, show_deleted: bool | None = None, service_type: str | None = None, instance_id: str | None = None, operational_space_id: str | None = None, deployment_space_id: str | None = None, integrated_project_id: str | None = None, **kwargs) DetailedResponse [source]
List service providers.
List assosiated Machine Learning service instances.
- Parameters:
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
show_deleted (bool) – (optional) show also resources pending delete.
service_type (str) – (optional) Type of service.
instance_id (str) – (optional) comma-separated list of IDs.
operational_space_id (str) – (optional) comma-separated list of IDs.
deployment_space_id (str) – (optional) comma-separated list of IDs.
integrated_project_id (str) – (optional) comma-separated list of IDs.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with ServiceProviderResponseCollection result
- update(service_provider_id: str, patch_document: List[PatchDocument], *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Update a service provider.
Update existing service provider.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with ServiceProviderResponse result
APIClient.subscriptions
- class Subscriptions(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
Subscriptions
Manages Subscription instance.
- show(limit: int | None = 10, data_mart_id: str | None = None, service_provider_id: str | None = None, asset_asset_id: str | None = None, asset_asset_type: str | None = None, deployment_deployment_id: str | None = None, deployment_deployment_type: str | None = None, integration_reference_integrated_system_id: str | None = None, integration_reference_external_id: str | None = None, risk_evaluation_status_state: str | None = None, service_provider_operational_space_id: str | None = None, pre_production_reference_id: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) None [source]
Show service providers. By default 10 records will be shown.
- Parameters:
limit (int) – maximal number of fetched rows. By default set to 10. (optional)
data_mart_id (str) – (optional) comma-separated list of IDs.
service_provider_id (str) – (optional) comma-separated list of IDs.
asset_asset_id (str) – (optional) comma-separated list of IDs.
asset_asset_type (str) – (optional) comma-separated list of types.
deployment_deployment_id (str) – (optional) comma-separated list of IDs.
deployment_deployment_type (str) – (optional) comma-separated list of types.
integration_reference_integrated_system_id (str) – (optional) comma-separated list of IDs.
integration_reference_external_id (str) – (optional) comma-separated list of IDs.
risk_evaluation_status_state (str) – (optional) comma-separated list of states.
service_provider_operational_space_id (str) – (optional) comma-separated list of operational space ids (property of service provider object).
pre_production_reference_id (str) – (optional) comma-separated list of IDs.
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
A way you might use me is:
>>> client.subscriptions.show() >>> client.subscriptions.show(limit=20) >>> client.subscriptions.show(limit=None)
- add(data_mart_id: str, service_provider_id: str, asset: Asset, deployment: AssetDeploymentRequest, asset_properties: AssetPropertiesRequest = None, risk_evaluation_status: RiskEvaluationStatus = None, analytics_engine: AnalyticsEngine = None, data_sources: List[DataSource] = None, training_data_stats: dict = None, project_id: str = None, space_id: str = None, background_mode: bool = True, **kwargs) DetailedResponse | dict | None [source]
Add a subscription to the model deployment.
- Parameters:
data_mart_id (str) – ID of the data_mart (required)
service_provider_id (str) – ID of the service_provider (required)
asset (Asset) – an Asset object with asset’s information (required)
deployment (AssetDeploymentRequest) – an AssetDeploymentRequest object with deployment’s information (required)
asset_properties (AssetPropertiesRequest) – (optional) Additional asset properties (subject of discovery if not provided when creating the subscription).
risk_evaluation_status (RiskEvaluationStatus) – (optional)
analytics_engine (AnalyticsEngine) – (optional)
data_sources (List[DataSource]) – (optional)
training_data_stats – Training statistic json generated using training stats notebook (https://github.com/IBM/watson-openscale-samples/blob/main/training%20statistics/training_statistics_notebook.ipynb)
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with SubscriptionResponse result
A way you may use me:
>>> from ibm_watson_openscale import * >>> added_subscription_info = client.subscriptions.add( data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', service_provider_id='997b1474-00d2-4g05-ac02-287ebfc603b5', asset=Asset(...), deployment=AssetDeploymentRequest(...), asset_properties=AssetPropertiesRequest(...), )
- delete(subscription_id: str, force: bool = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse | dict | None [source]
Delete subscription.
- Parameters:
subscription_id (str) – Unique subscription ID.
force (bool) – (optional) force hard delete.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
A way you may use me:
>>> client.subscriptions.delete( background_mode=False, subscription_id='997b1474-00d2-4g05-ac02-287ebfc603b5', force=True )
- create_feedback_table(subscription_id: str, project_id: str = None, space_id: str = None, **kwargs) DetailedResponse [source]
Create a table for feedback dataset type.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataSetResponse result
- poll_subscription_status(subscription_id, message, ids, delay, project_id=None, space_id=None)[source]
- create_subscription_using_training_data(subscription_name, datamart_id, service_provider_id, model_info, sample_csv, spark_credentials, data_warehouse_connection, payload_table, feedback_table, scored_training_data_table, managed_by, project_id=None, space_id=None, background_mode: bool = True)[source]
Create batch subscription using model_info.
- Parameters:
subscription_name (str) – Name of this subscription.
datamart_id (str) – Datamart id in which we want to to create this subscription.
service_provider_id (str) – Service Provider id.
model_info (dict) –
Information about the model which needs the subscription. Format for model_info model_info = {
”model_type”: “binary”, “label_column”: “Risk”, “prediction”: “predicted_label”, “probability”: “probability”, “feature_columns”: [list of categorical columns]/None, “categorical_columns”: [list of categorical columns]/None, “scoring”: {
”url”: “url”:”scoring url”, # This is required if explainability needs to be enabled, “token”: “token for scoring”, # This is mandatory for Azure ML studio Model
}
}
sample_csv (csv) – Sample csv file
spark_credentials (dict) –
Dictionary containing spark connection information. Format for spark_credentials spark_credentials = {
- ”connection”: {
“endpoint”: <SPARK_ENDPOINT>, “location_type”: <LOCATION_TYPE>, “display_name”: <DISPLAY_NAME>, “instance_id”: <INSTANCE_ID>, “volume”: <VOLUME>
}, “credentials”: {
”username”: <USERNAME>, “apikey”: <APIKEY>
}
}
data_warehouse_connection (dict) –
Dictionary containing data warehouse (DB connection) information. Format for the DB connection dataware_house_connection = {
”type”: “jdbc”, “connection”: {
”jdbc_driver”: “com.ibm.db2.jcc.DB2Driver”, “use_ssl”: False, “certificate”: None, “jdbc_url”: “jdbc:db2://<HOST>:50000/SAMPLE”
}, “credentials”: {
”username”: “<USERNAME>”,
”password”: “<PASSWORD>”
}
}
payload_table (dict) –
Dictionary containing payload table connection information. Format for the payload table payload_table = {
- ”data”: {
“auto_create”: True, “database”: “SAMPLE”, “schema”: “KP”, “table”: “PAYLOAD_TABLE”
}, “parameters”:{
”partition_column”: “WOS_PARTITION_COLUMN”, “num_partitions”: 12
}
}
feedback_table (dict) – Dictionary containing feedback table connection information.
scored_training_data_table (dict) –
Dictionary scored trainin data table. Format for scored_training_data_table scored_training_data_table = {
- ”data”: {
“auto_create”: False, “database”: “SAMPLE”, “schema”: “KP”, “table”: “SCORED_TRAINING_DATA_TABLE”
}, “parameters”:{
”partition_column”: “WOS_PARTITION_COLUMN”, “num_partitions”: 12
}
}
managed_by (str) – To identify whether the subscription is online or batch. It should be either system for online subscription or self for batch subscripion.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- create_subscription(subscription_name: str, datamart_id, service_provider_id, configuration_archive, spark_credentials, data_warehouse_connection, payload_table: dict = {}, feedback_table: dict = {}, model_info: dict = {}, background_mode: bool = True, project_id=None, space_id=None, **kwargs)[source]
Create batch subscription
- Parameters:
subscription_name (str) – Name of the subscription.
datamart_id (str) – Datamart id in which we want to to create this subscription.
service_provider_id (str) – Service Provider id.
configuration_archive (str) – Path to the configuration archive file.
spark_credentials (dict) –
Dictionary containing spark connection information. Format for Remote Spark on hadoop spark_credentials = {
- ”connection”:{
“endpoint”: “<SPARK_ENDPOINT>”, “location_type”: “custom”
}, “credentials”: {
”username”: “<USERNAME>”, “password”: “<PASSWORD>”
}, “spark_settings”: {
”max_num_executors”: <MAX_EXECUTOR_COUNT>, “min_num_executors”: <MIN_EXECUTOR_COUNT>, “executor_cores”: <EXECUTOR_CORE>, “executor_memory”: <EXECUTOR_MEMORY>, “driver_cores”: <NUM_OF_DRIVER_CORES>, “driver_memory”: <DRIVER_MEMORY>
}
} Format for IAE Spark spark_credentials = { “connection”: {
”display_name”: “<IAE_INSTANCE_DISPLAYNAME>”, “endpoint”: “<IAE_JOB_ENDPOINT>”, “location_type”: “cpd_iae”, “volume”: “<VOLUME_NAME>”
}, “credentials”: {
”username”: “<USERNAME>”, “apikey”: “<APIKEY>”
}, “spark_setting”: {
#Look at remote spark settings
}
} :param dict data_warehouse_connection: Dictionary containing data warehouse (DB connection) information.
Format for the DB connection dataware_house_connection = {
“type”: “jdbc”, “connection”: {
“jdbc_driver”: “com.ibm.db2.jcc.DB2Driver”, “use_ssl”: False, “certificate”: None, “jdbc_url”: “jdbc:db2://<HOST>:50000/SAMPLE”
}, “credentials”: {
“username”: “<USERNAME>”,
“password”: “<PASSWORD>”
}
}
- Parameters:
payload_table (dict) –
Dictionary containing payload table connection information. Format for the payload table payload_table = {
- ”data”: {
“auto_create”: True, “database”: “SAMPLE”, “schema”: “KP”, “table”: “PAYLOAD_GERMAN_CREDIT_DATA_NEW”
}, “parameters”:{
”partition_column”: “WOS_PARTITION_COLUMN”, “num_partitions”: 12
}
}
feedback_table (dict) – Dictionary containing feedback table connection information. Format for the feedback_table is same as payload table
model_info (dict) –
Information about the model which needs the subscription. Format for model_info model_info = {
”model_type”: “binary”, “label_column”: “Risk”, “prediction”: “predicted_label”, “probability”: “probability”, “feature_columns”: [list of categorical columns]/None, “categorical_columns”: [list of categorical columns]/None, “scoring”: {
”url”: “url”:”scoring url”, # This is required if explainability needs to be enabled, “token”: “token for scoring”, # This is mandatory for Azure ML studio Model
}
}
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
subscription id
- Return type:
- configuration_synchrozation_get(subscription_id: str, **kwargs) DetailedResponse [source]
Get status of triggered configuraiton synchronization.
- get(subscription_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Get a specific subscription.
Get a specific subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with SubscriptionResponse result
- list(*, project_id: str | None = None, space_id: str | None = None, data_mart_id: str | None = None, service_provider_id: str | None = None, asset_asset_id: str | None = None, asset_asset_type: str | None = None, deployment_deployment_id: str | None = None, deployment_deployment_type: str | None = None, integration_reference_integrated_system_id: str | None = None, integration_reference_external_id: str | None = None, risk_evaluation_status_state: str | None = None, service_provider_operational_space_id: str | None = None, pre_production_reference_id: str | None = None, **kwargs) DetailedResponse [source]
List subscriptions.
List subscriptions.
- Parameters:
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
data_mart_id (str) – (optional) comma-separated list of IDs.
service_provider_id (str) – (optional) comma-separated list of IDs.
asset_asset_id (str) – (optional) comma-separated list of IDs.
asset_asset_type (str) – (optional) comma-separated list of types.
deployment_deployment_id (str) – (optional) comma-separated list of IDs.
deployment_deployment_type (str) – (optional) comma-separated list of types.
integration_reference_integrated_system_id (str) – (optional) comma-separated list of IDs.
integration_reference_external_id (str) – (optional) comma-separated list of IDs.
risk_evaluation_status_state (str) – (optional) comma-separated list of states.
service_provider_operational_space_id (str) – (optional) comma-separated list of operational space ids (property of service provider object).
pre_production_reference_id (str) – (optional) comma-separated list of IDs.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with SubscriptionResponseCollection result
- schemas(subscription_id: str, *, input_data: List[ScoreData] | None = None, training_data_reference: InputDataReference | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Derive model schemas from the training data.
Derive model schemas from the training data. Only “structured” input data type is supported. If the input_data_type field in the subscription (subscription -> entity -> asset -> input_data_type) is not “structured”, an error will be returned.
- Parameters:
subscription_id (str) – Unique subscription ID.
input_data (List[ScoreData]) – (optional) Array of score data object. If multiple score data objects are included, the “fields” array (if any) for score purposes will always be taken from the first score data object.
training_data_reference (InputDataReference) – (optional) InputDataReference is the same as TrainingDataReference except that neither location nor connection is required. This is needed for the Schemas API and to avoid updating existing APIs.
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with SchemaInferenceResponse result
- score(subscription_id: str, values: List[str], *, fields: List[str] | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Computes the bias mitigation/remediation for the specified model.
Computes the bias mitigation/remediation for the specified model. The fairness monitoring debias request payload details must be valid.
- Parameters:
subscription_id (str) – Unique subscription ID.
values (List[str]) – The values associated to the fields.
fields (List[str]) – (optional) The fields to process debias scoring.
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with FairnessMonitoringRemediation result
- tables(subscription_id: str, dataset_type: str, unknown_base_type: object, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Create a table for specified data set type.
Current supported dataset_type is feedback. The body of request should be json object (an empty object {} is fine).
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataSetResponse result
- trigger_configuration_synchrozation(subscription_id: str, *, exclude_monitors: List[str] | None = None, force: bool | None = None, **kwargs) DetailedResponse [source]
Trigger configuraiton synchronization from pre-production to production model.
Trigger configuraiton synchronization based on pre_production_reference_id in subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with ConfigurationSynchronization result
- update(subscription_id: str, patch_document: List[PatchDocument], *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Update a subscription.
Update existing asset (from ML service instance) subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with SubscriptionResponse result
APIClient.data_sets
- class DataSets(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
DataSets
Manages Data Sets.
- show(limit: int = 10, target_target_id: str | None = None, target_target_type: str | None = None, type: str | None = None, managed_by: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) None [source]
Show data sets. By default 10 records will be shown.
- Parameters:
limit (int) – maximal number of fetched rows. By default set to 10. (optional)
target_target_id (str) – (optional) ID of the data set target (e.g. subscription ID, business application ID).
target_target_type (str) – (optional) type of the target.
type (str) – (optional) type of the data set.
managed_by (str) – (optional) ID of the managing entity (e.g. business application ID).
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
None
A way you might use me is:
>>> client.data_sets.show() >>> client.data_sets.show(limit=20) >>> client.data_sets.show(limit=None)
- add(data_mart_id: str, name: str, type: str, target: Target, data_schema: SparkStruct, description: str = None, schema_update_mode: str = None, location: LocationTableName = None, managed_by: str = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse | dict | None [source]
Create Data Set.
- Parameters:
data_mart_id (str)
name (str)
type (str)
target (Target)
data_schema (SparkStruct)
description (str) – (optional)
schema_update_mode (str) – (optional)
location (LocationTableName) – (optional)
managed_by (str) – (optional)
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataSetResponse result
A way you might use me is:
>>> from ibm_watson_openscale import * >>> target = Target( target_id='subscription_id', target_type=TargetTypes.SUBSCRIPTION ) >>> data_schema = SparkStruct( type='struct', fields=[ SparkStructField( name='CheckingStatus', type='string', nullable=True, metadata={'columnInfo': {'columnLength': 64}, 'measure': 'discrete', 'modeling_role': 'feature'} ), SparkStructField( name='LoanDuration', type='integer', nullable=True, metadata={'modeling_role': 'feature'} ), SparkStructField( name='asset_revision', type='string', nullable=True, metadata={} ) ] ) >>> custom_dataset_info = client.data_sets.add( target=target, name='custom dataset', type='custom', data_schema=data_schema, data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5' )
- delete(data_set_id: str, background_mode: bool = True, force: bool = False, project_id: str = None, space_id: str = None) DetailedResponse | dict | None [source]
Delete Data Set.
- Parameters:
data_set_id (str) – ID of the data set.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
A way you may use me:
>>> client.data_sets.delete(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
- store_records(data_set_id: str, request_body: str | BufferedReader | List[PayloadRecord] | List[List] | List[Dict], header: bool = None, skip: int = None, limit: int = None, delimiter: str = None, on_error: str = None, csv_max_line_length: float = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse | dict | None [source]
Store records to specific data set.
- Parameters:
data_set_id (str) – ID of the data set.
scoring_payload_request (list[ScoringPayloadRequest])
header (bool) – (optional) if not provided service will attempt to automatically detect header in the first line.
skip (int) – (optional) skip number of rows from input.
limit (int) – (optional) limit for number of processed input rows.
delimiter (str) – (optional) delimiter character for data provided as csv.
on_error (str) – (optional) expected behaviour on error.
csv_max_line_length (float) – (optional) maximum length of single line in bytes (default 10MB).
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with Status result
A way you might use me is:
>>> from ibm_watson_openscale import * >>> store_record_info = client.data_sets.store_records( request_body=[ { "GENDER": "M", "PRODUCT_LINE": "Golf Equipment", "AGE": 25, "MARITAL_STATUS": "Unspecified", "PROFESSION": "Sales" }, { "GENDER": "M", "PRODUCT_LINE": "Sport shoes", "AGE": 28, "MARITAL_STATUS": "Married", "PROFESSION": "Sales" }, { "GENDER": "F", "PRODUCT_LINE": "Sport shoes", "AGE": 25, "MARITAL_STATUS": "Single", "PROFESSION": "Software Developer" } ], data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', ) >>> from ibm_watson_openscale.supporting_classes.payload_record import PayloadRecord >>> store_record_info = client.data_sets.store_records( request_body=[PayloadRecord( scoring_id='42e62c3ae2244f0d851009dec4754d74', request={ "fields": ["CheckingStatus", "LoanDuration", "CreditHistory", "LoanPurpose", "LoanAmount", "ExistingSavings", "EmploymentDuration", "InstallmentPercent", "Sex", "OthersOnLoan", "CurrentResidenceDuration", "OwnsProperty", "Age", "InstallmentPlans", "Housing", "ExistingCreditsCount", "Job", "Dependents", "Telephone", "ForeignWorker"], "values": [["less_0", 4, "all_credits_paid_back", "car_new", 250, "less_100", "less_1", 2, "male", "none", 1, "real_estate", 26, "stores", "rent", 1, "unskilled", 1, "none", "yes"]] }, response={ "fields": ["CheckingStatus", "LoanDuration", "CreditHistory", "LoanPurpose", "LoanAmount", "ExistingSavings", "EmploymentDuration", "InstallmentPercent", "Sex", "OthersOnLoan", "CurrentResidenceDuration", "OwnsProperty", "Age", "InstallmentPlans", "Housing", "ExistingCreditsCount", "Job", "Dependents", "Telephone", "ForeignWorker", "CheckingStatus_IX", "CreditHistory_IX", "EmploymentDuration_IX", "ExistingSavings_IX", "ForeignWorker_IX", "Housing_IX", "InstallmentPlans_IX", "Job_IX", "LoanPurpose_IX", "OthersOnLoan_IX", "OwnsProperty_IX", "Sex_IX", "Telephone_IX", "features", "rawPrediction", "probability", "prediction", "predictedLabel"], "values": [["less_0", 4, "all_credits_paid_back", "car_new", 250, "less_100", "less_1", 2, "male", "none", 1, "real_estate", 26, "stores", "rent", 1, "unskilled", 1, "none", "yes", 1.0, 3.0, 3.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 2.0, 0.0, 0.0, [1.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0, 2.0, 1.0, 1.0, 1.0, 0.0, 0.0, 4.0, 250.0, 2.0, 1.0, 4.0, 26.0, 1.0, 1.0], [19.600662549552556, 0.39933745044744245], [ 0.9800331274776278, 0.01996687252237212], 0.0, "No Risk"]] }, response_time=460, user_id='IBM-1234' )], data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', )
>>> csv_buffer_reader = io.open('path_to_csv', mode="rb") >>> store_record_info = client.data_sets.store_records( request_body=csv_buffer_reader, delimiter=',', header=True, limit=100, data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', csv_max_line_length = 8196 )
- get_update_status(data_set_id: str, request_id: str, project_id: str = None, space_id: str = None) DetailedResponse [source]
Get status of the specific request.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with Status result
A way you might use me is:
>>> update_status = client.data_sets.get_update_status( data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', request_id='7843-00d35462-346-ac0672-7357' )
- get_list_of_records(data_set_id: str, limit: int = 100, start: datetime = None, end: datetime = None, offset: int = None, includes: str = None, annotations: List[str] = None, exclude_annotations: bool = None, filter: str = None, include_total_count: bool = None, order: str = None, format: str = None, output_type: str = None, include_internal_columns=False, return_payload_raw_data=False, project_id: str = None, space_id: str = None) DetailedResponse | DataFrame [source]
List data set records.
- Parameters:
data_set_id (str) – ID of the data set.
limit (int) – By default it will return 100 records. If the value is greater than 1000 than it will be truncated.
start (datetime) – (optional) return records with timestamp greater than or equal to start parameter. Date string should be in the UTC ISO 8601 format. Ex: 2021-06-10T09:43:53.309Z
end (datetime) – (optional) return records with timestamp lower than end parameter. Date string should be in the UTC ISO 8601 format. Ex: 2021-06-10T09:43:53.309Z
offset (int) – (optional) offset of returned records.
includes (str) – (optional) return records with only specified columns. Parameter must be specified as comma separated string.
annotations (list[str]) – (optional) return record annotations with given names.
exclude_annotations (bool) – (optional) If there is no need to fetch annotations at all, set this parameter as true. There should be better performance.
filter (str) – (optional) return records for which transaction ids in associated data set the condition is met, format: {data_set_id}.{field_name}:{op}:{value}.
include_total_count (bool) – (optional) If total_count should be included. It can have performance impact if total_count is calculated.
order (str) – (optional) return records in order specified. There are two patterns. The first is random sampling, the other is sorting per column.
filter – (optional) return records for which transaction ids in associated data set the condition is met, format: {data_set_id}.{field_name}:{op}:{value}.
format (str) – (optional) What JSON format to use on output.
output_type (str) – (optional) type of the response data to be present, default is ‘dict’, available option is ‘pandas’
include_internal_columns (bool) – (optional) Flag to retrieve internal columns
return_payload_raw_data (bool) – (optional) Flag to retrieve only the raw data which was used for scoring. Applicable to only Payload Logging data and format is ‘pandas’
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataRecordsResponseCollection result
A way you might use me is:
>>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5') >>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', format=RecordsFormatTypes.DICT ) >>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', format=RecordsFormatTypes.LIST ) >>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', output_type=ResponseTypes.PYTHON ) >>> records = client.data_sets.get_list_of_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5', output_type=ResponseTypes.PANDAS )
- show_records(data_set_id: str | None = None, limit: int = 10, project_id=None, space_id=None) None [source]
Show data set records. By default 10 records will be shown.
- Parameters:
data_set_id (str) – ID of the data set.
limit (int) – Maximal number of fetched rows. By default set to 10. (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
None
A way you might use me is:
>>> client.data_sets.show_records(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
- print_records_schema(data_set_id: str | None = None, project_id: str | None = None, space_id: str | None = None) None [source]
Show data set records. By default 10 records will be shown.
- Parameters:
- Returns:
None
A way you might use me is:
>>> client.data_sets.print_records_schema(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
- get_records_count(data_set_id: str | None = None, project_id=None, space_id=None) int [source]
Count data set records.
- Parameters:
- Returns:
int
A way you might use me is:
>>> number_of_records = client.data_sets.get_records_count(data_set_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
- patch_records(data_set_id: str, patch_document: List[PatchDocument], *, project_id: str = None, space_id: str = None, **kwargs)[source]
Update data set records.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with Status result
- get(data_set_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Get data set with the given id.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataSetResponse result
- list(*, project_id: str | None = None, space_id: str | None = None, target_target_id: str | None = None, target_target_type: str | None = None, type: str | None = None, managed_by: str | None = None, **kwargs) DetailedResponse [source]
List all data sets specified by the parameters.
- Parameters:
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
target_target_id (str) – (optional) ID of the data set target (e.g. subscription ID.. ).
target_target_type (str) – (optional) type of the target.
type (str) – (optional) type of the data set.
managed_by (str) – (optional) ID of the managing entity (e.g. data mart id).
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataSetResponseCollection result
- update(data_set_id: str, patch_document: List[PatchDocument], *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Update a data set.
Update the data set.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataSetResponse result
APIClient.monitor_instances
- class MonitorInstances(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
Instances
Manages Monitor Instances.
- run(monitor_instance_id: str, triggered_by: str = 'user', parameters: dict | None = None, business_metric_context=None, project_id: str | None = None, space_id: str | None = None, background_mode: bool = True) Any [source]
Trigger monitoring run. :param str monitor_instance_id: Unique monitor instance ID. :param str triggered_by: (optional) An identifier representing the source
that triggered the run request (optional). One of: event, scheduler, user, webhook.
- Parameters:
parameters (dict) – (optional) Monitoring parameters consistent with the parameters_schema from the monitor definition.
business_metric_context (MonitoringRunBusinessMetricContext) – (optional) Properties defining the business metric context in the triggered run of AI metric calculation.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitoringRun result
A way you may use me:
>>> monitor_instance_run_info = client.monitor_instances.run( background_mode=False, monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5' )
- list(data_mart_id: str = None, monitor_definition_id: str = None, target_target_id: str = None, project_id: str = None, space_id: str = None, target_target_type: str = None) DetailedResponse [source]
List monitor instances.
- Parameters:
data_mart_id (str) – (optional) comma-separated list of IDs.
monitor_definition_id (str) – (optional) comma-separated list of IDs.
target_target_id (str) – (optional) comma-separated list of IDs.
target_target_type (str) – (optional) comma-separated list of types.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorInstanceCollection result
A way you may use me:
>>> monitor_instances_info = client.monitor_instances.list( data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', )
- show(limit: int = 10, data_mart_id: str | None = None, monitor_definition_id: str | None = None, target_target_id: str | None = None, target_target_type: str | None = None, project_id: str | None = None, space_id: str | None = None) None [source]
Show monitor instances. By default 10 records will be shown.
- Parameters:
limit (int) – Maximal number of fetched rows. By default set to 10. (optional)
data_mart_id (str) – (optional) comma-separated list of IDs.
monitor_definition_id (str) – (optional) comma-separated list of IDs.
target_target_id (str) – (optional) comma-separated list of IDs.
target_target_type (str) – (optional) comma-separated list of types.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
None
A way you might use me is:
>>> client.monitor_instances.show() >>> client.monitor_instances.show(limit=20) >>> client.monitor_instances.show(20)
- show_metrics(monitor_instance_id: str, limit: int = 10, project_id: str | None = None, space_id: str | None = None)[source]
Show metrics for monitor instance.
- Parameters:
monitor_instance_id (str) – ID of the monitor instance.
limit (int) – maximal number of fetched rows. By default set to 10. (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
None
A way you might use me is:
>>> client.monitor_instances.show_metrics(monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
- create(monitor_definition_id: str, target: Target, parameters: dict, data_mart_id: str = None, thresholds: List[MetricThresholdOverride] = None, schedule: MonitorInstanceSchedule = None, managed_by: str = None, training_data_stats: dict = None, background_mode: bool = True, skip_scheduler: bool = None, project_id: str = None, space_id: str = None, **kwargs) DetailedResponse | dict | None [source]
Create monitor instance.
- Parameters:
data_mart_id (str)
monitor_definition_id (str)
target (Target)
parameters (dict) – (optional) Monitoring parameters consistent with the parameters_schema from the monitor definition.
thresholds (list[MetricThresholdOverride]) – (optional)
schedule (MonitorInstanceSchedule) – (optional) The schedule used to control how frequently the target is monitored. The maximum frequency is once every 30 minutes. Defaults to once every hour if not specified.
managed_by (str) – (optional)
training_data_stats – Training statistic json generated using training stats notebook (https://github.com/IBM-Watson/aios-data-distribution/blob/master/training_statistics_notebook.ipynb)
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorInstanceResponse result
A way you might use me is:
>>> from ibm_watson_openscale import * >>> target = Target( target_type=TargetTypes.SUBSCRIPTION, target_id='997b1474-00d2-4g05-ac02-287ebfc603b5' ) >>> parameters = { min_feedback_data_size=50 } >>> thresholds = [ MetricThresholdOverride( metric_id=client.monitor_definitions.MONITORS.QUALITY.METRIC.ACCURACY, type=MetricThresholdTypes.LOWER_LIMIT, value=0.7 ) ] >>> monitor_instances_info = client.monitor_instances.create( data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', background_mode=False, monitor_definition_id=client.monitor_definitions.MONITORS.QUALITY.ID, target=target, parameters=parameters, thresholds=thresholds )
- delete(monitor_instance_id: str, background_mode: bool = True, force: bool = False, project_id: str = None, space_id: str = None) DetailedResponse | dict | None [source]
Delete monitor instance.
- Parameters:
monitor_instance_id (str) – Unique monitor instance ID.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
A way you might use me is:
>>> ai_client_v2.monitor_instances.delete( background_mode=False, monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5' )
- get(monitor_instance_id: str, project_id: str = None, space_id: str = None) DetailedResponse [source]
Get monitor instance details.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorInstanceResponse result
A way you might use me is:
>>> monitor_instance_info = client.monitor_instances.get( monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5' )
- update(monitor_instance_id: str, patch_document: List[PatchDocument], update_metadata_only: bool = None) DetailedResponse [source]
Update monitor instance.
- Parameters:
monitor_instance_id (str) – Unique monitor instance ID.
patch_document (List[PatchDocument])
update_metadata_only (bool) – (optional) Flag that allows to control if the underlaying actions related to the monitor reconfiguration should be triggered.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorInstanceResponse result
- get_metrics_count(monitor_instance_id: str, start: datetime, end: datetime, interval: str = None, filter: str = None, group: str = None, project_id=None, space_id=None)[source]
Get the count of the metrics.
- Parameters:
monitor_instance_id (str) – Unique monitor instance ID.
start (datetime) – Calculations inclusive, internally floored to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.
end (datetime) – Calculations exclusive, internally ceiled to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.
agg (str) – Comma delimited function list constructed from metric name and function, e.g. agg=metric_name:count,:last that defines aggregations.
interval (str) – (optional) Time unit in which metrics are grouped and aggregated, interval by interval.
filter (str) – (optional) Filter expression can consist of any metric tag or a common column of string type followed by filter name and optionally a value, all delimited by colon. Supported filters are: in, eq, null and exists. Sample filters are: filter=region:in:[us,pl],segment:eq:sales or filter=region:null,segment:exists.
group (str) – (optional) Comma delimited list constructed from metric tags, e.g. group=region,segment to group metrics before aggregations.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataMartGetMonitorInstanceMetrics result
A way you might use me is:
>>> metrics_count = client.monitor_instances.get_metrics_count( monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5', start=start_time, end=end_time, )
- get_metrics(monitor_instance_id: str, start: datetime, end: datetime, agg: str = 'last', interval: str = None, filter: str = None, group: str = None, project_id=None, space_id=None)[source]
Get all the generated metrics between start and end date for specific monitor instance id
- Parameters:
monitor_instance_id (str) – Unique monitor instance ID.
start (datetime) – Calculations inclusive, internally floored to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.
end (datetime) – Calculations exclusive, internally ceiled to achieve full interval. If interval is vulnerable to time zone, the calculated value depends on a backend db engine: PostgreSQL respects time zone and DB2 use UTC time. Calculated value is returned in response.
agg (str) – Comma delimited function list constructed from metric name and function, e.g. agg=metric_name:count,:last that defines aggregations.
interval (str) – (optional) Time unit in which metrics are grouped and aggregated, interval by interval.
filter (str) – (optional) Filter expression can consist of any metric tag or a common column of string type followed by filter name and optionally a value, all delimited by colon. Supported filters are: in, eq, null and exists. Sample filters are: filter=region:in:[us,pl],segment:eq:sales or filter=region:null,segment:exists.
group (str) – (optional) Comma delimited list constructed from metric tags, e.g. group=region,segment to group metrics before aggregations.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with DataMartGetMonitorInstanceMetrics result
A way you might use me is:
>>> metrics_count = client.monitor_instances.get_metrics_count( monitor_instance_id='997b1474-00d2-4g05-ac02-287ebfc603b5', start=start_time, end=end_time, )
- upload_drift_model(model_path: str, data_mart_id: str, subscription_id: str, archive_name: str = 'user_drift.tar.gz', enable_data_drift: bool = True, enable_model_drift: bool = True, project_id=None, space_id=None) DetailedResponse [source]
Upload a Drift model to be able to compute Drift monitor.
- Parameters:
model_path (str) – (required) path to the drift model
data_mart_id (str) – (required) data_mart ID
subscription_id (str) – (required) subscription ID
archive_name (str) – (optional) Archive name to use while storing tarball in datamart
enable_data_drift (str) – (optional) If data drift is expected to be enabled for this subscription. If set to True, archive is verified to contain a valid data constraints json file.
enable_model_drift (str) – (optional) If model drift is expected to be enabled for this subscription. If set to True, archive is verified to contain a valid drift model pickle file.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
A way you might use me is:
>>> client.monitor_instances.upload_drift_model( model_path='drift_models/drift_detection_model.tar.gz', data_mart_id='997b1474-00d2-4g05-ac02-287ebfc603b5', subscription_id='997b1474-00d2-4g05-ac02-287ebfc603b5', )
- download_drift_model(monitor_instance_id: str) DetailedResponse [source]
Downloads the model.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
A way you might use me is:
>>> client.monitor_instances.download_drift_model( monitor_instance_id="0a9a4b85-f2bb-46de-850b-f033d7d37d9a" )
- download_drift_model_metadata(monitor_instance_id: str) DetailedResponse [source]
Downloads the model metadata.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
A way you might use me is:
>>> client.monitor_instances.download_drift_model_metadata( monitor_instance_id="0a9a4b85-f2bb-46de-850b-f033d7d37d9a" )
- list_runs(monitor_instance_id: str, start: str | None = None, limit: int | None = None, project_id=None, space_id=None)[source]
List monitoring runs.
List monitoring runs.
- Parameters:
monitor_instance_id (str) – Unique monitor instance ID.
start (str) – (optional) The page token indicating where to start paging from.
limit (int) – (optional) The limit of the number of items to return, for example limit=50. If not specified a default of 100 will be used.
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitoringRunCollection result
- get_run_details(monitor_instance_id: str, monitoring_run_id: str, project_id=None, space_id=None, **kwargs)[source]
Get monitoring run details. :param str monitor_instance_id: Unique monitor instance ID. :param str monitoring_run_id: Unique monitoring run ID. :param dict headers: A dict containing the request headers :param str project_id: Id of the Project context in which governance operation is happening (optional) :param str space_id: Id of the Space context in which governance operation is happening (optional) :return: A DetailedResponse containing the result, headers and HTTP status code. :rtype: DetailedResponse with MonitoringRun result
- explanation_tasks(scoring_ids: List[str], input_rows: List[dict] | None = None, explanation_types: List[str] | None = None, subscription_id=None, project_id=None, space_id=None, **kwargs)[source]
Compute explanations.
Submit tasks for computing explanation of predictions.
- Parameters:
scoring_ids (List[str]) – IDs of the scoring transaction.
input_rows (List[dict]) – (optional) List of scoring transactions.
explanation_types (List[str]) – (optional) Types of explanations to generate.
subscription_id (str) – (optional) Unique subscription ID.
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PostExplanationTaskResponse result
- get_explanation_tasks(explanation_task_id: str, subscription_id=None, project_id=None, space_id=None, **kwargs)[source]
Get explanation.
Get explanation for the given explanation task id.
- Parameters:
explanation_task_id (str) – ID of the explanation task.
subscription_id (str) – Unique subscription ID.
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with GetExplanationTaskResponse result
- get_all_explaination_tasks(offset=None, limit=None, subscription_id=None, scoring_id=None, status=None, project_id=None, space_id=None, **kwargs)[source]
List all explanations.
List of all the computed explanations.
- Parameters:
subscription_id (str) – Unique subscription ID.
offset (int) – (optional) offset of the explanations to return.
limit (int) – (optional) Maximum number of explanations to return.
scoring_id (str) – (optional) ID of the scoring transaction.
status (str) – (optional) Status of the explanation task.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with GetExplanationTasksResponse result
- get_measurement_details(monitor_instance_id: str, measurement_id: str, project_id=None, space_id=None, **kwargs)[source]
Get Measurement details. Get Measurement info for the given measurement and monitor instance id. :param str monitor_instance_id: ID of the monitor instance. :param str measurement_id: ID of the measurement. :param dict headers: A dict containing the request headers :param str project_id: Id of the Project context in which governance operation is happening (optional) :param str space_id: Id of the Space context in which governance operation is happening (optional) :return: A DetailedResponse containing the result, headers and HTTP status code. :rtype: DetailedResponse with MonitorMeasurementResponse result
- add_measurements(monitor_instance_id: str, monitor_measurement_request: List[MonitorMeasurementRequest], project_id=None, space_id=None, **kwargs)[source]
Publish measurement data to OpenScale.
Publish measurement data to OpenScale for a specific monitor instance.
- Parameters:
monitor_instance_id (str) – Unique monitor instance ID.
monitor_measurement_request (List[MonitorMeasurementRequest])
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- upload_explainability_archive(subscription_id: str, archive: BinaryIO, **kwargs)[source]
Upload explainability archives.
API to upload explainability archives such as the Perturbations scoring response archive. The api can also be used to update the archive.
- Parameters:
subscription_id (str) – Unique subscription ID.
archive (BinaryIO) – explanation Archive
- Return type:
DetailedResponse
- get_explainability_archive(subscription_id: str, **kwargs)[source]
Retrieves the Explainability archives.
API to retrieve the Explainability archives.
- Parameters:
subscription_id (str) – Unique subscription ID.
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- enable_monitor_using_training_data(datamart_id, subscription_id, monitors_config, drifted_transaction_table={}, explain_queue_table={}, explain_results_table={}, project_id=None, space_id=None)[source]
Enable configured monitors and learn stats online
- Parameters:
datamart_id (str) – Datamart id in which we want to to create this subscription.
subscription_id (str) – subscription id
monitors_config (dict) –
configuration params for monitors Format for the monitors_config is as follows monitors_config = {
- ”fairness_configuration”: {
“enabled”: True, “parameters”: { }, “thresholds”: [ ]
}, “quality_configuration”: {
”enabled”: True, “parameters” : { }, “thresholds” : []
}, “explainability_configuration”:{
”enabled”: True, “parameters” : {
”enable_online_learning”: True
}
}, “drift_configuration”: {
”enabled”: True, “parameters” : { “train_drift_model”: True }
}
}
drifted_transaction_table (dict) –
Dictionary containing drifted transaction table connection information. Required if drift is to be configured Format for the drifted transaction table is as follows drifted_transaction_table = {
- ”data”: {
“auto_create”: False, “database”: “SAMPLE”, “schema”: “KP”, “table”: “DRIFTED_TRANSACTION_TABLE”
}, “parameters”:{
”partition_column”: “WOS_PARTITION_COLUMN”, “num_partitions”: 12
}
}
explain_queue_table (dict) – Dictionary containing explanation queue table connection information. Required if explanation is to be configured. Format for the explain_queue_table is same as drifted transaction table
explain_results_table (dict) – Dictionary containing explanation results table connection information. Required if explanation is to be configured. Format for the explain_results_table is same as drifted transaction table
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
list containing monitor instance ids
- Return type:
- enable_monitors(datamart_id, service_provider_id, subscription_id, configuration_archive, drifted_transaction_table={}, explain_queue_table={}, explain_results_table={}, project_id=None, space_id=None)[source]
Enable configured monitors using configuration archive file
- Parameters:
datamart_id (str) – Datamart id in which we want to to create this subscription.
service_provider_id (str) – Service Provider id.
configuration_archive (str) – Path to the configuration archive.
drifted_transaction_table (dict) –
Dictionary containing drifted transaction table connection information. Required if drift is to be configured Format for the drifted transaction table is as follows
- drifted_transaction_table = {
- “data”: {
“auto_create”: True, “database”: “SAMPLE”, “schema”: “KP”, “table”: “drifted_transactions_table_new”
}
}
explain_queue_table (dict) – Dictionary containing explanation queue table connection information. Required if explanation is to be configured. Format for the explain_queue_table is same as drifted transaction table
explain_results_table (dict) – Dictionary containing explanation results table connection information. Required if explanation is to be configured. Format for the explain_results_table is same as drifted transaction table
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
list containing monitor instance ids
- Return type:
- get_drift_v2_archive_metadata(subscription_id: str, archive_id: str = None, **kwargs) DetailedResponse [source]
Get drift archive metadata for a given subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- upload_drift_v2_archive(subscription_id: str, archive_path: str, archive_name: str = None, **kwargs) DetailedResponse [source]
Upload drift_v2 archive for a given subscription.
This API is used to upload the drift_v2 archive necessary to configure the Drift v2 monitor.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- download_drift_v2_archive(subscription_id: str, archive_id: str = None, **kwargs) DetailedResponse [source]
Get drift v2 archive for a given subscription.
This API is used to download the drift_v2 Archives.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
APIClient.monitor_instances.mrm
- class ModelRiskManagement(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
ModelRiskManagement
Manage model risk management monitoring for asset.
- evaluate_risk(monitor_instance_id: str, test_data_set_name: str | None = None, test_data_path: str | None = None, publish_metrics: str | None = None, publish_lineage: str | None = None, publish_fact: str | None = None, includes_model_output: str | None = None, delimiter: str | None = None, evaluation_tests: str | None = None, content_type='text/csv', project_id=None, space_id=None, body=None, background_mode: bool = True, **kwargs) DetailedResponse [source]
Uploads the test data and triggers a monitor run for risk evaluation.
- Parameters:
monitor_instance_id (str) – The monitor instance ID.
:param str test_data_path : (optional) Path to test data :param str body : (optional) Path to mapping json file :param str content_type: (optional) The type of the input. A character
encoding can be specified by including a charset parameter. For example, ‘text/csv;charset=utf-8’.
- Parameters:
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
test_data_set_name (str) – (optional) The name of the test CSV file being uploaded.
publish_metrics (str) – (optional) Flag to decide whether to send evaluated metrics to OpenPages.
publish_lineage (str) – (optional) Flag to decide whether a lineage event should be published to an integrated system.
publish_fact (str) – (optional) Flag to decide whether Fact metadata should be published to an integrated system.
includes_model_output (str) – (optional) Boolean flag to indicate whether the data being uploaded contains scored output or not.
evaluation_tests (str) – (optional) Comma separated list of monitor tests to run.
delimiter (str) – (optional) The delimiter to be used for CSV/Dynamic CSV files.
background_mode – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PostRiskEvaluationsResponse result
- get_risk_evaluation(monitor_instance_id: str, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Returns the status of the risk evaluation.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskEvaluationResponse result
- cancel_risk_evaluation(monitor_instance_id: str, cancel_run: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Cancels the risk evaluations run.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskEvaluationResponse result
- update_notification_preferences(monitor_instance_id: str, notification_enabled: bool, notification_frequency: str, notification_emails: List[str], project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Sets the users email notification preference in the MRM monitor instance of a given model subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskNotificationPreferencesResponse result
- get_notification_preferences(monitor_instance_id: str, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Gets the users email notification preferences for a given model subscription.
Gets the users email notification preferences for a given model subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskNotificationPreferencesResponse result
- publish_metrics(monitor_instance_id: str, monitoring_run_id: str, metrics_info: dict | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Publishes the chosen metrics to the integrated system reference.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- get_risk_evaluation_status_list(project_id: str | None = None, space_id: str | None = None, data_mart_id: str | None = None, **kwargs) DetailedResponse [source]
Returns the risk evaluation status of all subscriptions in a given service instance.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MrmGetRiskEvaluationStatusEntity result
- get_risk_evaluation_status(subscription_id: str, project_id=None, space_id=None, **kwargs) DetailedResponse [source]
Gets risk evaluation status for the given subscription.
- update_risk_evaluation_status(subscription_id: str, state: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Updates the risk evaluation status for the given subscription.
- mrm_download_pdf_report(monitor_instance_id: str, monitoring_run_id: str, file_name: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) None [source]
Returns the risk evaluation report in a PDF format.
- execute_prompt_setup(prompt_template_asset_id: str, project_id: str | None = None, space_id: str | None = None, deployment_id: str | None = None, label_column: str | None = None, operational_space_id: str | None = None, problem_type: str | None = None, classification_type: str | None = None, input_data_type: str | None = None, context_fields: List[str] | None = None, question_field: str | None = None, supporting_monitors: dict = {}, background_mode: bool = True, **kwargs) DetailedResponse [source]
Performs the setup activities in Openscale for a given prompt template asset.
Note: This method will be deprecated in the next release and be replaced by wos_client.wos.execute_prompt_setup() method”
- Parameters:
prompt_template_asset_id (str) – The GUID of the prompt template asset.
label_column (str) – (optional) The name of the column containing the ground truth or actual labels.
operational_space_id (str) – (optional) The rank of the environment in which the monitoring is happening. Accepted values are development, pre_production, production.
problem_type (str) – (optional) The task type to monitor for the given prompt template asset.
classification_type (str) – (optional) The classification type binary/multiclass applicable only for classification problem (task) type.
input_data_type (str) – (optional) The input data type.
context_fields (List[str]) – (optional) The list of prompt variables containing the context. Applicable only for Retrieval-Augmented Generation problem type.
question_field (str) – (optional) The prompt variable containing the question. Applicable only for Retrieval-Augmented Generation problem type.
supporting_monitors (dict) – (optional)
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
deployment_id (str) – (optional) The GUID of the deployment.
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PromptSetupResponse result
- get_prompt_setup(prompt_template_asset_id: str, project_id: str | None = None, space_id: str | None = None, deployment_id: str | None = None, **kwargs) DetailedResponse [source]
Gets the status of the prompt setup for the given prompt template asset.
Note: This method will be deprecated in the next release and be replaced by wos_client.wos.get_prompt_setup() method
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PromptSetupResponse result
- mrm_download_report(monitor_instance_id: str, monitoring_run_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Returns the risk evaluation report in a PDF format.
Returns the risk evaluation report in a PDF format.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with BinaryIO result
- mrm_get_all_sub_risk_evaluation_status(*, project_id: str | None = None, space_id: str | None = None, data_mart_id: str | None = None, **kwargs) DetailedResponse [source]
Returns the risk evaluation status of all subscriptions in a given service instance.
Returns the risk evaluation status of all subscriptions in a given service instance.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MrmGetRiskEvaluationStatusEntity result
- mrm_get_notification_preferences(monitor_instance_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Gets the users email notification preferences for a given model subscription.
Gets the users email notification preferences for a given model subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskNotificationPreferencesResponse result
- mrm_get_prompt_setup(prompt_template_asset_id: str, *, project_id: str | None = None, space_id: str | None = None, deployment_id: str | None = None, **kwargs) DetailedResponse [source]
Gets the status of the prompt setup for the given prompt template asset.
Gets the status of the prompt setup for the given prompt template asset.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PromptSetupResponse result
- mrm_get_risk_evaluation(monitor_instance_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Returns the status of the risk evaluation.
Returns the status of the risk evaluation.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskEvaluationResponse result
- mrm_get_risk_evaluation_status(subscription_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Gets risk evaluation status for the given subscription.
Gets risk evaluation status for the given subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- mrm_publish_metrics(monitor_instance_id: str, monitoring_run_id: str, *, metrics: List[IntegratedSystemMetricsArray] | None = None, send_report: bool | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Publishes the chosen metrics to the integrated system reference.
Publishes the chosen metrics to the integrated system reference.
- Parameters:
monitor_instance_id (str) – The monitor instance ID.
monitoring_run_id (str) – The monitoring run ID.
metrics (List[IntegratedSystemMetricsArray]) – (optional)
send_report (bool) – (optional)
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- mrm_put_risk_evaluation(monitor_instance_id: str, *, cancel_run: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Cancels the risk evaluations run.
Cancels the risk evaluations run.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskEvaluationResponse result
- mrm_risk_evaluations(monitor_instance_id: str, *, unknown_base_type: object | str | TextIO | None = None, content_type: str | None = None, project_id: str | None = None, space_id: str | None = None, test_data_set_name: str | None = None, publish_metrics: str | None = None, publish_lineage: str | None = None, publish_fact: str | None = None, includes_model_output: str | None = None, delimiter: str | None = None, evaluation_tests: str | None = None, **kwargs) DetailedResponse [source]
Uploads the test data and triggers a monitor run for risk evaluation.
Uploads the test data and triggers a monitor run for risk evaluation.
- Parameters:
monitor_instance_id (str) – The monitor instance ID.
unknown_base_type (UNKNOWN_BASE_TYPE) – (optional)
content_type (str) – (optional) The type of the input. A character encoding can be specified by including a charset parameter. For example, ‘text/csv;charset=utf-8’.
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
test_data_set_name (str) – (optional) The name of the test CSV file being uploaded.
publish_metrics (str) – (optional) Flag to decide whether to send evaluated metrics to OpenPages.
publish_lineage (str) – (optional) Flag to decide whether a lineage event should be published to an integrated system.
publish_fact (str) – (optional) Flag to decide whether Fact metadata should be published to an integrated system.
includes_model_output (str) – (optional) Boolean flag to indicate whether the data being uploaded contains scored output or not.
delimiter (str) – (optional) The delimiter to be used for CSV/Dynamic CSV files.
evaluation_tests (str) – (optional) Comma separated list of monitor tests to run.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PostRiskEvaluationsResponse result
- mrm_start_prompt_setup(prompt_template_asset_id: str, *, label_column: str | None = None, operational_space_id: str | None = None, problem_type: str | None = None, classification_type: str | None = None, input_data_type: str | None = None, context_fields: List[str] | None = None, question_field: str | None = None, monitors: PromptSetupRequestMonitors | None = None, project_id: str | None = None, space_id: str | None = None, deployment_id: str | None = None, **kwargs) DetailedResponse [source]
Performs the setup activities in Openscale for a given prompt template asset.
Performs the service provider creation, subscription creation and monitors configuration for the given prompt template asset.
- Parameters:
prompt_template_asset_id (str) – The GUID of the prompt template asset.
label_column (str) – (optional) The name of the column containing the ground truth or actual labels.
operational_space_id (str) – (optional) The rank of the environment in which the monitoring is happening. Accepted values are development, pre_production, production.
problem_type (str) – (optional) The task type to monitor for the given prompt template asset.
classification_type (str) – (optional) The classification type binary/multiclass applicable only for classification problem (task) type.
input_data_type (str) – (optional) The input data type.
context_fields (List[str]) – (optional) The list of prompt variables containing the context. Applicable only for Retrieval-Augmented Generation problem type.
question_field (str) – (optional) The prompt variable containing the question. Applicable only for Retrieval-Augmented Generation problem type.
monitors (PromptSetupRequestMonitors) – (optional)
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
deployment_id (str) – (optional) The GUID of the deployment.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PromptSetupResponse result
- mrm_update_notification_preferences(monitor_instance_id: str, *, notification_enabled: bool | None = None, notification_frequency: str | None = None, notification_emails: List[str] | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Sets the users email notification preference in the MRM monitor instance of a given model subscription.
Sets the users email notification preference in the MRM monitor instance of a given model subscription.
- Parameters:
monitor_instance_id (str) – The monitor instance ID.
notification_enabled (bool) – (optional)
notification_frequency (str) – (optional)
notification_emails (List[str]) – (optional)
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with RiskNotificationPreferencesResponse result
- mrm_update_risk_evaluation_status(subscription_id: str, *, state: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse [source]
Updates the risk evaluation status for the given subscription.
Updates the risk evaluation status for the given subscription.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
APIClient.monitor_definitions
- class MonitorDefinitions(ai_client: WatsonOpenScaleV2Adapter, project_id=None, space_id=None)[source]
Bases:
Monitors
Manages Monitor Definitions.
- add(name: str, metrics: List[MonitorMetricRequest], tags: List[MonitorTagRequest], description: str = None, applies_to: ApplicabilitySelection = None, parameters_schema: object = None, managed_by: str = None, schedule: MonitorInstanceSchedule = None, monitor_runtime: MonitorRuntime = None, project_id: str = None, space_id: str = None, background_mode: bool = True) DetailedResponse | dict | None [source]
Add custom monitor.
- Parameters:
name (str) – Monitor UI label (must be unique).
metrics (List[MonitorMetricRequest]) – A list of metric definition.
tags (List[MonitorTagRequest]) – Available tags.
description (str) – (optional) Long monitoring description presented in monitoring catalog.
applies_to (ApplicabilitySelection) – (optional)
parameters_schema (object) – (optional) JSON schema that will be used to validate monitoring parameters when enabled.
managed_by (str) – (optional)
schedule (MonitorInstanceSchedule) – (optional) The schedule used to control how frequently the target is monitored. The maximum frequency is once every 30 minutes. Defaults to once every hour if not specified.
monitor_runtime (MonitorRuntime) – (optional) Field to specify if scheduler should be created or not.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorDisplayForm result
A way you may use me:
>>> from ibm_watson_openscale import * >>> metrics = [ MonitorMetricRequest( name='sensitivity', thresholds=[MetricThreshold( type=MetricThresholdTypes.LOWER_LIMIT, default=0.8 )] ), MonitorMetricRequest( name='specificity', thresholds=[MetricThreshold( type=MetricThresholdTypes.LOWER_LIMIT, default=0.75 )] ), ] >>> tags = [ MonitorTagRequest( name='region', description='customer geographical region' ) ] >>> my_monitor = client.monitor_definitions.add( name='my model performance', metrics=metrics, tags=tags, background_mode=False)
- delete(monitor_definition_id: str, background_mode: bool = True, force: bool = False, project_id: str = None, space_id: str = None) DetailedResponse | dict | None [source]
Delete custom monitor.
- Parameters:
monitor_definition_id (str) – Unique monitor definition ID.
background_mode (bool) – if set to True, run will be in asynchronous mode, if set to False it will wait for result (optional)
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
A way you may use me:
>>> client.monitor_definitions.delete(monitor_definition_id='997b1474-00d2-4g05-ac02-287ebfc603b5')
- update(monitor_definition_id: str, name: str, metrics: List[MonitorMetricRequest], tags: List[MonitorTagRequest], description: str = None, applies_to: ApplicabilitySelection = None, parameters_schema: object = None, managed_by: str = None, schedule: MonitorInstanceSchedule = None, project_id: str = None, space_id: str = None) DetailedResponse [source]
Edit custom monitor.
Update monitor.
- Parameters:
monitor_definition_id (str) – Unique monitor definition ID.
name (str) – Monitor UI label (must be unique).
metrics (List[MonitorMetricRequest]) – A list of metric definition.
tags (List[MonitorTagRequest]) – Available tags.
description (str) – (optional) Long monitoring description presented in monitoring catalog.
applies_to (ApplicabilitySelection) – (optional)
parameters_schema (object) – (optional) JSON schema that will be used to validate monitoring parameters when enabled.
managed_by (str) – (optional)
schedule (MonitorInstanceSchedule) – (optional) The schedule used to control how frequently the target is monitored. The maximum frequency is once every 30 minutes. Defaults to once every hour if not specified.
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorDisplayForm result
A way you may use me:
>>> from ibm_watson_openscale import * >>> metrics = [ MonitorMetricRequest( name='sensitivity', thresholds=[MetricThreshold( type=MetricThresholdTypes.LOWER_LIMIT, default=0.7 )] ), MonitorMetricRequest( name='specificity', thresholds=[MetricThreshold( type=MetricThresholdTypes.LOWER_LIMIT, default=0.6 )] ), ] >>> tags = [ MonitorTagRequest( name='region', description='customer geographical region'.upper() ) ] >>> my_monitor = client.monitor_definitions.update( monitor_definition_id='monitor_definition_id', name='my model performance', metrics=metrics, tags=tags)
- show(limit: int = 10, project_id=None, space_id=None) None [source]
Show monitor definitions. By default 10 records will be shown.
- Parameters:
A way you might use me is:
>>> client.monitor_definitions.show() >>> client.monitor_definitions.show(limit=20) >>> client.monitor_definitions.show(limit=None)
- get(monitor_definition_id: str, *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse
Get a specific monitor definition.
Get a specific monitor definition.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorDisplayForm result
- list(*, project_id: str | None = None, space_id: str | None = None, name: str | None = None, type: str | None = None, **kwargs) DetailedResponse
List available monitors.
List available monitors.
- Parameters:
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
name (str) – (optional) comma-separated list of names.
type (str) – (optional) Either of service or user can be specifeid. service is corresponding to monitor definitions managed by IBM, and user is corresponding to those of managed by users.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorCollections result
- patch(monitor_definition_id: str, json_patch_operation: List[JsonPatchOperation], *, project_id: str | None = None, space_id: str | None = None, **kwargs) DetailedResponse
Update a monitor definition.
Update a monitor definition.
- Parameters:
monitor_definition_id (str) – Unique monitor definition ID.
json_patch_operation (List[JsonPatchOperation])
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
headers (dict) – A dict containing the request headers
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with MonitorDisplayForm result
APIClient.ai_metrics
- class AIMetrics(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
object
- compute_metrics(spark=None, configuration=None, data_frame=None, metric_aggregator=None, **kwargs)[source]
Compute research metrics based on the configuration. :param SparkSession spark: Spark session object to be used for computing metrics. :param dict configuration: Configuration for computing metrics. :param Union[DataFrame, pd.DataFrame] data_frame: data frame containing the data on which metrics to be computed. :return: Key/Value pair where key is the metric group name and value is an object consisting of the metric results for all individual metrics. :rtype: dict
This is how the configuration parameter dict will look like
>>> from ibm_metrics_plugin.common.utils.constants import FairnessMetricType configuration = {} configuration['configuration'] = { "problem_type": "binary", "label_column": "Risk", "fairness": { "metrics_configuration": { FairnessMetricType.SPD.value: { "features": [ ["Sex"],["Age"] ] }, FairnessMetricType.SED.value: { "features": [ ["Sex"],["Sex","Age"] ], "concentration": 1.0 } }, "protected_attributes": [ { "feature": "Sex", "reference_group": ["male"] }, { "feature": "Age", "reference_group": [[26, 55],[56,75]] } ], "favourable_label": ["No Risk"], "unfavourable_label": ["Risk"] } }
A way you might use me is: >>> client.ai_metrics.compute_metrics(spark, configuration, data_frame)
- compute_metrics_as_job(spark_credentials: dict, configuration: dict, background=True, timeout=300, **kwargs)[source]
Compute research metrics as spark job on remote spark.
- Parameters:
- Returns:
Key/Value pair where key is the metric group name and value is an object consisting of the metric results for all individual metrics.
- Return type:
This is how the parameters look like
>>> spark_credentials = { "connection": { "endpoint": "<JOB_ENDPOINT>", "location_type": "cpd_iae", "display_name": "<IAE_INSTANCE_NAME>", "instance_id": "<IAE_INSTANCE_ID>", "volume": "<MY_VOLUME>" }, "credentials": { "username": "admin", "apikey":"<API_KEY" } } from ibm_metrics_plugin.common.utils.constants import FairnessMetricType metric_config = { "problem_type":"binary", "label_column" : "Risk", "fairness": { "metrics_configuration": { FairnessMetricType.SPD.value: { "features": [ ["Sex"],["Age"] ] } }, "protected_attributes": [ { "feature": "Sex", "reference_group": ["male"], "monitored_group": ["female"], "threshold": 0.95, }, { "feature": "Age", "reference_group": [[26, 55],[56,75]], "monitored_group": [[18, 25]], "threshold": 0.95, }, ], "favourable_label": ["No Risk"], "unfavourable_label": ["Risk"], "min_records": 100 } } configuration = { "spark_settings": { "max_num_executors": 4, "executor_cores": 1, "executor_memory": "1", "driver_cores": 1, "driver_memory": "1" }, "arguments": { "storage": { "type": "hive", "connection": { "location_type": "metastore", "metastore_url": "<METASTORE_URL>" } }, "tables": [ { "type": "training", "database": "<DB_NAME>", "schema": "", "table": "<TABLE_NAME>" } ] } } configuration['arguments']['metric_configuration'] = metric_config
A way you might use me is: >>> client.ai_metrics.compute_metrics_as_job(spark_credentials, configuration)
- get_job_output(job_response)[source]
Check the metrics evaluation job status and return the output on completion.
- fit_transformer(spark=None, configuration=None, data_frame=None, **kwargs)[source]
Train a metric transformer.
- Parameters:
spark (SparkSession) – Spark session object to be used for evaluation.
configuration (dict) – Configuration for fitting the transformer.
data_frame (Union[DataFrame, pd.DataFrame]) – Dataframe on which the transformer is to be trained upon.
- Returns:
Instance of WOSTransformer
- Return type:
WOSTransformer
This is how the configuration parameter dict will look like
>>> from ibm_metrics_plugin.common.utils.constants import FairnessMetricType configuration = {} configuration["configuration"] = { "fairness": { "metrics_configuration": { FairnessMetricType.FST.value: { "params": { "epsilon": 0.01, "criteria": "MSP" }, "features": {"probabilities": <PROBABILITY_COLUMN_NAME>, "protected": <PROTECTED_ATTRIBUTE_NAME>} } } } }
A way you might use me is: >>> client.ai_metrics.fit_transformer(spark, configuration, data_frame)
- fit_transformer_as_job(spark_credentials: dict, configuration: dict, **kwargs)[source]
Fit metric transformer as spark Job
- Parameters:
- Returns:
Instance of WOSTransformer
- Return type:
WOSTransformer
This is how the parameters look like
>>> spark_credentials = { "connection": { "endpoint": "<JOB_ENDPOINT>", "location_type": "cpd_iae", "display_name": "<IAE_INSTANCE_NAME>", "instance_id": "<IAE_INSTANCE_ID>", "volume": "<MY_VOLUME>" }, "credentials": { "username": "admin", "apikey":"<API_KEY" } } from ibm_metrics_plugin.common.utils.constants import FairnessMetricType metric_config = { "problem_type":"binary", "label_column" : "Risk", "fairness": { "metrics_configuration": { FairnessMetricType.FST.value: { "params": { "epsilon": 0.01, "criteria": "MSP" }, "features": {"probabilities": <PROBABILITY_COLUMN_NAME>, "protected": <PROTECTED_ATTRIBUTE_NAME>} } } } } configuration = { "spark_settings": { "max_num_executors": 4, "executor_cores": 1, "executor_memory": "1", "driver_cores": 1, "driver_memory": "1" }, "arguments": { "storage": { "type": "hive", "connection": { "location_type": "metastore", "metastore_url": "<METASTORE_URL>" } }, "tables": [ { "type": "training", "database": "<DB_NAME>", "schema": "", "table": "<TABLE_NAME>" } ] } } configuration['arguments']['metric_configuration'] = metric_config
A way you might use me is:
>>> client.ai_metrics.fit_transformer_as_job(spark_credentials, configuration)
- transform_result(metrics_result, metric_group_type, metric_type, **kwargs)[source]
Transform the json metric result to the required object. For SHAP metric, the result is transformed to SHAP explanation objects which can then be used to plot the explanations. An exception is thrown when invoked for metric which do not support transformation of result.
APIClient.llm_metrics
- class LLMMetrics(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
object
- compute_metrics(configuration: dict, sources: DataFrame | None = None, predictions: DataFrame | None = None, references: DataFrame | None = None, custom_evaluators=[], **kwargs)[source]
Compute LLM based metrics based on the configuration. :param DataFrame sources: data frame containing the input data (if required or else empty dataframe). :param DataFrame predictions: data frame containing the input data (if required or else empty dataframe). :param DataFrame references: data frame containing the referene data (if required or else empty dataframe). :param List custom_evaluators: List of custom evaluator functions that compute additional custom metrics :return: Key/Value pair where key is the metric name and value is an object consisting of the metric results for all individual metrics. :rtype: dict
This is how the configuration parameter dict will look like
>>> from ibm_metrics_plugin.metrics.llm.utils.constants import LLMTextMetricGroup, LLMSummarizationMetrics, HAP_SCORE metric_config = { "configuration": { LLMTextMetricGroup.SUMMARIZATION.value: { #This is metric group LLMSummarizationMetrics.ROUGE_SCORE.value: { #This is individual metric and contains it's specific parameters if required "use_aggregator": True, "use_stemmer": True }, LLMSummarizationMetrics.SARI.value: { #This is individual metric and contains it's specific parameters if required }, LLMSummarizationMetrics.BLEURT_SCORE.value: {}, HAP_SCORE: {}, LLMSummarizationMetrics.SACREBLEU.value: {}, LLMSummarizationMetrics.WIKI_SPLIT.value: {}, LLMSummarizationMetrics.METEOR.value: {}, LLMSummarizationMetrics.NORMALIZED_RECALL.value: {}, LLMSummarizationMetrics.NORMALIZED_PRECISION.value: {}, LLMSummarizationMetrics.NORMALIZED_F1_SCORE.value: {}, } } } A way you might use me is: >>> client.llm_metrics.compute_metrics(configuration, sources, predictions, references) User can pass custom_evaluators as argument to compute custom metrics. eg: def fun1(sources: pd.DataFrame, predictions: pd.DataFrame, references: pd.DataFrame): # compute custom metrics and returns it as a dict custom_evaluators = [fun1] >>> client.llm_metrics.compute_metrics(configuration, sources, predictions, references, custom_evaluators = custom_evaluators)
- get_metrics_result(configuration: dict, metrics_result, **kwargs)[source]
Get the result of metrics which are run on the server. Used for faithfulness metric. :param configuration: The configuration of the metrics to get the response :param metrics_result: The metrics result dictionary containing the details of the computation tasks triggered. This will be output of the method ‘compute_metrics’. :return: Key/Value pair where key is the metric name and value is an object consisting of the metric results for all individual metrics.
This is how the configuration parameter dict will look like
>>> from ibm_metrics_plugin.metrics.llm.utils.constants import LLMTextMetricGroup, LLMSummarizationMetrics, HAP_SCORE metric_config = { "configuration": { LLMTextMetricGroup.RAG.value: { #This is metric group LLMSummarizationMetrics.ROUGE_SCORE.value: { #This is individual metric and contains it's specific parameters if required "use_aggregator": True, "use_stemmer": True }, LLMSummarizationMetrics.FAITHFULNESS.value: { #This is individual metric and contains it's specific parameters if required }, LLMSummarizationMetrics.ANSWER_RELEVANCE.value: {} } } } A way you might use me is: >>> metrics_result = client.llm_metrics.compute_metrics(configuration, sources, predictions, references) >>> final_result = client.llm_metrics.get_metrics_result(configuration=configuration, metrics_result=metrics_result)
APIClient.integrated_systems
- class IntegratedSystems(ai_client: WatsonOpenScaleV2Adapter)[source]
Bases:
IntegratedSystems
Manages Integrated Systems instance.
- show(limit: int | None = 10, type: str | None = None, project_id: str | None = None, space_id: str | None = None, **kwargs) None [source]
Show integrated systems. By default 10 records will be shown.
- Parameters:
limit (int) – maximal number of fetched rows. By default set to 10. (optional)
type (str) – (optional) comma-separated list of type for the integrated system.
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
A way you might use me is:
>>> client.integrated_systems.show() >>> client.integrated_systems.show(limit=20) >>> client.integrated_systems.show(limit=None)
- add(name: str, type: str, description: str, credentials: dict, connection: object = None, group_ids: List[str] = None, user_ids: List[str] = None, project_id: str = None, space_id: str = None, **kwargs) DetailedResponse [source]
Create a new integrated system.
Create a new integrated system.
- Parameters:
name (str) – The name of the Integrated System.
type (str)
description (str) – The description of the Integrated System.
credentials (dict) – The credentials for the Integrated System.
connection (object) – (optional) The additional connection information for the Integrated System.
group_ids (List[str]) – (optional) Access control list of group id of Cloud Pak for Data (Only available for open_pages type and OpenScale on Cloud Pak for Data >= 4.0.6 with ENABLE_GROUP_AUTH being true).
user_ids (List[str]) – (optional) Access control list of user id of Cloud Pak for Data (Only available for open_pages type and OpenScale on Cloud Pak for Data >= 4.0.6 with ENABLE_GROUP_AUTH being true).
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with IntegratedSystemResponse result
- get(integrated_system_id: str, project_id: str = None, space_id: str = None, **kwargs) DetailedResponse [source]
Get a specific integrated system.
Get a specific integrated system.
- Parameters:
integrated_system_id (str) – Unique integrated system ID.
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with IntegratedSystemResponse result
- update(integrated_system_id: str, json_patch_operation: List[JsonPatchOperation], project_id: str = None, space_id: str = None, **kwargs) DetailedResponse [source]
Update an integrated system.
Update an integrated system.
- Parameters:
integrated_system_id (str) – Unique integrated system ID.
json_patch_operation (List[JsonPatchOperation])
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with IntegratedSystemResponse result
- delete(integrated_system_id: str, project_id: str = None, space_id: str = None, **kwargs) DetailedResponse [source]
Delete an integrated system.
Delete an integrated system.
- Parameters:
integrated_system_id (str) – Unique integrated system ID.
headers (dict) – A dict containing the request headers
project_id (str) – Id of the Project context in which governance operation is happening (optional)
space_id (str) – Id of the Space context in which governance operation is happening (optional)
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse
- list(*, project_id: str | None = None, space_id: str | None = None, type: str | None = None, **kwargs) DetailedResponse [source]
List integrated systems.
List integrated systems.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with IntegratedSystemCollection result
APIClient.wos
- class WOS(ai_client: WatsonOpenScaleV2Adapter, service_url: str)[source]
Bases:
object
Manages Utility methods at the Watson OpenScale level.
- get_instance_mapping(project_id: str | None = None, space_id: str | None = None)[source]
Get all instance mappings specified by the parameters filtered by either of project_id or space_id
Note: This operation is applicable only for Cloud Pack for Data env
- Parameters:
- Return type:
A way you might use me is:
>>> from ibm_watson_openscale import * >>> client.wos.get_instance_mapping( project_id=project_id )
- add_instance_mapping(service_instance_id: str | None = None, project_id: str | None = None, space_id: str | None = None)[source]
Create instance mapping between OpenScale service instance and with either space or project.
Note: This operation is applicable only for Cloud Pack for Data env
- Parameters:
- Return type:
A way you might use me is:
>>> from ibm_watson_openscale import * >>> client.wos.add_instance_mapping( service_instance_id=service_instance_id, project_id=project_id )
- execute_prompt_setup(prompt_template_asset_id: str, project_id: str | None = None, space_id: str | None = None, deployment_id: str | None = None, label_column: str | None = None, operational_space_id: str | None = None, problem_type: str | None = None, classification_type: str | None = None, input_data_type: str | None = None, context_fields: List[str] | None = None, question_field: str | None = None, supporting_monitors: dict = {}, background_mode: bool = True, **kwargs) DetailedResponse [source]
Performs the setup activities in Openscale for a given prompt template asset.
- Parameters:
prompt_template_asset_id (str) – The GUID of the prompt template asset.
label_column (str) – (optional) The name of the column containing the ground truth or actual labels.
operational_space_id (str) – (optional) The rank of the environment in which the monitoring is happening. Accepted values are development, pre_production, production.
problem_type (str) – (optional) The task type to monitor for the given prompt template asset.
classification_type (str) – (optional) The classification type binary/multiclass applicable only for classification problem (task) type.
input_data_type (str) – (optional) The input data type.
context_fields (List[str]) – (optional) The list of prompt variables containing the context. Applicable only for Retrieval-Augmented Generation problem type.
question_field (str) – (optional) The prompt variable containing the question. Applicable only for Retrieval-Augmented Generation problem type.
supporting_monitors (dict) – (optional)
project_id (str) – (optional) The GUID of the project.
space_id (str) – (optional) The GUID of the space.
deployment_id (str) – (optional) The GUID of the deployment.
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PromptSetupResponse result
- get_prompt_setup(prompt_template_asset_id: str, project_id: str | None = None, space_id: str | None = None, deployment_id: str | None = None, **kwargs) DetailedResponse [source]
Gets the status of the prompt setup for the given prompt template asset.
- Parameters:
- Returns:
A DetailedResponse containing the result, headers and HTTP status code.
- Return type:
DetailedResponse with PromptSetupResponse result
Helper Classes
MetricThreshold
- class MetricThreshold(type: str, *, default: float | None = None, default_recommendation: str | None = None, specific_values: List[MetricSpecificThresholdObject] | None = None)[source]
MetricThreshold.
- Attr str type:
- Attr float default:
(optional) default value of threshold.
- Attr str default_recommendation:
(optional)
- Attr List[MetricSpecificThresholdObject] specific_values:
(optional)
Target
MonitorInstanceParameters
DatabaseConfiguration
- class DatabaseConfiguration(database_type: str, credentials: SecretCleaned, *, instance_id: str | None = None, name: str | None = None, location: LocationSchemaName | None = None)[source]
Database configuration ignored if internal database is requested (internal_database is true).
- Attr str database_type:
- Attr str instance_id:
(optional)
- Attr str name:
(optional)
- Attr SecretCleaned credentials:
- Attr LocationSchemaName location:
(optional)
AzureCredentials
- class AzureCredentials(*, token: str | None = None, username: str | None = None, password: str | None = None, subscription_id: str | None = None, client_id: str | None = None, client_secret: str | None = None, tenant: str | None = None, workspaces: List[AzureWorkspaceCredentials] | None = None, **kwargs)[source]
AzureCredentials.
- Attr str token:
(optional)
- Attr str username:
(optional)
- Attr str password:
(optional)
- Attr str subscription_id:
(optional)
- Attr str client_id:
(optional)
- Attr str client_secret:
(optional)
- Attr str tenant:
(optional)
- Attr List[AzureWorkspaceCredentials] workspaces:
(optional)
CustomCredentials
- class CustomCredentials(*, url: str | None = None, username: str | None = None, password: str | None = None, apikey: str | None = None, auth_url: str | None = None, auth_type: str | None = None, auth_provider: str | None = None, **kwargs)[source]
CustomCredentials.
- Attr str url:
(optional)
- Attr str username:
(optional)
- Attr str password:
(optional)
- Attr str apikey:
(optional)
- Attr str auth_url:
(optional)
- Attr str auth_type:
(optional)
- Attr str auth_provider:
(optional)
SageMakerCredentials
SPSSCredentials
WMLCredentialsCP4D
- class WMLCredentialsCP4D(*, url: str | None = None, apikey: str | None = None, username: str | None = None, uid: str | None = None, wml_location: str | None = None, **kwargs)[source]
WMLCredentials format for OpenScale on Cloud Pak for Data.
- Attr str url:
(optional) Required if wml_location is cpd_remote or cloud_remote.
- Attr str apikey:
(optional) Required if wml_location is cpd_remote or cloud_remote.
- Attr str username:
(optional) Required if wml_location is cpd_remote.
- Attr str uid:
(optional) User ID of a user in the Cloud Pak for Data. If not set, the uid extracted from the access token in Authorization header is used. This parameter is only applicable if wml_location is cpd_local.
- Attr str wml_location:
(optional) If wml_location is not selected, we treat the service provider as cpd_local for backward compatibility.
WMLCredentialsCloud
Asset
- class Asset(asset_id: str, asset_type: str, *, url: str | None = None, name: str | None = None, asset_rn: str | None = None, created_at: str | None = None, problem_type: str | None = None, model_type: str | None = None, runtime_environment: str | None = None, input_data_type: str | None = None)[source]
Asset.
- Attr str asset_id:
- Attr str url:
(optional)
- Attr str name:
(optional)
- Attr str asset_type:
- Attr str asset_rn:
(optional) Asset Resource Name (used for integration with 3rd party ML engines).
- Attr str created_at:
(optional)
- Attr str problem_type:
(optional)
- Attr str model_type:
(optional)
- Attr str runtime_environment:
(optional)
- Attr str input_data_type:
(optional)
AssetDeploymentRequest
- class AssetDeploymentRequest(deployment_id: str, name: str, deployment_type: str, *, deployment_rn: str | None = None, url: str | None = None, description: str | None = None, created_at: str | None = None, scoring_endpoint: ScoringEndpointRequest | None = None)[source]
AssetDeploymentRequest.
- Attr str deployment_id:
- Attr str deployment_rn:
(optional) Deployment Resource Name (used for integration with 3rd party ML engines).
- Attr str url:
(optional)
- Attr str name:
- Attr str description:
(optional)
- Attr str deployment_type:
Deployment type.
- Attr str created_at:
(optional)
- Attr ScoringEndpointRequest scoring_endpoint:
(optional) Definition of scoring endpoint in custom_machine_learning.
AssetPropertiesRequest
- class AssetPropertiesRequest(*, training_data_reference: TrainingDataReference | None = None, training_data_schema: SparkStruct | None = None, input_data_schema: SparkStruct | None = None, output_data_schema: SparkStruct | None = None, input_token_count_field: str | None = None, output_token_count_field: str | None = None, label_column: str | None = None, labels: List[str] | None = None, dashboard_configuration: dict | None = None, predicted_target_field: str | None = None, prediction_field: str | None = None, transaction_id_field: str | None = None, feature_fields: List[str] | None = None, categorical_fields: List[str] | None = None, context_fields: List[str] | None = None, question_field: str | None = None, probability_fields: List[str] | None = None, prediction_names: List[str] | None = None)[source]
Additional asset properties (subject of discovery if not provided when creating the subscription).
- Attr TrainingDataReference training_data_reference:
(optional)
- Attr SparkStruct training_data_schema:
(optional)
- Attr SparkStruct input_data_schema:
(optional)
- Attr SparkStruct output_data_schema:
(optional)
- Attr str input_token_count_field:
(optional) Field with this name will be given modeling_role input-token-count.
- Attr str output_token_count_field:
(optional) Field with this name will be given modeling_role output-token-count.
- Attr str label_column:
(optional)
- Attr List[str] labels:
(optional)
- Attr dict dashboard_configuration:
(optional)
- Attr str predicted_target_field:
(optional) Field with this name will be given modeling_role decoded-target.
- Attr str prediction_field:
(optional) Field with this name will be given modeling_role prediction.
- Attr str transaction_id_field:
(optional) Field with this name will have transaction_id_key metadata set to true.
- Attr List[str] feature_fields:
(optional) Fields to be given modeling_role feature.
- Attr List[str] categorical_fields:
(optional) Fields to be given metadata measure of value discrete.
- Attr List[str] context_fields:
(optional) Contexts fields with this name will be given prompt_role as context_field used in Retrieval-Augmented Generation.
- Attr str question_field:
(optional) Question field with this name will be given prompt_role as question_field used in Retrieval-Augmented Generation.
- Attr List[str] probability_fields:
(optional) Fields to be given modeling_role class_probability (for columns of double data type) or probability (for column of array data type).
- Attr List[str] prediction_names:
(optional) Prediction names for multiple output models.
PayloadRecord
- class PayloadRecord(request: dict, response: dict | str, scoring_id: str | None = None, scoring_timestamp: str | None = None, response_time: int | None = None, asset_revision: str | None = None, multiple_records: bool = True, user_id: str | None = None)[source]
Used during payload logging, describes payload record.
- Parameters:
request (dict) – scoring request
response (str) – scoring response
scoring_id (str) – scoring identifier (optional). If not provided random uid is assigned.
scoring_timestamp (str) – scoring request timestamp (optional). If not provided current time is assigned.
response_time – scoring response time in ms (optional)
user_id – User ID (optional)
MonitorMeasurementMetrics
PrimaryStorageCredentialsLong
- class PrimaryStorageCredentialsLong(hostname: str, username: str, password: str, db: str, *, port: int | None = None, ssl: bool | None = None, sslmode: str | None = None, certificate_base64: str | None = None, additional_properties: dict | None = None)[source]
PrimaryStorageCredentialsLong.
- Attr str hostname:
- Attr str username:
- Attr str password:
- Attr str db:
- Attr int port:
(optional)
- Attr bool ssl:
(optional)
- Attr str sslmode:
(optional) (postgresql only).
- Attr str certificate_base64:
(optional) DER-encoded certificate in Base64 encoding. The decoded content must be bound at the beginning by —–BEGIN CERTIFICATE—– and at the end by —–END CERTIFICATE—–.
- Attr dict additional_properties:
(optional) any additional properties to be included in connection url.
JsonPatchOperation
- class JsonPatchOperation(op: str, path: str, *, from_: str | None = None, value: object | None = None)[source]
This model represents an individual patch operation to be performed on a JSON document, as defined by RFC 6902.
- Attr str op:
The operation to be performed.
- Attr str path:
The JSON Pointer that identifies the field that is the target of the operation.
- Attr str fromfrom_:
(optional) The JSON Pointer that identifies the field that is the source of the operation.
- Attr object value:
(optional) The value to be used within the operation.
Enums
- class InputDataType[source]
Bases:
object
Describes possible model input data types.
Contains: [STRUCTURED, UNSTRUCTURED_IMAGE, UNSTRUCTURED_TEXT, UNSTRUCTURED_AUDIO, UNSTRUCTURED_VIDEO]
- STRUCTURED = 'structured'
- UNSTRUCTURED_IMAGE = 'unstructured_image'
- UNSTRUCTURED_TEXT = 'unstructured_text'
- UNSTRUCTURED_AUDIO = 'unstructured_audio'
- UNSTRUCTURED_VIDEO = 'unstructured_video'
- class DeploymentTypes[source]
Bases:
object
Describes possible model deployment types.
Contains: [ONLINE]
- ONLINE = 'online'
- class RecordsFormatTypes[source]
Bases:
object
Describes possible format types for getting list of records.
Contains: [DICT, LIST]
- DICT = 'dict'
- LIST = 'list'
- class FeedbackType(value)[source]
Bases:
Enum
Describes supported types of feedback format.
Contains: [WML, DICT, CSV]
- WML = 'WML'
- DICT = 'DICT'
- CSV = 'CSV'
- PAYLOAD = 'PAYLOAD'
- LIST_OF_DICT = 'LIST_OF_DICT'
- class ServiceTypes[source]
Bases:
object
Describes supported types of service.
- 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 = 'azure_machine_learning'
- CUSTOM_MACHINE_LEARNING = 'custom_machine_learning'
- SPSS_COLLABORATION_AND_DEPLOYMENT_SERVICES = 'spss_collaboration_and_deployment_services'
- AZURE_MACHINE_LEARNING_SERVICE = 'azure_machine_learning_service'
- class ResponseTypes[source]
Bases:
object
Describes supported types of output format.
Contains: [PANDAS, PYTHON]
- PANDAS = 'pandas'
- PYTHON = 'python'
- class TargetTypes[source]
Bases:
object
Describes supported types of target format.
Contains: [SUBSCRIPTION, BUSINESS_APPLICATION, INSTANCE, DATA_MART]
- SUBSCRIPTION = 'subscription'
- BUSINESS_APPLICATION = 'business_application'
- INSTANCE = 'instance'
- DATA_MART = 'data_mart'
- PROJECT = 'project'
- SPACE = 'space'
- class FormatTypes[source]
Bases:
object
Format of the returned data. full format compared to compact is additive and contains sources part.
- COMPACT = 'compact'
- FULL = 'full'
- class IntervalTypes[source]
Bases:
object
Time unit in which metrics are grouped and aggregated, interval by interval.
- MINUTE = 'minute'
- HOUR = 'hour'
- DAY = 'day'
- WEEK = 'week'
- MONTH = 'month'
- YEAR = 'year'
- class AggregationTypes[source]
Bases:
object
Comma delimited function list constructed from metric name and function, e.g. agg=metric_name:count,:last that defines aggregations.
- LAST = 'last'
- FIRST = 'first'
- MAX = 'max'
- MIN = 'min'
- SUM = 'sum'
- AVG = 'avg'
- COUNT = 'count'
- STDDEV = 'stddev'
- class OnErrorTypes[source]
Bases:
object
expected behaviour on error.
- STOP = 'stop'
- CONTINUE = 'continue'
- class ContentTypes[source]
Bases:
object
The type of the input. A character encoding can be specified by including a charset parameter. For example, ‘text/csv;charset=utf-8’.
- APPLICATION_JSON = 'application/json'
- TEXT_CSV = 'text/csv'
- class DataSetTypes[source]
Bases:
object
type of the data set.
- MANUAL_LABELING = 'manual_labeling'
- PAYLOAD_LOGGING = 'payload_logging'
- FEEDBACK = 'feedback'
- BUSINESS_PAYLOAD = 'business_payload'
- CUSTOM = 'custom'
- class MetricThresholdTypes[source]
Bases:
object
- LOWER_LIMIT = 'lower_limit'
- UPPER_LIMIT = 'upper_limit'
- class StatusStateType[source]
Bases:
object
- ACTIVE = 'active'
- RUNNING = 'running'
- FINISHED = 'finished'
- PREPARING = 'preparing'
- SUCCESS = 'success'
- COMPLETED = 'completed'
- FAILURE = 'failure'
- FAILED = 'failed'
- ERROR = 'error'
- CANCELLED = 'cancelled'
- CANCELED = 'canceled'
- UPLOAD_ERROR = 'upload_error'
- class DatabaseType[source]
Bases:
object
Describes possible options of choosing database type.
Contains: [POSTGRESQL, DB2]
- POSTGRESQL = 'postgresql'
- DB2 = 'db2'
- class Choose[source]
Bases:
object
Describes possible options of choosing result from table filtering when only one result is required.
Contains: [FIRST, LAST, RANDOM]
- FIRST = 'first'
- LAST = 'last'
- RANDOM = 'random'
- class ProblemType[source]
Bases:
object
Describes possible model (problem) types.
Contains: [regression, binary, multiclass]
- REGRESSION = 'regression'
- BINARY_CLASSIFICATION = 'binary'
- MULTICLASS_CLASSIFICATION = 'multiclass'
- class ExpectedDirectionTypes[source]
Bases:
object
the indicator specifying the expected direction of the monotonic metric values.
- INCREASING = 'increasing'
- DECREASING = 'decreasing'
- UNKNOWN = 'unknown'
- class IntegratedSystemTypes[source]
Bases:
object
- OPEN_PAGES = 'open_pages'
- WATSON_DATA_CATALOG = 'watson_data_catalog'
- SLACK = 'slack'