Skip to main content

CLI library to automate the onboarding process to IBM Watson OpenScale

Project description

Status Latest Stable Version

IBM Watson Openscale “fastpath” configuration tool. This tool allows the user to get started quickly with Watson OpenScale. * If needed, provision a Lite plan instance for IBM Watson OpenScale * If needed, provision a Lite plan instance for IBM Watson Machine Learning * Drop and re-create the IBM Watson OpenScale datamart instance and datamart database schema * Optionally, deploy a sample machine learning model to the WML instance * Configure the sample model instance to OpenScale, including payload logging, fairness checking, feedback, quality checking, and explainability * Optionally, store up to 7 days of historical payload, fairness, and quality data for the sample model

Before you begin

Installation

To install, use pip or easy_install:

pip install -U ibm-ai-openscale-cli

or

easy_install -U ibm-ai-openscale-cli

Usage

ibm-ai-openscale-cli --help
usage:    [-h] -a APIKEY [--env {ypprod,ypqa,ys1dev,icp}]
          [--resource-group RESOURCE_GROUP] [--postgres POSTGRES]
          [--postgres-json POSTGRES_JSON] [--icd ICD] [--icd-json ICD_JSON]
          [--db2 DB2] [--db2-json DB2_JSON] [--wml WML] [--wml-json WML_JSON]
          [--azure AZURE] [--azure-json AZURE_JSON] [--spss SPSS]
          [--spss-json SPSS_JSON] [--custom CUSTOM]
          [--custom-json CUSTOM_JSON] [--aws AWS] [--aws-json AWS_JSON]
          [--deployment-name DEPLOYMENT_NAME] [--username USERNAME]
          [--password PASSWORD] [--url URL] [--datamart-name DATAMART_NAME]
          [--keep-schema] [--history HISTORY] [--verbose] [--version]
          [--model {all,GermanCreditRiskModel,DrugSelectionModel,GolfModel}]
          [--reset {metrics,monitors,datamart,model}]

IBM Watson Openscale "fastpath" configuration tool. This tool allows the user
to get started quickly with Watson OpenScale: 1) If needed, provision a Lite
plan instance for IBM Watson OpenScale 2) If needed, provision a Lite plan
instance for IBM Watson Machine Learning 3) Drop and re-create the IBM Watson
OpenScale datamart instance and datamart database schema 4) Optionally, deploy
a sample machine learning model to the WML instance 5) Configure the sample
model instance to OpenScale, including payload logging, fairness checking,
feedback, quality checking, and explainability 6) Optionally, store up to 7
days of historical payload, fairness, and quality data for the sample model

optional arguments:
  -h, --help            show this help message and exit
  --env {ypprod,ypqa,ys1dev,icp}
                        Environment. Default "ypprod"
  --resource-group RESOURCE_GROUP
                        Resource Group to use. If not specified, then
                        "default" group is used
  --postgres POSTGRES   Path to postgres credentials file for the datamart
                        database. If --postgres, --icd, and --db2 all are not
                        specified, then the internal Watson OpenScale database
                        is used
  --postgres-json POSTGRES_JSON
                        Postgres credentials in JSON format
  --icd ICD             Path to IBM Cloud Database credentials file for the
                        datamart database
  --icd-json ICD_JSON   IBM Cloud Database credentials for the datamart
                        database in JSON format
  --db2 DB2             Path to IBM DB2 credentials file for the datamart
                        database
  --db2-json DB2_JSON   IBM DB2 credentials for the datamart database in JSON
                        format: '{ "username": "<USERNAME>", "password":
                        "<PASSWORD>", "hostname": "<hostname>", "port":
                        "<port>", "db": "<db>" }'
  --wml WML             Path to IBM WML credentials file
  --wml-json WML_JSON   IBM WML credentials in JSON format
  --azure AZURE         Path to Microsoft Azure credentials file
  --azure-json AZURE_JSON
                        Microsoft Azure credentials in JSON format: '{
                        "client_id": "<CLIENT_ID", "client_secret":
                        "<CLIENT_SECRET", "tenant": "<TENANT>",
                        "subscription_id": "<SUBSCRIPTION_ID" }'
  --spss SPSS           Path to SPSS credentials file
  --spss-json SPSS_JSON
                        SPSS credentials in JSON format: '{ "username":
                        "<USERNAME>", "password": "<PASSWORD", "url": "<URL>"
                        }'
  --custom CUSTOM       Path to Custom Engine credentials file
  --custom-json CUSTOM_JSON
                        Custom Engine credentials in JSON format: '{ "url":
                        "<URL>" }'
  --aws AWS             Path to Amazon Web Services credentials file
  --aws-json AWS_JSON   Amazon Web Services credentials in JSON format: '{
                        "access_key_id": "<ACCESS_KEY_ID",
                        "secret_access_key": "<SECRET_ACCESS_KEY", "region":
                        "<REGION>" }'
  --deployment-name DEPLOYMENT_NAME
                        Name of the existing deployment to use. Required for
                        Azure ML Studio, SPSS Engine and Custom ML Engine.
                        Optional for Watson Machine Learning
  --username USERNAME   ICP username. Required if "icp" environment is chosen
  --password PASSWORD   ICP password. Required if "icp" environment is chosen
  --url URL             ICP url. Required if "icp" environment is chosen
  --datamart-name DATAMART_NAME
                        Specify data mart name and database schema, default is
                        "aiosfastpath"
  --keep-schema         Use pre-existing datamart schema, only dropping all
                        tables. If not specified, datamart schema is dropped
                        and re-created
  --history HISTORY     Days of history to preload. Default is 7
  --verbose             verbose flag
  --version             show program's version number and exit
  --model {all,GermanCreditRiskModel,DrugSelectionModel,GolfModel}
                        Model to set up with Watson OpenScale (default
                        "GermanCreditRiskModel")
  --reset {metrics,monitors,datamart,model}
                        Reset existing datamart then exit

