kytos / pathfinder

Kytos main path finder Network Application (NApp)
https://napps.kytos.io/kytos/pathfinder
MIT License
1 stars 21 forks source link

Show a better error message when required imports fail #30

Closed viniarck closed 4 years ago

viniarck commented 5 years ago

@beraldoleal @hdiogenes, sometimes when I start over my dev environment from scratch I usually have to keep reinstalling other pip dependencies since the NApp package at the moment is not capable of bootstraping the other/third party dependencies like networkx.

I figured it would be nice to have a bootstrap mechanism in place. With this PR it auto bootstrap if there's an ImportError:

❯ pip list | grep networkx
networkx                 2.2
❯ pip uninstall networkx -y
Uninstalling networkx-2.2:
  Successfully uninstalled networkx-2.2
~/repos/kytos/.direnv/python-3.6.6/var/lib/kytos/napps/.installed/kytos/pathfinder autopip_networkx
❯ kytosd -f -E
2019-01-13 19:54:35,705 - INFO [kytos.core.logs] (MainThread) Logging config file "/home/viniarck/repos/kytos/.direnv/python-3.6.6/etc/kytos/logging.ini" loaded successfully.
...
2019-01-13 19:54:35,876 - INFO [controller] (MainThread) Loading NApp kytos/pathfinder
2019-01-13 19:54:35,877 - INFO [root] (mef_eline) Running NApp: <Main(mef_eline, started 140484189910784)>
Collecting networkx>=2.2
Requirement already satisfied: decorator>=4.3.0 in /home/viniarck/repos/kytos/.direnv/python-3.6.6/lib/python3.6/site-packages (from networkx>=2.2) (4.3.0)
Installing collected packages: networkx
Successfully installed networkx-2.2
2019-01-13 19:54:38,034 - INFO [api_server] (MainThread) Started /api/kytos/pathfinder/v2/ - POST

What do you think?

viniarck commented 5 years ago

Hi @hdiogenes. Indeed. I just rebased the PR and just kept the error message. In the long term though, it would be nice to have a solution to facilitate installing libraries dependencies for end users.

hdiogenes commented 5 years ago

Thanks, @viniarck. I've created a bug for that https://github.com/kytos/kytos/issues/890.

viniarck commented 5 years ago

@beraldoleal my bad, I missed this notification. I just fixed the error that 'yala' was complaining about the variable name.