Running specklepy inside pyodide (browser)

Hey specklers,

In case you haven’t heard of pyodide, its a python port (runtime?) to WASM that can run natively inside browsers. It supports installing packages and already there are many packages that work for it like matplotlib, pandas, etc. I was trying to install Specklepy with it but I noticed it fails because of two dependencies:

You can try yourself by going to the pyodide REPL and running:

import micropip
await micropip.install("specklepy", keep_going=True)

For specklepy to work inside pyodide those two dependencies (ujson, stringcase) must have wheels available in PyPI, however they are too old like stringcase or not maintained and possibily unsafe like ujson.

After a quick research @gizemdemirhaan and I found out that this two dependenies have easy replacements, and I wanted to raise a PR to update them. Would you be interested in looking into it?

Hey @andrsbtrg

I’m tracking the pyodide efforts, but a bit further than you by the looks of it. It is a fun new avenue for python in the browser, so if you have a PR for this, I’d love to get it in.

Tbf ujson comes from pydantic, and I don’t think we’re using it as a JSON parser, so there probably a requirement narrowing would be enough. For stringcase I guess we need an alternative with pre built wheels…

Anyhow I’d love to see what you are trying to build with this :slightly_smiling_face:

2 Likes

Hey @gjedlicska ,

That’s great! i will raise it soon and look forward to your comments.

The reason why we’re interested in pyodide is that would like to have way to debug the test specifications that our library maple uses for model quality check. They look something like this:

def spec_d():
    mp.it("validates basic roof`s thermal mass")

    mp.get("family", "Basic Roof").where("type", "SG Metal Panels roof").its(
        "Thermal Mass"
    ).should("be.equal", 20.512)

The library depends on specklepy to query the model and then asserts the properties.

We would like to debug a script like this without having to install python, deps, etc, so we about thought using the browser as the debug environment with pyodide.

1 Like