required arguments:
  -a APIKEY, --apikey APIKEY
                        IBM Cloud platform user APIKey. If "--env icp" is also
                        specified, APIKey value is not used.

Examples

In this example, if a WML instance already exists it is used, but if not a new Lite plan instance is provisioned and used. If an OpenScale instance exists, its datamart is dropped and recreated along with its datamart internal database schema. Otherwise, a Lite plan OpenScale instance is provisioned. The GermanCreditRiskModel is stored and deployed in WML, configured to OpenScale, and 7 days’ historical data stored.

export APIKEY=<PLATFORM_API_KEY>
ibm-ai-openscale-cli --apikey $APIKEY

In this example, assume the user already has provisioned instances of WML, OpenScale, IBM Cloud Database for Postgres (ICD), and has selected a schema for the OpenScale datamart database. The OpenScale datamart is dropped and recreated, and the datamart’s database schema is dropped and recreated. An already-deployed instance of the DrugSelectionModel is configured to OpenScale, and 7 days’ historical data stored.

export APIKEY=<PLATFORM_API_KEY>
export WML=<WML instance credentials JSON file>
export ICD=<ICD instance credentials JSON file>
export SCHEMA=<ICD database schema>
ibm-ai-openscale-cli --apikey $APIKEY --wml $WML --model DrugSelectionModel --deployment-name DrugSelectionModelDeployment --icd $ICD --datamart-name $SCHEMA

In this example, assume the user already has provisioned an Entry plan instance of IBM DB2 Warehouse on Cloud. The OpenScale datamart’s tables within the user’s existing DB2 schema are dropped and recreated. The GermanCreditRiskModel is stored and deployed in WML, configured to OpenScale, and 7 days’ historical data stored.

export APIKEY=<PLATFORM_API_KEY>
export DB2=<DB2 instance credentials JSON file>
export SCHEMA=<user's DB2 database schema>
ibm-ai-openscale-cli --apikey $APIKEY --db2 $DB2 --datamart-name $SCHEMA --keep-schema

FAQ

Q: How do the reset options work?

A: The reset options each affect a different level of data in the datamart:

  • --reset metrics : Clean up the payload logging table, monitoring history tables etc, so that it restores the system to a fresh state with datamart configured, model deployments added, all monitors configured, but no actual metrics in the system yet. The system is ready to go. Not supported for Watson OpenScale internal databases.

  • --reset monitors : Remove all configured monitors and corresponding metrics and history, but leave the actual model deployments (if any) in the datamart. User can proceed to configure the monitors via user interface, API, or fastpath.

  • -- reset datamart : “Factory reset” the datamart to a fresh state as if there was not any configuration.

  • -- reset model : Delete the model and deployment from WML. Not yet supported for non-WML engines. Does not affect the datamart.

Q: Can I use SSL for connecting to the datamart DB2 database?

A: Yes. DB2 Warehouse on Cloud databases automatically support SSL, using the VCAP json file generated on the “Service Credentials” page. For on-prem or ICP4D DB2 databases, you can specify the path on the local client machine to a copy of the DB2 server’s SSL certificate “arm” file, using an “ssldsn” connection string in the VCAP json file:

{
  "hostname": "<ipaddr>",
  "host": "<ipaddr>",
  "username": "<uid>",
  "password": "<pw>",
  "port": 50000,
  "jdbcurl": "jdbc:db2://<ipaddr>:50000/<dbname>",
  "uri": "db2://<uid>:<pw>@<ipaddr>:50000/<dbname>",
  "db": "<dbname>",
  "dsn": "DATABASE=<dbname>;HOSTNAME=<ipaddr>;PORT=50000;PROTOCOL=TCPIP;UID=<uid>;PWD=<pw>",
  "ssldsn": "DATABASE=<dbname>;HOSTNAME=<ipaddr>;PORT=50001;PROTOCOL=TCPIP;UID=<uid>;PWD=<pw>;Security=ssl;SSLServerCertificate=/path_on_local_client_machine_to/db2server_instance.arm;"
}

If SSL connections are not needed, or not configured on the DB2 server, you can remove the “ssldsn” tag and ibm-ai-openscale-cli will use the non-SSL “dsn” tag instead. If the VCAP has both dsn and ssldsn tags, ibm-ai-openscale-cli will use “ssldsn” tag to create an SSL connection.

Python version

✅ Tested on Python 3.4, 3.5, 3.6, and 3.7.

Contributing

See CONTRIBUTING.md.

License

This library is licensed under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ibm-ai-openscale-cli-0.2.5.tar.gz (9.3 MB view hashes)

Uploaded Source

Built Distribution

ibm_ai_openscale_cli-0.2.5-py3-none-any.whl (11.7 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page