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

[BUG] Wonky bug with layouts module #931

Open
ebridge2 opened this issue Mar 11, 2022 · 6 comments
Open

[BUG] Wonky bug with layouts module #931

ebridge2 opened this issue Mar 11, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@ebridge2
Copy link
Collaborator

Expected Behavior

import graspologic

works successfully in a jupyter notebook, after setting up from either github or the setup.py file manually (e.g., cloning package).

Actual Behavior

import graspologic

produces the following error from a jupyter notebook:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/.virtualenvs/graspy-fix/lib/python3.8/site-packages/pkg_resources/__init__.py:355, in get_provider(moduleOrReq)
    354 try:
--> 355     module = sys.modules[moduleOrReq]
    356 except KeyError:

KeyError: None

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import graspologic
      2 print(graspologic.__file__)

File <frozen importlib._bootstrap>:991, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:975, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:655, in _load_unlocked(spec)

File <frozen importlib._bootstrap>:618, in _load_backward_compatible(spec)

File <frozen zipimport>:259, in load_module(self, fullname)

File ~/.virtualenvs/graspy-fix/lib/python3.8/site-packages/graspologic-1.0.1-py3.8.egg/graspologic/__init__.py:9, in <module>
      7 import graspologic.embed
      8 import graspologic.inference
----> 9 import graspologic.layouts
     10 import graspologic.models
     11 import graspologic.nominate

File <frozen importlib._bootstrap>:991, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:975, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:655, in _load_unlocked(spec)

File <frozen importlib._bootstrap>:618, in _load_backward_compatible(spec)

File <frozen zipimport>:259, in load_module(self, fullname)

File ~/.virtualenvs/graspy-fix/lib/python3.8/site-packages/graspologic-1.0.1-py3.8.egg/graspologic/layouts/__init__.py:6, in <module>
      1 # Copyright (c) Microsoft Corporation.
      2 # Licensed under the MIT license.
      5 from .classes import NodePosition
----> 6 from .colors import categorical_colors, sequential_colors
      7 from .render import save_graph, show_graph
      9 from .auto import layout_tsne, layout_umap  # isort:skip

File <frozen importlib._bootstrap>:991, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:975, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:655, in _load_unlocked(spec)

File <frozen importlib._bootstrap>:618, in _load_backward_compatible(spec)

File <frozen zipimport>:259, in load_module(self, fullname)

File ~/.virtualenvs/graspy-fix/lib/python3.8/site-packages/graspologic-1.0.1-py3.8.egg/graspologic/layouts/colors.py:36, in <module>
     32     dark: Dict[Any, Any] = thematic_json["dark"]
     33     return light, dark
---> 36 _CACHED_LIGHT, _CACHED_DARK = _load_thematic_json(None)
     39 def _get_colors(light_background: bool, theme_path: Optional[str]) -> Dict[Any, Any]:
     40     light = _CACHED_LIGHT

File ~/.virtualenvs/graspy-fix/lib/python3.8/site-packages/graspologic-1.0.1-py3.8.egg/graspologic/layouts/colors.py:26, in _load_thematic_json(path)
     24 else:
     25     atexit.register(pkg_resources.cleanup_resources)
---> 26     include_path = pkg_resources.resource_filename(__package__, "include")
     27     colors_path = os.path.join(include_path, "colors-100.json")
     29 with open(colors_path) as thematic_json_io:

File ~/.virtualenvs/graspy-fix/lib/python3.8/site-packages/pkg_resources/__init__.py:1141, in ResourceManager.resource_filename(self, package_or_requirement, resource_name)
   1139 def resource_filename(self, package_or_requirement, resource_name):
   1140     """Return a true filesystem path for specified resource"""
-> 1141     return get_provider(package_or_requirement).get_resource_filename(
   1142         self, resource_name
   1143     )

File ~/.virtualenvs/graspy-fix/lib/python3.8/site-packages/pkg_resources/__init__.py:357, in get_provider(moduleOrReq)
    355     module = sys.modules[moduleOrReq]
    356 except KeyError:
--> 357     __import__(moduleOrReq)
    358     module = sys.modules[moduleOrReq]
    359 loader = getattr(module, '__loader__', None)

TypeError: __import__() argument 1 must be str, not None

Your Environment

  • Python version: 3.8.2
  • graspologic version: 1.0.1 (dev branch)

Additional Details

The package builds/works successfully from a terminal session, so obviously my first thought was that I had mis-configured/not appropriately configured my jupyter kernel for the notebook. However, I verified manually that graspologic.__file__ pointed to the same thing in both places, which it did. Further verified that my jupyter kernel was the right version of python, which it was. Not really sure what to do from there. Not sure whether this is a jupyter issue, OS issue (mac), or a python issue relating to something else.

@ebridge2 ebridge2 added the bug Something isn't working label Mar 11, 2022
@daxpryce daxpryce self-assigned this Mar 23, 2022
@daxpryce
Copy link
Contributor

Oh this is going to be so much fun to track down. Basically we try to look inside the module for the json file that contains the thematic color palette and use it. The current process was supposed to work everywhere - relative paths, or while packaged, etc - but it seems like Jupyter is putting you in an odd state that we didn't expect. What's most vexxing is that this absolutely works for other people in Jupyter, so there's something else adding a new wrinkle that we didn't expect at all.

@ebridge2
Copy link
Collaborator Author

@daxpryce for reference, there was no 😢 react, so let the 👍 stand in its place :(

@ebridge2
Copy link
Collaborator Author

@ebridge2
Copy link
Collaborator Author

@daxpryce perhaps a "healthy medium" as a last resort fail-safe would be a try-catch that downloads it if it's not there if the computer is connected to interwebz..?

@ebridge2
Copy link
Collaborator Author

yah; this doesn't work for me locally, nor on a remote jupyter instance for the github workflow we use for the book... so something is amuck. no clue how to rectify.

@ebridge2
Copy link
Collaborator Author

ebridge2 commented Mar 25, 2022

Ok so I just brute forced it temporarily by literally wgetting and chmodding with problematically bad permissions to fix the issue for the specific deployment workflow I needed to work as seen https://github.com/neurodata/graph-stats-book/blob/accde1f0dcad134b2d7843fa637923db77d4068a/.github/workflows/deploy.yml#L29, so no longer critical to me, but definitely still seems to be a problem. The workflow we were building off was using ubuntu-latest on a github workflow, and we were building using pip install git+<appropriate path to graspologic>@dev directly from the dev branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants