Attempting update_look in Python SDK, assertion err. I must have my syntax wrong

twoshay
Participant I

Among our users, we’ve got lots of trouble with dashboards and looks running big queries upon load - so I’ve been tasked with turning it off on existing objects. Using the python looker_sdk, I am able to scan through and see that setting on all existing looks. I haven’t been able to update a test Look to turn if off, though - I get an err at line 8130 of methods.py: “assert isinstance(body, models.WriteLookWithQuery)”

My test app as it stands now:

import looker_sdk

sdk = looker_sdk.init40("./looker.ini")

for thislook in sdk.all_looks("id,title,is_run_on_load"):
    print(thislook.title,thislook.is_run_on_load)
    if thislook.title == "TestingROL":
        setrol = {"is_run_on_load":False}
        updlook = sdk.update_look(thislook.id, setrol)

I’ve tried a few dozen varieties of syntax based on samples and other folks’ resolved issues, but have not landed on the right way to do this. Could someone tell me what I’m missing?

0 1 112
1 REPLY 1

twoshay
Participant I

This has been resolved. I tried a few more variations - including doing the ‘assert’ in my code to confirm the data type was what was expected. Finally I switched back to client31 instead of client40, and it worked. It’s hard to say what variations I’d tried would have worked under 31 - all my tests before were on 40. But… for reference, here’s working code to disable run-on-load for all saved looks. Next step, I add dashboards.

import sys
import looker_sdk
from looker_sdk import models

sdk = looker_sdk.init31("./looker.ini")
setrol =  models.WriteLookWithQuery(is_run_on_load=False)
for thislook in sdk.all_looks("id,title,is_run_on_load"):
    if thislook.is_run_on_load:
        print("Updating: ",thislook.title)
        updlook = sdk.update_look(thislook.id,body=setrol)