| 00:10 | paul121[m] | > <@mstenta:matrix.org> Main differences from the previous approach:... (full message at libera.ems.host/_matrix/media/r0/downloa) |
| 18:05 | paul121[m] | soo I spent a couple hours last night re-writing farmOS.py 😅 |
| 18:06 | paul121[m] | but what's amazing is how easy it was... using this new httpx library! www.python-httpx.org/ |
| 18:07 | paul121[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:11 | paul121[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:11 | paul121[m] | *only* having helper methods that are wrappers around `client.request(...)` |
| 18:17 | paul121[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:17 | paul121[m] | this is good for two reasons: |
| 18:17 | paul121[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:17 | paul121[m] | 2) You can make your own auth handler! |
| 18:22 | paul121[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:22 | paul121[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:22 | paul121[m] | my current code is here (all tests passing except for a weird subrequests bug!!) : github.com/farmOS/farmOS.py/compare/1.x. |
| 18:25 | paul121[m] | Usage:... (full message at libera.ems.host/_matrix/media/r0/downloa) |
| 18:28 | paul121[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:19 | symbioquine[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:19 | symbioquine[m] | > |
| 19:19 | symbioquine[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:19 | symbioquine[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:29 | paul121[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:29 | paul121[m] | It seems like you do this or maintain both sets of code |
| 19:29 | symbioquine[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:30 | symbioquine[m] | The part we couldn't reach a consensus on was how much farmOS.py should abstract the API. |
| 19:31 | symbioquine[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:32 | symbioquine[m] | * how much `farmOS.py, * farmOS.py` should |
| 19:32 | symbioquine[m] | * proposition of `farmOS.py, * farmOS.py` should |
| 19:33 | paul121[m] | In others words, farmOS.py not depend on any http client itself? |
| 19:34 | symbioquine[m] | Well maybe, but that's not what I meant by abstraction |
| 19:35 | symbioquine[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:36 | symbioquine[m] | (Though at the time I wrote that proposal it wasn't `JSON:API`) |
| 19:36 | paul121[m] | Ah yes |
| 19:37 | paul121[m] | We should chat more about this. There might be a couple layers |
| 20:06 | mstenta[m] | github.com/farmOS/farmOS/pull/544 |
| 20:06 | mstenta[m] | Finished the documentation this morning |
| 20:07 | mstenta[m] | Ready to merge if y'all approve! |
| 20:21 | symbioquine[m] | Left a couple minor comments |
| 20:35 | mstenta[m] | Thanks symbioquine! Replied... |
| 21:47 | mstenta[m] | symbioquine: what do you use for creating screen recording gifs? |
| 21:52 | symbioquine[m] | Peek |
| 21:52 | symbioquine[m] | github.com/phw/peek |