< 182022-06-19⋎20 >

Topic for #farmOS is: farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Forum: farmOS.discourse.groupSet by mstenta on 2021-06-15 at 12:52
00:10paul121[m]> <@mstenta:matrix.org> Main differences from the previous approach:... (full message at libera.ems.host/_matrix/media/r0/downloa)
18:05paul121[m]soo I spent a couple hours last night re-writing farmOS.py 😅
18:06paul121[m]but what's amazing is how easy it was... using this new httpx library! www.python-httpx.org/
18:07paul121[m]> HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support for both HTTP/1.1 and HTTP/2.
18:11paul121[m]It really eliminates all of the http/client level logic we have in farmOS.py... it ends up looking like this:... (full message at libera.ems.host/_matrix/media/r0/downloa)
18:11paul121[m]*only* having helper methods that are wrappers around `client.request(...)`
18:17paul121[m]to be fair, this is much simpler because it doesn't handle authentication. httpx allows you to provide your own class to handle authentication flows: www.python-httpx.org/advanced/#customizi
18:17paul121[m]this is good for two reasons:
18:17paul121[m]1) We should be able to use an existing/reusable OAuth2 auth class (like github.com/Colin-b/httpx_auth, although this doesn't seem quite perfect/mature)
18:17paul121[m]2) You can make your own auth handler!
18:22paul121[m]symbioquine: I'm curious what you think about this. I believe httpx addresses many of the points you made awhile back... github.com/farmOS/farmOS.py/issues/31
18:22paul121[m]hybrid async/sync methods, supporting different async backends, pluggable authentication, etc.. but most importantly at a lower level, where it really makes sense to do so!!
18:22paul121[m]my current code is here (all tests passing except for a weird subrequests bug!!) : github.com/farmOS/farmOS.py/compare/1.x.
18:25paul121[m]Usage:... (full message at libera.ems.host/_matrix/media/r0/downloa)
18:28paul121[m]the biggest thing holding me back is that this httpx_auth library isn't quite perfect... it supports many of the OAuth2 classes but only uses the original `access_token`, it doesn't support refreshing with a `refresh_token`. It also doesn't support async authentication. But these are things we could implement ourselves, might be better than having another dependency.
19:19symbioquine[m]> <@paul121:matrix.org> symbioquine: I'm curious what you think about this. I believe httpx addresses many of the points you made awhile back... github.com/farmOS/farmOS.py/issues/31
19:19symbioquine[m]>
19:19symbioquine[m]> hybrid async/sync methods, supporting different async backends, pluggable authentication, etc.. but most importantly at a lower level, where it really makes sense to do so!!
19:19symbioquine[m]Unless something's changed at the Python level, there isn't really a way to abstract out the dual async/sync support. You either end up doing code transformation/rewriting like I was doing or you end up duplicating the code in `FarmClient`/`AsyncFarmClient`.
19:29paul121[m]Ah yes.. that's the same situation. There is an `unasync` library that tries to help do this, copy _async code into a new _sync folder..
19:29paul121[m]It seems like you do this or maintain both sets of code
19:29symbioquine[m]As I recall, that was a big part of my proposal was how to organize the code such that the API would make sense while cleanly supporting both.
19:30symbioquine[m]The part we couldn't reach a consensus on was how much farmOS.py should abstract the API.
19:31symbioquine[m]I still feel that it's pretty trivial to use the API directly via requests or a similar library so the value proposition of farmOS.py should be in providing an abstraction of some sort.
19:32symbioquine[m]* how much `farmOS.py, * farmOS.py` should
19:32symbioquine[m]* proposition of `farmOS.py, * farmOS.py` should
19:33paul121[m]In others words, farmOS.py not depend on any http client itself?
19:34symbioquine[m]Well maybe, but that's not what I meant by abstraction
19:35symbioquine[m]I meant abstracting the API details so you're interacting with a Python version of the farmOS data model, not the farmOS data model strained through a `JSON:API` sieve.
19:36symbioquine[m](Though at the time I wrote that proposal it wasn't `JSON:API`)
19:36paul121[m]Ah yes
19:37paul121[m]We should chat more about this. There might be a couple layers
20:06mstenta[m]github.com/farmOS/farmOS/pull/544
20:06mstenta[m]Finished the documentation this morning
20:07mstenta[m]Ready to merge if y'all approve!
20:21symbioquine[m]Left a couple minor comments
20:35mstenta[m]Thanks symbioquine! Replied...
21:47mstenta[m]symbioquine: what do you use for creating screen recording gifs?
21:52symbioquine[m]Peek
21:52symbioquine[m]github.com/phw/peek

< 182022-06-19⋏20 >