[patch, netjsonconfig]: importing backends from other modules

31 views
Skip to first unread message

Edoardo Putti

unread,
May 21, 2018, 4:36:39 AM5/21/18
to OpenWISP
Hello everyone,

it's been a long time since 2017 GSOC but I keep reading the digest from the project.

Recently I had some time to experiment with python packaging and this is the result applied to netjsonconfig [0].

This change would help integrating with custom backend that the community has been experimenting on that did not get merged upstream [1], [2], [3], [4] or simply
make writing a backend simpler without having to touch the original netjsonconfig code.

I still don't know if this is the correct way to do this "find backends dinamically" thing so if there are more experienced python packagers please chime in.

edoput

Federico Capoano

unread,
May 21, 2018, 6:15:08 AM5/21/18
to OpenWISP
Hi Edoardo,

thanks for the patch.

I'm not 100% sure I fully understood this patch in practice.
In the pull request you cite a `setup.py` example, but I don't understand if that would be the `setup.py` of a python module using netjsonconfig or that should be the setup.py of netjsonconfig itself.
Could you give a full example?

If it's what I think it is, it will most likely need a bit of documentation to help users understand how this feature works and how it can be used.

Federico

Edoardo Putti

unread,
May 21, 2018, 10:29:42 AM5/21/18
to OpenWISP
The patch is from a package using netjsonconfig.

Take AirOS as an example, I would create a project, netjsonconfig-airos, import netjsonconfig for the base classes, write my backend + templates
and then write the entry_point attribute in my setup.py to reference my backend class.

Then when using netjsonconfig if I want to use the netjsonconfig-airos backend it's just a pip install away.

I'll make an example backend soon to provide more reference to how this works

Federico Capoano

unread,
May 21, 2018, 2:11:38 PM5/21/18
to OpenWISP
Sounds great. Could you add some documentation regarding this feature?
You could, for example, start a page called "extending.rst" and explain this concept there including an example.

It will be a great chance for me as well to add a few lines on how to create a new backend.

Federico

Edoardo Putti

unread,
May 22, 2018, 5:27:17 PM5/22/18
to OpenWISP
The example backend is available here https://github.com/edoput/example_backend

I'll add a page documenting this feature soon

eg...@innovationgarage.no

unread,
May 23, 2018, 10:48:19 AM5/23/18
to OpenWISP
I greatly support this patch as it's The Right Way To Do it<tm> :P Please merge :)

Edoardo Putti

unread,
May 24, 2018, 6:14:10 AM5/24/18
to OpenWISP
I've added a page title `create_your_backend` to the documentation. Rigth now is in docs/source/backend folder, let me know if this should be elsewhere

Edoardo Putti

unread,
Jun 10, 2018, 4:22:29 AM6/10/18
to OpenWISP
I finally found some time to squash the commits and make every check green so this feature could be safely merged.

I don't know if anyone has tested it before the merge but if you encounter any issue I'm happy to help troubleshooting

Have a nice Sunday

edoput

Federico Capoano

unread,
Jun 11, 2018, 6:25:52 AM6/11/18
to OpenWISP
I merged, thank you Edoardo!

I'd be happy if some of you guys could test the development version and send any useful feedback.

Fed
Reply all
Reply to author
Forward
0 new messages