looker-open-source / henry

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

cannot import name 'models' from 'looker_sdk' #82

Open FranSimoneTK opened 4 months ago

FranSimoneTK commented 4 months ago

Hello!! Can you please help me with this error: after installing and running henry --help I get the following: Traceback (most recent call last): File "/Users/francisco.simone/Documents/henry/henry/bin/henry", line 5, in <module> from henry.cli import main File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/cli.py", line 7, in <module> from henry.commands import analyze, pulse, vacuum File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/commands/pulse.py", line 5, in <module> from looker_sdk import models ImportError: cannot import name 'models' from 'looker_sdk' (/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/__init__.py) If I move the models.py to the root folder I'm able to 'run' henry but I get different errors: Traceback (most recent call last): File "/Users/francisco.simone/Documents/henry/henry/bin/henry", line 8, in <module> sys.exit(main()) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/cli.py", line 20, in main vacuum.Vacuum.run(user_input) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/commands/vacuum.py", line 14, in run result = vacuum.explores(model=user_input.model, explore=user_input.explore) File "/Users/francisco.simone/.pyenv/versions/3.7.17/lib/python3.7/contextlib.py", line 74, in inner return func(*args, **kwds) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/commands/vacuum.py", line 46, in explores field_stats = self.get_explore_field_stats(e) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/modules/fetcher.py", line 288, in get_explore_field_stats model=explore.model_name, explore=explore.name File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/modules/fetcher.py", line 244, in get_used_explore_fields limit="5000", File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/sdk/api40/methods.py", line 9240, in run_inline_query transport_options=transport_options, File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/rtl/api_methods.py", line 180, in post return self._return(response, structure) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/rtl/api_methods.py", line 93, in _return raise sdk_error looker_sdk.error.SDKError Thanks!

tottipensotti commented 3 months ago

Hi all! I'm also getting the error mentioned above, but it also mention if wanted to use 'models40' instead of 'models'. Just in case it helps to close this issue ImportError: cannot import name 'models' from 'looker_sdk' (/Users/totti/code/personal_dump/henry/env/lib/python3.12/site-packages/looker_sdk/__init__.py). Did you mean: 'models40'?

gwilson253 commented 2 months ago

I believe the root cause is the import method in henry/commands/pulse.py here. Looking at the looker-sdk API code, there isn't a methods module that can be directly imported from the looker-sdk package. Rather, this ought to be from looker_sdk.sdk.api40 import methods, as is used in the henry/commands/analyze.py module here.

I fixed this locally and the error resolved... only to uncover a different error on Test 2:

...
looker_sdk.error.SDKError: 
    message:           Must query at least one dimension or measure
...

😞

Also, if there is any guidance on how to set up and run the unit tests I would be more than happy to contribute to this project.

gwilson253 commented 2 months ago

Note - this is fixed in PR https://github.com/looker-open-source/henry/pull/57

rbob86 commented 2 months ago

Created a PR with all current fixes @ https://github.com/looker-open-source/henry/pull/85