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

Interest in supporting Kaggle? #3

Open
francesco-ballarin opened this issue Dec 6, 2022 · 2 comments
Open

Interest in supporting Kaggle? #3

francesco-ballarin opened this issue Dec 6, 2022 · 2 comments

Comments

@francesco-ballarin
Copy link

Hi @mhochsteger and @JSchoeberl,
I got in touch with you a few months ago about my FEM on Colab project, which supports NGSolve, including visualization through the webgui.

A few users have asked me if, by reusing the same build system, I could also package the same libraries for usage on Kaggle. With a bit of work, this is now available in the spin-off project FEM on Kaggle.

Kaggle is based on jupyter lab, but does not support additional widgets unless they are hardcoded in their backend (see Kaggle/docker-python#1190). Since on Colab, at least to my understanding, you do not use widgets either, my thought was to patch
https://github.com/CERBSim/webgui_jupyter_widgets/blob/main/webgui_jupyter_widgets/widget.py#L30
changing the bool from False to True while packaging ngsolve for Kaggle, to trick the webgui into thinking that it is on Colab, so that
https://github.com/NGSolve/ngsolve/blob/master/python/webgui.py#L592
https://github.com/NGSolve/netgen/blob/master/python/webgui.py#L238
will follow on both Colab and Kaggle the same flow.

You can find the resulting packages at
https://fem-on-kaggle.github.io/packages.html
and a relevant test at
https://kaggle.com/kernels/welcome?src=https://github.com/fem-on-kaggle/fem-on-kaggle.github.io/blob/gh-pages/tests/ngsolve/test-ngsolve-extras.ipynb

If you run that notebook, at the first Draw(mesh) you will get a plot similar to the following screenshot, where some part of the webgui are shown but the mesh is missing, and the overall formatting is clearly wrong.
Screenshot from 2022-12-06 09-51-30

If you have any interest in supporting Kaggle I would be happy to test future releases of webgui_jupyter_widgets with my packaging workflow.

Cheers,
Francesco

@JSchoeberl
Copy link

JSchoeberl commented Dec 6, 2022 via email

@francesco-ballarin
Copy link
Author

Hi @JSchoeberl

There is kaggle package that one could use in a try...except block, but that is not necessarily a reliable way to check if one is on kaggle because:

  1. it requires the user to store some kaggle credentials in their home (see the very first cell in my test)
  2. it may give a false positive if a user has locally installed the kaggle package from pypi.

In my notebook those two issues are not a big deal, but I would advise against such a try...except block in an actual package like yours.
The easiest way I would suggest instead to check if one is on Kaggle is to see if "KAGGLE_URL_BASE" in os.environ.

I had a quick look - can we check for availability of jupyter - widgets, instead of checking explicitely for colab ?

I am not sure if that would be advisable.
The reasoning in the patch that I currently ship is the following:

  • from pythreejs is installed, but widgets are not shown Kaggle/docker-python#1190, it seem that widgets are indeed supported, but their components need to be hardcoded in kaggle itself, which is probably not something we can achieve.
  • my understanding is that on Colab you just avoid widgets (correct?), and use IPython.display(the html equivalent of the widget), which I had hoped was enough to get webgui_jupyter_widgets working on Kaggle as well.

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