Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'feast.ui_server' is not a package #4241

Closed
mascai opened this issue May 30, 2024 · 12 comments · Fixed by #4248
Closed

'feast.ui_server' is not a package #4241

mascai opened this issue May 30, 2024 · 12 comments · Fixed by #4248

Comments

@mascai
Copy link

mascai commented May 30, 2024

Expected Behavior

feast ui command is starting without errors

Current Behavior

feast ui --host 127.0.0.1 --port 8889
/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/feast/ui_server.py:45: DeprecationWarning: 
        on_event is deprecated, use lifespan event handlers instead.

        Read more about it in the
        [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
        
  @app.on_event("shutdown")
/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/fastapi/applications.py:4495: DeprecationWarning: 
        on_event is deprecated, use lifespan event handlers instead.

        Read more about it in the
        [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
        
  return self.router.on_event(event_type)
Traceback (most recent call last):
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/bin/feast", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/feast/cli.py", line 172, in ui
    store.serve_ui(
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/feast/feature_store.py", line 2494, in serve_ui
    ui_server.start_server(
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/feast/ui_server.py", line 105, in start_server
    app = get_app(
          ^^^^^^^^
  File "/Users/aamoskalenko/0_root_folder/02_dev/35_feast_ui/venv/lib/python3.11/site-packages/feast/ui_server.py", line 54, in get_app
    ui_dir_ref = importlib_resources.files(__name__) / "ui/build/"
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/resources/_common.py", line 22, in files
    return from_package(get_package(package))
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/resources/_common.py", line 55, in get_package
    raise TypeError(f'{package!r} is not a package')
TypeError: 'feast.ui_server' is not a package

Steps to reproduce

pip install feast==0.38.0
feast init test_ui # created a project
cd test_ui/feature_repo
feast apply -- OK
feast serve -p 8008 # started feast server 127.0.0.1:8008 -- OK

#in the same folder
feast ui --host 127.0.0.1 --port 8009 # I was trying different ports 8008, 8888 etc -- ERROR

Specifications

  • Version: feast==0.38.0 , python3.11
  • Platform: MacOs
  • Subsystem:

Possible Solution

@privatedumbo
Copy link
Contributor

This happened to me to. The problem is related to importlib_resources.

Problem: this does not work with importlib.resources
Solution: install importlib-resources

To validate this, you can run and it should work. I can PR:

from unittest import mock
import importlib_resources


with mock.patch("feast.ui_server.importlib_resources", new=importlib_resources):
        store = FeatureStore()
        store.serve_ui(
            host=host,
            port=port,
            get_registry_dump=registry_dump,
            registry_ttl_sec=registry_ttl_sec,
            root_path=root_path,
        )

@shuchu
Copy link
Collaborator

shuchu commented May 31, 2024

The importlib of Python involves many changes and deprecations in newer Python versions. I would prefer to modify the code and catch the latest changes in importlib.resources

@privatedumbo
Copy link
Contributor

So you suggest fixing this using the built-in one, instead of installing importlib-resources?

@tokoko
Copy link
Collaborator

tokoko commented May 31, 2024

I think I broke this, sorry about that :). changing importlib_resources.files(__name__) with importlib_resources.files('feast') should be a fix if I'm not mistaken. I was for some reason still not able to start the ui server with the change applied, but it seemed to fix the is not a package error. If anyone can verify it, would be a great help...

@privatedumbo
Copy link
Contributor

v0.38.0
v0.37.1

For what I see, the difference is using the builtin vs the library. Not the package name

@tokoko
Copy link
Collaborator

tokoko commented May 31, 2024

Yes, I made the change in #4109. The difference apparently is that files method in library expects anchor file path as a first parameter, while the same method in built-in expects a package name. I thought there were supposed to be drop-in replacements and missed that...

@privatedumbo
Copy link
Contributor

Yes, should be TBH. I can PR this tomorrow if it helps.
Option A) we re-install the lib
Option B) we fix it using the built-in if possible

WDYT?

@tokoko
Copy link
Collaborator

tokoko commented May 31, 2024

yup, I'd prefer fixing it with built-in if possible. importlib libraries are pretty popular and have caused diamond dependency problems before... so if there's a way to not depend on them, that would be a plus. thanks a lot

@privatedumbo
Copy link
Contributor

Good, agreed. Will come back tomorrow for this. Thanks for the ping-pong 🏓

@shuchu
Copy link
Collaborator

shuchu commented May 31, 2024

So you suggest fixing this using the built-in one, instead of installing importlib-resources?

yes, the Python built-in one is preferred as the discussion concluded.

@privatedumbo
Copy link
Contributor

PR raised here:
#4248

@Annamalaisaravanan
Copy link

Follow this Video, This helped me a lot to crack and overcome this error: https://www.youtube.com/watch?v=rBJvW3AjmsM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants