IBM Watson Data & AI - Structured Ideas

This Ideas portal is being closed.  Please enter new idea at http://ibm.biz/IBMAnalyticsIdeasPortal

Use connected data Looks from Looker Catalog connector as dataframes in Watson studio notebooks

Today Looks can be created as connected data assets in Watson Studio. They are created by using the third party Looker connector and work similar to a connected database table.

Using the Looker API, a user can insert a Look as a data frame in Watson Studio Notebooks.

You can use the following notebook API code to understand the Looker API, how to establish a connection, and how to return a look result:

 

class LookerAPI(object):
"""Class to contain methods and variables related to looker API authentication and Requests
"""
def __init__(self, api_endpoint, client_id, client_secret, login_url):
self.api_endpoint = api_endpoint
self.client_secret = client_secret
self.client_id = client_id
self.login_endpoint = login_url
# print(self.login_endpoint)

def login(self):
"""login to looker API"""
try:
auth_data = {'client_id':self.client_id, 'client_secret':self.client_secret}
r = requests.post( self.login_endpoint,data=auth_data) # error handle here
json_auth = json.loads(r.text)['access_token']
return json_auth
except requests.exceptions.RequestException as e:
logger.error(e)

def run_look(self, look_id, json_auth,return_format='csv'):
"""run look and return as csv, need to add more formats here"""
try:
look_run_url = self.api_endpoint + '/looks/{0}/run/{1}'.format(look_id,return_format)
r = requests.get(look_run_url + '?' + 'access_token=' + json_auth)
return r.text
except requests.exceptions.RequestException as e:
logger.error(e)

  • Guest
  • Dec 14 2018
  • Needs review
Customer Name
Role Summary Data Scientist
  • Attach files