looker-open-source / henry

A command line tool for Looker instance cleanup
MIT License
79 stars 27 forks source link

An error occurs only in some commands #31

Open cavernaria opened 3 years ago

cavernaria commented 3 years ago

Only some commands give me an error. How can I get rid of this error?

Environment

Successful commands

Error command

Other than the above

Error Message

Any command can be shared and the following error occurs (also on a Mac).

/Traceback (most recent call last):
  File "c:\python37\lib\site-packages\henry\modules\fetcher.py", line 153, in get_explores
    for e in m.explores
  File "c:\python37\lib\site-packages\henry\modules\fetcher.py", line 153, in <listcomp>
    for e in m.explores
  File "c:\python37\lib\site-packages\looker_sdk\sdk\methods.py", line 3306, in lookml_model_explore
    transport_options=transport_options,
  File "c:\python37\lib\site-packages\looker_sdk\rtl\api_methods.py", line 134, in get
    return self._return(response, structure)
  File "c:\python37\lib\site-packages\looker_sdk\rtl\api_methods.py", line 78, in _return
    raise error.SDKError(response.value.decode(encoding=encoding))
looker_sdk.error.SDKError: {"message":"Not found","documentation_url":"http://docs.looker.com/"}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\Scripts\henry.exe\__main__.py", line 9, in <module>
  File "c:\python37\lib\site-packages\henry\cli.py", line 18, in main
    analyze.Analyze.run(user_input)
  File "c:\python37\lib\site-packages\henry\commands\analyze.py", line 14, in run
    result = analyze.models(project=user_input.project, model=user_input.model)
  File "c:\python37\lib\contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "c:\python37\lib\site-packages\henry\commands\analyze.py", line 67, in models
    "# Unused Explores": len(self.get_unused_explores(model=m.name)),
  File "c:\python37\lib\site-packages\henry\modules\fetcher.py", line 194, in get_unused_explores
    _all = self.get_explores(model=model)
  File "c:\python37\lib\site-packages\henry\modules\fetcher.py", line 158, in get_explores
    "An error occured while getting models/explores."
henry.modules.exceptions.NotFoundError: An error occured while getting models/explores.
bryan-at-looker commented 3 years ago

I ran into this fixing a different issue. One culprit was the system__activity model, but there are other cases too I wasn't able to track down.

Here's a consistent failure of this nature: henry analyze explores --model system__activity --config-file ../looker.ini

In this case we're failing here on explores = [self.sdk.lookml_model_explore(model, explore)] here

emilywilson2 commented 3 years ago

I'm also getting the same errors on all commands except pulse and analyze projects

Python 3.7.0 henry 0.2.2
looker-sdk 0.1.3b7

nishiogawakun commented 3 years ago

Same set up, same errors as above.

TiagoCruz1989 commented 3 years ago

Same here. If i use the name of some models as a parameter it works. If not i get the same errors.

jcarah commented 3 years ago

There is some unknown condition under which Looker's API will return explores in the call to the /models/ endpoint, but those explores can't be found when you make a call the /models/explores endpoint.

Henry makes these call successively, in fetcher.py. On line 157, I updated the except block to simply ignore these mismatches.

except error.SDKError:
    # raise exceptions.NotFoundError(
    #     "An error occured while getting models/explores."
    # )
    print("Could not find explore...skipping.")

@josephaxisa I wonder if you have any idea what's going on and whether you think this is an acceptable workaround. I can make a PR if so.