Looker Connect Training
Help Center
Documentation
Community
Cloud Certifications
Oh, there’s a line missing. You need to have this import statement at the top of your Python script: import looker_client_30 as looker_client That will define the looker_client for later. I’ll update the article to include this.
Thanks Tim, I’ll add all that detail to the internal ticket. Filter expressions are strings, but we would like to be forgiving to predictable issues like submitting a filter as an integer when that is the intended logic. Very useful input on the cases you’ve identified where values are not accepted as strings. We are looking at developing official clients for more languages, although I’m afraid there’s no formal commitments to share at the moment.
The only changes I’ve had to make are the ones discussed so far: handling binary downloads, and sanitising the vis_config input. And you can avoid the first change by using the _preload_content parameter to flag binary files, like at the end of this post: Using the Looker API to generate PDFs e.g. results = renderTask.render_task_results(task_id, _preload_content = False) Using that approach might be a good way to check no bugs have been introduced via your patches. You can then test the API calls just by modifying the vis_config dictionary.
For GitHub, I’m referring to the pip install instructions under step 1 in the article – but it sounds like you’ve caught and resolved the same issue for binary files in your own SDK code from swagger. For the vis_config, I tried just re-using the unmodified vis_config section and you’re right, there are some bugs to work out. I’ve chatted to our engineers and we’re taking a closer look. Below is the simple example I used similar to the screencaps in the article. You can see it doesn’t necessarily need much to replicate your Look. { 'type': 'looker_column', 'colors': ['palette: Looker Classic'], 'series_colors': {}, 'series_types': '', 'show_dropoff': True, 'show_view_names': False, 'totals_color': '#808080', } This Discourse provides some good examples (based on including vis_config settings in a LookML model): More Powerful Data Drilling
To modify the query in a Look, you need to use the Query API rather than the Look API. There’s an article on that here: Can you apply a filter to a pre-defined look via API3? The basic steps are: Get the query definition via the Look API Edit the filters as necessary Run the updated query via the Query API Getting the query: look = lookApi.look(770, fields='query') look_query = look.to_dict()['query'] If you just look at the filter values, you’ll see something like this: {'view_name.yesno_dimension_name': 'Yes', 'view_name.date_dimension_name_': '2 years'} The full query dictionary contains some read-only values, so you’ll need to update a few values. Here’s an example: look_query_dict.pop('client_id') look_query_dict['vis_config'] = { 'type': 'looker_column', 'colors': "['palette: Looker Classic']", # 'series_colors': '{}', 'series_types': '', 'show_dropoff': 'True', 'show_view_names': 'False', # 'totals_color': '#808080', } look_query_dict['filters']
Already have an account? Login
No account yet? Create an account
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.