bskinn / soi-app

sphobjinv suggest web app
MIT License
0 stars 0 forks source link

Investigate client-side PyScript callback #10

Open bskinn opened 2 years ago

bskinn commented 2 years ago

https://dash.plotly.com/clientside-callbacks

Minimal server load if the sphobjinv computation happens in the browser...

PyScript doesn't ship with C-compiled _ssl package, though Pyodide does have an ssl module. Make it use that? Or... download the inventory to local storage and then load? Still hits the ImportError trying to import sphobjinv. Modify sphobjinv to defer the error... warn that _ssl didn't load, and then only actually raise an error if _ssl is tried to be used?

bskinn commented 1 year ago

Can't download arbitrary files to JS -- CORS restrictions.

Download the inventory on the server, base64 encode, and pass to frontend... pass the base64 to PyScript, base64 decode, then pass directly to soi.Inventory?

Would still have to fix the import behavior for sphobjinv to defer any exception from the ssl import until an attempt to use it is actually made by an Inventory(url=...) instantiation.

YAGNI unless traffic gets HUGE. Can just scale PythonAnywhere workers until then, as long as cost doesn't get preposterous.

bskinn commented 1 year ago

Have to pull the inventory on the server side, tuple it with the search params, pickle/base64 encode, then send over the wire to the client. The PyScript code then takes the payload, b64decodes/pickle.loads, picks it apart, then loads into an Inventory and calls suggest.

A server-side callback updates a component, which then triggers a client-side callback?

bskinn commented 1 year ago

One possible setup: Instead of trying to chain the inventory retrieval and caching and searching all together, have one section of the page that's the data retrieval.. where the user enters a link, hits a button, and the server provides the encoded objects inventory file. That inventory info passed over from the server then populates a list box, for the user to pick from.

Then, another section of the page is for suggest searching of whichever cached inventory is selected.

Could present inventories in the drop-down/listbox as both project and version... that way users could easily search multiple versions of the same docset.