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

pinkgorilla notebook integration #11

Open
awb99 opened this issue Apr 29, 2020 · 4 comments
Open

pinkgorilla notebook integration #11

awb99 opened this issue Apr 29, 2020 · 4 comments

Comments

@awb99
Copy link

awb99 commented Apr 29, 2020

Hi Alan!
Thanks a lot for your nice library!

I was working on tech.ml and libpython integration with pinkgorilla notebook.
This is where i am currently:
https://github.com/pink-gorilla/python-gorilla
https://github.com/pink-gorilla/python-gorilla/blob/master/README.md

I ported a matplotlib renderer (stolen from @gigasquid) (alpha). This is not
relevant to your 3 demo notebooks; it effects the libpythonclj demo notebooks.

I ported your html and vega render functions.

Note I used a dev snapshot version for notebook dependency; will switch this to clojar
version tomorrow.

https://github.com/pink-gorilla/python-gorilla/blob/master/resources/notebooks/panthera-basic-concepts.cljg
https://github.com/pink-gorilla/python-gorilla/blob/master/resources/notebooks/panthera-intro.cljg
https://github.com/pink-gorilla/python-gorilla/blob/master/resources/notebooks/panthera-objects.cljg

I added the pokemon data.

Pinkgorilla can load public notebook indices via a central database; so my plan
would be to move this notebooks back to your repo, when everything works fine,
and then start adding your github user into the index of public notebooks.

FYI: Pinkgorilla has 3 ways of triggering renderers:

^:R this means render as reagent, using already loaded renderers that have :p/xxx
schema; so typically ^:R [:p/vega ...] or ^:R [:p/phtml ...] or ^:R [p:/text ...]
You can do arbitrary hiccup, so say ^:R [:div [:h1 "pokemon distribution"] [:p/vega ...]]

You can implement Renderable for a type. This is needed say for Images or other stuff
that does not have a representation on cljs. It is being used for all clojure core datatypes.

You can do ^{:p/render-as :p/vega} so you dont need to wrap the payload in another wrappper;
this is experimental.

On the html output - perhaps we can finetune the css for them? Do you know anything about that?

Any other visualizers that would make sense for panthera?

In terms of libpythonclj init - this is a very important. Ithink we will be able to extend the
pinkgorilla secret management, so we can allow custom environments. In the notebook
context I also think we need shutdown routines. So that an old session from another
notebook will not effect the eval on a different notebook.

In terms of tech.ml and libpythonclj: I think I solved the issues we had with the notebook
after chatting with chris Nuernberger: we now require:
[net.java.dev.jna/jna "5.2.0"]
[org.ow2.asm/asm "7.0"]

This two dependencies have fucked up core.async and hawk (filesystem change notifications).
For whatever reason libpython only works with this very recent dependencies.

Any other ideas / wishes from your side?

Best Regards
@awb99

@awb99
Copy link
Author

awb99 commented Apr 29, 2020

I have not yet refactored everything in your notebooks. Stopped short of adding the python
init code to the 3 notebooks.

For now for our testing it makes sense to keep this notebooks together here, as this is how
we are fixing all the bugs. But in the future I do not want to have responsibility to maintain
this notebook demos; this is much better suited to be done at the library level, as we will never
know when there are new features / better demos / etc.

I gave you maintainer access to python-gorilla in any case.

Let me know if you want to talk about this; I am available on phone / whatsapp / slack / zulip / telegram / etc.

@awb99
Copy link
Author

awb99 commented Apr 29, 2020

In regards to the maplotlib wrappers. I believe we have to wrap the require-python inside a function,
so they dont create a session at namespace include time. But perhaps there is more that has to be done to make it production ready.

@alanmarazzi
Copy link
Owner

I have not yet refactored everything in your notebooks. Stopped short of adding the python
init code to the 3 notebooks.

If libpython-clj is there Python should start anyway, whether you call it or not

For now for our testing it makes sense to keep this notebooks together here, as this is how
we are fixing all the bugs. But in the future I do not want to have responsibility to maintain
this notebook demos; this is much better suited to be done at the library level, as we will never
know when there are new features / better demos / etc.

I understand and I agree, but either I'll be able to substitute Jupyter with pink-gorilla, or I won't be able to support both environments.

In regards to the maplotlib wrappers. I believe we have to wrap the require-python inside a function,
so they dont create a session at namespace include time. But perhaps there is more that has to be > done to make it production ready.

This is about libpython-clj, not panthera.

Any other ideas / wishes from your side?

Mostly a "fast path" (something like a one-liner, a container, etc) to get a notebook ready on my browser: lein pink-gorilla my-notebook.cljg for example.

@awb99
Copy link
Author

awb99 commented May 6, 2020

Thanks Alan for your feedback - very interesting!!!

fast-path: Great idea! I completely forgot about that. So I made:
https://github.com/pink-gorilla/lein-pinkgorilla

lein pinkgorilla

runs notebook app; it can be configured to add directories to the
notebook explorer; example : https://github.com/pink-gorilla/trateg/blob/master/project.clj

cannot support both environments
I understand - thanks for mentioning.
lein-pinkgorilla can do notebook conversion.

lein nbconvert demo.ipynb

The notebook conversion currently does not evaluate the notebook (and therefore no output is saved into the notebook. I hope we will have auto eval in the near future. And then you
could generate gorilla notebooks as part of your build system. hahaha Perhaps this is
already too crazy...

Perhaps we can also add gorilla ui visualizations to clojupyter. I started a zulip thread on this.

If you have further feedback on lein-pinkgorilla, thst would be great. I see what we have now as just a start.

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

No branches or pull requests

2 participants