Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: jupyterlab extension #83

Closed
charles-cooper opened this issue Jun 12, 2023 · 11 comments · Fixed by #109
Closed

feature: jupyterlab extension #83

charles-cooper opened this issue Jun 12, 2023 · 11 comments · Fixed by #109

Comments

@charles-cooper
Copy link
Member

it would be cool to have https://github.com/vyperlang/titanoboa/blob/2c2a2664ad3fa566ddda8a43851cd6f14ab9276a/boa/integrations/jupyter.py work with jupyterlab (on account of jupyterlab being the new thing, it has an IDE and workspace etc). the current method for loading ethers does not seem to work though, it fails with require not defined, seems to be related to Calysto/calysto_processing#11 (comment). it looks like the thing to do is write a proper jupyterlab extension, which would be cool too since we could support vyper files natively.

@charles-cooper
Copy link
Member Author

also debugger (cf. https://jupyterlab.readthedocs.io/en/stable/user/debugger.html) and kernel for vyper could be done

@DanielSchiavini
Copy link
Collaborator

Is the idea here to simply port the existing code into a proper plugin, or do we want to add/change the functionality as well?
If so it would be great to know what the new functions we want implement are (maybe in separate issues?)

@charles-cooper
Copy link
Member Author

i think first port into a plugin, and then we can talk about adding additional functionality. the real issue that i'm trying to address here is that the way of jerry-rigging the required libraries that works for jupyter notebook does not work for jupyter labs.

@DanielSchiavini
Copy link
Collaborator

DanielSchiavini commented Dec 5, 2023

I created a plugin template in https://github.com/DanielSchiavini/titanoboa-jupyterlab

Update dec 5: trying to figure out how to add a comm target from the frontend. The kernel is not directly available like before. Alternatevely we could implement some other 2 way communication via ipython or tornado, but that's much more cumbersome.

@DanielSchiavini
Copy link
Collaborator

DanielSchiavini commented Dec 6, 2023

I got it working with API calls and shared memory, no websockets needed frontend and backend and the signer. There's still bugs to fix and tests to write, but this solution with shared memory is feasible and relatively simple.

@charles-cooper
Copy link
Member Author

I got it working with API calls and shared memory, no websockets needed frontend and backend and the signer. There's still bugs to fix and tests to write, but this solution with shared memory is feasible and relatively simple.

very slick! i think i have a couple reservations about using shared_memory_dict -- it's another dependency, and it also seems insecure because it uses pickle for instance (but that seems easy to get around by using shared_memory directly instead) and pass via json, or use something builtin to the mp library -- https://docs.python.org/3/library/multiprocessing.html#sharing-state-between-processes

@charles-cooper
Copy link
Member Author

btw, does this technique work with google colab somehow?

@DanielSchiavini
Copy link
Collaborator

We definitely don't need any extra dependencies, this was an easy way to proof the concept.
About Collab, I have no idea, and I wasn't able to find the restrictions quickly today. I can investigate more.

@DanielSchiavini
Copy link
Collaborator

I replaced the shared dict dependency with a SharedMemory object for each of the expected callbacks. DanielSchiavini/titanoboa-jupyterlab@2e86d6b

@DanielSchiavini
Copy link
Collaborator

DanielSchiavini commented Dec 13, 2023

The integration tests are failing in Github for some stupid reason (they pass locally).
I've managed to reproduce the issue locally, and track down an exception thru act, docker and jupyterlab to this line. It produces ["TypeError: Cannot read properties of undefined (reading 'get')","TypeError: Cannot read properties of undefined (reading 'get')"] which is about the most generic error in the planet and it can come from literally anywhere. And the error details are right there being ignored in the line. 😠
I'm trying to intercept the call somehow but it's not easy inside Github actions 😞

Of course we could ignore the included tests, but the pipelines are vital to easily produce a npm+pip package.

@DanielSchiavini
Copy link
Collaborator

DanielSchiavini commented Jan 12, 2024

I have 2 PRs with the implementation ready for review:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants