CiscoDevNet / yangsuite

Cisco YANG Suite provides a set of tools and plugins to learn, test, and adopt YANG programmable interfaces such as NETCONF, RESTCONF, gNMI and more.
Other
244 stars 75 forks source link

"Error 500: [Errno 2] No such file or directory: "YANG set '...' owned by '...' (609 modules)" #91

Closed 8bitDesigner closed 1 year ago

8bitDesigner commented 1 year ago

Hi all, I just checked out this project this morning, and I'm receiving the following error when trying to explore a yangset I have set up:

Error 500: [Errno 2] No such file or directory: "YANG set 'ms390-default-yangset' owned by 'pausween' (609 modules)"

And the stack trace from the console:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/pausween/.pyenv/versions/3.8.16/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/Users/pausween/.pyenv/versions/3.8.16/lib/python3.8/multiprocessing/spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
  File "/Users/pausween/yangsuitevenv/lib/python3.8/site-packages/ysyangtree/yangsettree.py", line 18, in <module>
    from ysyangtree.models import YangSetTree, YangSetJSON
  File "/Users/pausween/yangsuitevenv/lib/python3.8/site-packages/ysyangtree/models.py", line 28, in <module>
    class YangSetJSON(models.Model):
  File "/Users/pausween/yangsuitevenv/lib/python3.8/site-packages/django/db/models/base.py", line 103, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/Users/pausween/yangsuitevenv/lib/python3.8/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
    self.check_apps_ready()
  File "/Users/pausween/yangsuitevenv/lib/python3.8/site-packages/django/apps/registry.py", line 135, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
[28/Mar/2023 19:56:33] ERROR [yangsuite.ysyangtree.yangsettree:427] MAC Python 3.8 cannot build tree in process
[28/Mar/2023 19:56:33] ERROR [django.request:222] [Errno 2] No such file or directory: "YANG set 'ms390-default-yangset' owned by 'pausween' (609 modules)": /yangtree/gettree/
[28/Mar/2023 19:56:33] ERROR [django.server:154] "POST /yangtree/gettree/ HTTP/1.1" 500 2

Steps to reproduce

  1. Start a clean install of yangsuite on MacOS 13.2.1:
$ ~/.pyenv/versions/3.8.12/bin/python -m venv yangsuitevenv
$ source yangsuiteenv/bin/activate
$ pip install pip wheel setuptools --upgrade
$ pip install yangsuite
$ yangsuite
  1. Set up a new device profile under "Setup > Device Profiles"
  2. Select the profile, and click "Create default Repository and Yangset"
  3. Go to "Explore > YANG", select the newly configured yangset, select a module, and click "Load module(s)"

Versions

(yangsuitevenv) PAUL.SWEENEY-M-JLWV [0] ~$ pip list | grep yangsuite
yangsuite             2.9.10
yangsuite-devices     2.9.3
yangsuite-filemanager 1.9.0
yangsuite-netconf     1.17.17
yangsuite-yangtree    2.1.2
8bitDesigner commented 1 year ago

I'm not a Python expert, but I think this is because the YSContext class is being inited with a YSYangSet instead of a string, which would explain why the error message is printing out "No such file or directory: '{YSYangSet string representation}'". If I replace the YSYangSet's string representation method with yangset_path(self.owner, self.setname) (eg: print its path instead of a description), this seems to work

mobig commented 1 year ago

I'm not a Python expert, but I think this is because the YSContext class is being inited with a YSYangSet instead of a string, which would explain why the error message is printing out "No such file or directory: '{YSYangSet string representation}'". If I replace the YSYangSet's string representation method with yangset_path(self.owner, self.setname) (eg: print its path instead of a description), this seems to work

i'm having the same issue. can you give more detail on what files and lines you changed to work around this?

8bitDesigner commented 1 year ago

In my case it was yangsuitevenv/lib/python3.8/site-packages/ysfilemanager/filemanager/yangset.py where yangsuitevenv is the name of the virtualenv I set up to install YangSuite into

miott commented 1 year ago

We have a bug open on this, the engineer was able to reproduce it, and we should have a fix soon.

RefluxMeds commented 1 year ago

Hi, I'm having a similiar issue. Yang repos and module sets can be configured, but trying to open any model for exploration in the Explore -> YANG tab errors out with Error 500: 'YSContext' object has no attribute 'repository'

The server logs:

[31/Mar/2023 13:41:24] ERROR [django.request:222] 'YSContext' object has no attribute 'repository': /yangtree/gettree/ [31/Mar/2023 13:41:24] ERROR [django.server:154] "POST /yangtree/gettree/ HTTP/1.1" 500 2 Process Process-7: Traceback (most recent call last): File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/ubuntu/testing/yangsuite/.venv/lib/python3.8/site-packages/ysyangtree/yangsettree.py", line 312, in create_tree_process ctx = YSContext.get_instance(ref, merge_user_set( File "/home/ubuntu/testing/yangsuite/.venv/lib/python3.8/site-packages/ysyangtree/context.py", line 148, in get_instance repo = ctx.repository AttributeError: 'YSContext' object has no attribute 'repository' [31/Mar/2023 13:41:42] ERROR [django.request:222] 'YSContext' object has no attribute 'repository': /yangtree/gettree/ [31/Mar/2023 13:41:42] ERROR [django.server:154] "POST /yangtree/gettree/ HTTP/1.1" 500 2 Process Process-8: Traceback (most recent call last): File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/ubuntu/testing/yangsuite/.venv/lib/python3.8/site-packages/ysyangtree/yangsettree.py", line 312, in create_tree_process ctx = YSContext.get_instance(ref, merge_user_set( File "/home/ubuntu/testing/yangsuite/.venv/lib/python3.8/site-packages/ysyangtree/context.py", line 148, in get_instance repo = ctx.repository AttributeError: 'YSContext' object has no attribute 'repository' [31/Mar/2023 13:43:38] ERROR [django.request:222] 'YSContext' object has no attribute 'repository': /yangtree/gettree/ [31/Mar/2023 13:43:38] ERROR [django.server:154] "POST /yangtree/gettree/ HTTP/1.1" 500 2

miott commented 1 year ago

A fix for this has been deployed to yangsuite-yangtree as a pre-release. Pre-releases can be manually installed or you can wait for yangsuite-yangtree 2.1.3 main release (probably sometime next week).

** NOTE: your directory or container name may vary depending on your install

source yangsuite/venv/bin/activate
pip install --upgrade --pre yangsuite-yangtree

For docker containers first enter the container using the exec command.

docker exec -it yangsuite bash
pip install --upgrade --pre yangsuite-yangtree

Should have yangsuite-yangtree 2.1.3.post0.dev3 showing in Admin-->Manage plugins