volttron icon indicating copy to clipboard operation
volttron copied to clipboard

platform driver agent restful interface

Open bbartling opened this issue 2 years ago • 5 comments

Update driver to use grequests instead of requests library.

Currently the driver seems to only support a rest api that has a baseline URL and concatenating the "point" into the url path with no parsing of the payload.

This feature is nice but what if the API doesnt support this and data needs to be parsed? Can an update include optional parsing a payload??

bbartling avatar Jul 22 '22 00:07 bbartling

I assume you are talking about https://github.com/VOLTTRON/volttron/blob/main/services/core/PlatformDriverAgent/platform_driver/interfaces/restful.py.

How would you have the agent parse the payload? Do you have something in mind? Will the response be in xml, json, protocol bufs?

I think it might be easier to customize this per the endpoint one is trying to parse. Then you can supply the logic to parse the data and use the platform driver to format and publish

craig8 avatar Jul 22 '22 14:07 craig8

Hi Craig, the only I know how to do is Jerry Rig the scrape all to parse everything you need... Like this:

https://gist.github.com/bbartling/9cff12ac5f9f41d0f358b2fec97dcc7c#:~:text=def%20_scrape_all(self)%3A

bbartling avatar Jul 24 '22 14:07 bbartling

That's what you would generally need to do for each of the potential payloads. I wouldn't call that Jerry Rig though I would call that development using open source technology. For what you show in your gist is customized to work with what you need it to.

craig8 avatar Jul 25 '22 16:07 craig8

Should we be using requests or grequests? Or does it matter?

On Mon, Jul 25, 2022, 11:15 AM Craig @.***> wrote:

That's what you would generally need to do for each of the potential payloads. I wouldn't call that Jerry Rig though I would call that development using open source technology. For what you show in your gist is customized to work with what you need it to.

— Reply to this email directly, view it on GitHub https://github.com/VOLTTRON/volttron/issues/2979#issuecomment-1194304451, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHC4BHNCZVVCB4TTEXI2ZJ3VV24TLANCNFSM54JONFEA . You are receiving this because you authored the thread.Message ID: @.***>

bbartling avatar Jul 25 '22 22:07 bbartling

If you are going to use it in a greenlet requests is fine, if you are going to use it outside of a greenlet then use grequests. The difference being that if you are in a greenlet context then you aren't in the main thread of the agent.

craig8 avatar Jul 28 '22 16:07 craig8