Typed Python clients
Currently we're trying to experiment with replacing our NATS service with Convex's realtime mechanism. So the Python service, would subscribe to changes in Convex, simplifying our stack significantly.
We've set up Convex in the Python client and it is working fine, the subscriptions too. The only thing is that we don't have any types for the subscribed values. Currently for example in the following code example, the tasks varible just has a type of "ConvexValue" instead of "Task" or something like that:
for tasks in convexClient.subscribe("queries/tasks:get"):
print(tasks)
The reason we have typings in the NATS setup is because we're using a yml spec file for that in combination with asyncapi-codegen.
Is there some way to generate typed Python types/clients for Convex? Or would I have to write my own parser/generator?
4 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I just found this by @λx.1 - https://github.com/ParsonosAI/convex-schema-parser
Going to try that out
GitHub
GitHub - ParsonosAI/convex-schema-parser: Parses your
schema.ts
a...Parses your
schema.ts
and generates types for Python/Rust - ParsonosAI/convex-schema-parserActually I get an error when trying to install the package
"Error: cabal: Unknown package "convex-schema-parser"."
Hi, sorry. I am not that often online here. Did you try to do
cabal install convex-schema-parser
after cloning and entering the repo?
This package is not hosted on Hackage
but I could do that, which would remove the requirement of cloning.
I am currently waiting to be approved for package uploads to Hackage. (:
In the meantime, you would have to clone the repo yourself, cd
into it and then issue a cabal install convex-schema-parser
The README also gives an outline on how to run the executable without installing via cabal run convex-schema-parser -- {dev,generate}
. Hope this helps, if you guys still are searching for something.