cozodb / pycozo

The Python client and Jupyter helper for CozoDB
Mozilla Public License 2.0
47 stars 9 forks source link

Add multitransact support for remote connections #14

Open hosford42 opened 1 month ago

hosford42 commented 1 month ago

What needs to happen for this to be added? I'd like to help.

https://github.com/cozodb/pycozo/blob/26132723ba90e41b703d9c789738aa0e273edfdc/pycozo/client.py#L279

hosford42 commented 1 month ago

Looking at the cozo source, it appears to be supported on the server side:

https://github.com/cozodb/cozo/blob/6ab063c627a57242ff42d563dfa1ce41264bcc72/cozo-bin/src/server.rs#L255C1-L256C72

        .route("/transact", post(start_transact))
        .route("/transact/:id", post(transact_query).put(finish_query))

I think it just needs a class with the same interface as MultiTransact to wrap these API calls so they are made at the right times. Is there anything I'm overlooking?

hosford42 commented 1 month ago

I have code implemented to handle this now, but I'm getting a 400 Client Error: Bad Request for the /transact endpoint. It's clearly there in the rust code. Is it possible this was somehow excluded from the build I'm running? I'm running the precompiled cozo binary for windows x64, cozo-0.7.6-x86_64-pc-windows-msvc.exe, from the latest release.

hosford42 commented 1 month ago

I sorted out the bad request issue. User error, no surprise there. Now trying to identify why the actual query is hanging.

hosford42 commented 1 month ago

Submitted a pull request: https://github.com/cozodb/pycozo/pull/16

Let me know if you'd like me to make other changes in order to accept.

hosford42 commented 1 month ago

The query hanging issue appears to be related to improper termination of the client, and seems to only affect the mem engine. I think it needs to be addressed on the server side. A client error shouldn't impact future connections.