Skip to content

Commit

Permalink
Update Watson Machine Learning auth with IAM (#1737)
Browse files Browse the repository at this point in the history
* update watson auth with IAM

* remove username/password reference
  • Loading branch information
Tomcli authored and k8s-ci-robot committed Aug 8, 2019
1 parent 8b5ac7e commit 79b58d7
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def get_secret_creds(path):
DEPLOYMENT_NAME = args.deployment_name

wml_url = get_secret_creds("/app/secrets/wml_url")
wml_username = get_secret_creds("/app/secrets/wml_username")
wml_password = get_secret_creds("/app/secrets/wml_password")
wml_instance_id = get_secret_creds("/app/secrets/wml_instance_id")
wml_apikey = get_secret_creds("/app/secrets/wml_apikey")
cos_endpoint = get_secret_creds("/app/secrets/cos_endpoint")
cos_access_key = get_secret_creds("/app/secrets/cos_access_key")
cos_secret_key = get_secret_creds("/app/secrets/cos_secret_key")
Expand All @@ -50,9 +49,8 @@ def get_secret_creds(path):

WML_CREDENTIALS = {
"url": wml_url,
"username": wml_username,
"password": wml_password,
"instance_id": wml_instance_id
"instance_id": wml_instance_id,
"apikey": wml_apikey
}
''' Load Spark model '''
cos = Minio(cos_endpoint,
Expand Down
8 changes: 3 additions & 5 deletions components/ibm-components/watson/deploy/src/wml-deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ def deploy(args):

# retrieve credentials
wml_url = getSecret("/app/secrets/wml_url")
wml_username = getSecret("/app/secrets/wml_username")
wml_password = getSecret("/app/secrets/wml_password")
wml_instance_id = getSecret("/app/secrets/wml_instance_id")
wml_apikey = getSecret("/app/secrets/wml_apikey")

# set up the WML client
wml_credentials = {
"url": wml_url,
"username": wml_username,
"password": wml_password,
"instance_id": wml_instance_id
"instance_id": wml_instance_id,
"apikey": wml_apikey
}
client = WatsonMachineLearningAPIClient(wml_credentials)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def get_secret_creds(path):
problem_type = args.problem_type

wml_url = get_secret_creds("/app/secrets/wml_url")
wml_username = get_secret_creds("/app/secrets/wml_username")
wml_password = get_secret_creds("/app/secrets/wml_password")
wml_instance_id = get_secret_creds("/app/secrets/wml_instance_id")
wml_apikey = get_secret_creds("/app/secrets/wml_apikey")
aios_guid = get_secret_creds("/app/secrets/aios_guid")
Expand All @@ -52,8 +50,6 @@ def get_secret_creds(path):

WML_CREDENTIALS = {
"url": wml_url,
"username": wml_username,
"password": wml_password,
"instance_id": wml_instance_id,
"apikey": wml_apikey
}
Expand Down
14 changes: 6 additions & 8 deletions components/ibm-components/watson/store/src/wml-store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# define the function to store the model

def getSecret(secret):
Expand All @@ -23,19 +23,17 @@ def store(wml_model_name, run_uid):

# retrieve credentials
wml_url = getSecret("/app/secrets/wml_url")
wml_username = getSecret("/app/secrets/wml_username")
wml_password = getSecret("/app/secrets/wml_password")
wml_instance_id = getSecret("/app/secrets/wml_instance_id")

wml_apikey = getSecret("/app/secrets/wml_apikey")

# set up the WML client
wml_credentials = {
"url": wml_url,
"username": wml_username,
"password": wml_password,
"instance_id": wml_instance_id
"instance_id": wml_instance_id,
"apikey": wml_apikey
}
client = WatsonMachineLearningAPIClient( wml_credentials )

# store the model
stored_model_name = wml_model_name
stored_model_details = client.repository.store_model( run_uid, stored_model_name )
Expand Down
8 changes: 3 additions & 5 deletions components/ibm-components/watson/train/src/wml-train.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def train(args):

# retrieve credentials
wml_url = getSecret("/app/secrets/wml_url")
wml_username = getSecret("/app/secrets/wml_username")
wml_password = getSecret("/app/secrets/wml_password")
wml_apikey = getSecret("/app/secrets/wml_apikey")
wml_instance_id = getSecret("/app/secrets/wml_instance_id")

wml_data_source_type = getSecret("/app/secrets/wml_data_source_type")
Expand Down Expand Up @@ -66,9 +65,8 @@ def train(args):
# set up the WML client
wml_credentials = {
"url": wml_url,
"username": wml_username,
"password": wml_password,
"instance_id": wml_instance_id
"instance_id": wml_instance_id,
"apikey": wml_apikey
}
client = WatsonMachineLearningAPIClient( wml_credentials )

Expand Down
2 changes: 1 addition & 1 deletion samples/contrib/ibm-samples/openscale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To provision your own OpenScale, Spark, Watson Machine Learning services and clo

To create a Watson Machine Learning service, go to [IBM Cloud](https://cloud.ibm.com/), login with IBM account id first. From the `Catalog` page, click on `AI` tab on the left side to go to this [page](https://cloud.ibm.com/catalog?category=ai). Then click on the [`Machine Learning`](https://cloud.ibm.com/catalog/services/machine-learning) link and follow the instructions to create the service.

Once the service is created, from the service's `Dashboard`, follow the instructions to generate `service credentials`. Refer to IBM Cloud [documents](https://cloud.ibm.com/docs) for help if needed. Collect the `url`, `username`, `password`, `apikey`, and `instance_id` info from the service credentials as these will be required to access the service.
Once the service is created, from the service's `Dashboard`, follow the instructions to generate `service credentials`. Refer to IBM Cloud [documents](https://cloud.ibm.com/docs) for help if needed. Collect the `url`, `apikey`, and `instance_id` info from the service credentials as these will be required to access the service.

2. IBM Watson OpenScale service instance

Expand Down
2 changes: 0 additions & 2 deletions samples/contrib/ibm-samples/openscale/credentials/creds.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ cos_access_key = ObjectStoreAccessKeyID
cos_secret_key = ObjectStoreSecretAccessKey

wml_url = https://us-south.ml.cloud.ibm.com
wml_username = WMLUserName
wml_password = WMLPassword
wml_instance_id = WMLInstanceId
wml_apikey = WMLAPIKey
2 changes: 1 addition & 1 deletion samples/contrib/ibm-samples/watson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To provision your own Watson Machine Learning services and cloud object store, f

To create a machine learning service, go to [IBM Cloud](https://console.bluemix.net), login with IBM account id first. From the `Catalog` page, click on `AI` tab on the left side to go to this [page](https://console.bluemix.net/catalog/?category=ai). Then click on the [`Machine Learning`](https://console.bluemix.net/catalog/services/machine-learning) link and follow the instructions to create the service.

Once the service is created, from service's `Dashboard`, follow the instruction to generate `service credentials`. Refer to IBM Cloud [documents](https://console.bluemix.net/docs/) for help if needed. Collect the `url`, `username`, `password` and `instance_id` info from the service credentials as these will be required to access the service.
Once the service is created, from service's `Dashboard`, follow the instruction to generate `service credentials`. Refer to IBM Cloud [documents](https://console.bluemix.net/docs/) for help if needed. Collect the `url`, `apikey`, and `instance_id` info from the service credentials as these will be required to access the service.

* A cloud object store

Expand Down
3 changes: 1 addition & 2 deletions samples/contrib/ibm-samples/watson/credentials/creds.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[CREDENTIALS]
wml_url=https://us-south.ml.cloud.ibm.com
wml_username=WMLUserName
wml_password=WMLPassword
wml_instance_id=WMLInstanceId
wml_apikey=WMLAPIKey

wml_data_source_type=s3

Expand Down

0 comments on commit 79b58d7

Please sign in to comment.