[x3d-public] jupyter notebook

Andreas Plesch andreasplesch at gmail.com
Wed May 22 05:07:51 PDT 2019


Hi John,

X_ITE needs an additional X3DCanvas element wrapper:

http://create3000.de/x_ite/getting-started/

And the x3d in a file.

You could write the xml to a file in jupyter with python. But then the
file probably also needs to be served by a HTTP server. Since jupyter
is already served (even locally) to allow for the web interface,
perhaps it works to just point to the file as a relative url, as in
the example on the x_ite web page.

With my x_ite_dom js bridge, it may work the same as with x3dom.

-Andreas

On Wed, May 22, 2019 at 4:37 AM John Carlson <yottzumm at gmail.com> wrote:
>
> It would be good to test Script nodes in X3DPSAIL output, but I think that means X_ITE instead of X3DOM.
>
>
>
> Will that be as easy as tacking on different JS and CSS elements?
>
>
>
> John
>
>
>
> Sent from Mail for Windows 10
>
>
>
> From: Andreas Plesch
> Sent: Tuesday, May 21, 2019 3:16 PM
> To: John Carlson
> Cc: X3D Graphics public mailing list
> Subject: Re: [x3d-public] jupyter notebook
>
>
>
> I learned a little more about jupyterlab and mybinder.org.
>
>
>
> https://mybinder.org/v2/gh/andreasplesch/conda/master/?urlpath=lab/tree/sphere.ipynb
>
>
>
> gives you now the full jupyterlab interface. I also added a second
>
> scene which is modified from the first scene by using a global
>
> material cell.
>
>
>
> I was also thinking about animation, eg. updating an existing output
>
> but this seems to be not a very common jupyter notebook mode anyways.
>
>
>
> But it would be a challenging next step to have an python interface to
>
> the generated DOM, or the live content in a X3D browser for true scene
>
> access.
>
>
>
> For the way mybinder works with cached docker images on the server,
>
> the jar size may not be that critical. It all stays on the server. It
>
> just may take little longer to pull the prebuild docker image onto the
>
> server but the image is probably pretty large anyways.
>
>
>
> It still feels pretty heavy to have to use a 40MB jar plus pyjnius.
>
>
>
> Unfortunately, I am not familiar with anaconda packages. I guess the
>
> target is a package with Pyjnius as an (automatic?) dependency, which
>
> includes X3DJSAIL.jar and the autoclass generation python. Anaconda
>
> has channels, so if conda-forge does not accept such a package, one
>
> could perhaps find another channel or make one.
>
>
>
> Let me see, I saw somewhere an example on how to include a jar in a
>
> conda package ...
>
>
>
> https://github.com/conda-forge/conda-forge.github.io/issues/590 is
>
> what you tried, and you got a recommendation.
>
>
>
> Looks like https://pypi.org/project/scyjava/ is the way to go.
>
>
>
> https://github.com/andreasplesch/conda was just a quick way to try
>
> mybinder.org since that works with github repos. I learned that
>
> Mybinder.org is an instance of a BinderHub which can be created
>
> anywhere. Binder is mostly about automatically creating docker images
>
> for jupyterlab with any additional requirements/software necessary. So
>
> one could just have a local BinderHub.
>
>
>
> "My" docker image boils down to just providing a simple
>
> environment.yml (which just specifies pyjnius as a required conda
>
> package) and X3DJSAIL in a place where it can be found (root). For any
>
> other python notebook it is likely that other conda packages are
>
> required in addition, although I think the default docker image
>
> already has the most popular ones preconfigured.
>
>
>
> One can just clone the repo, and go from there.
>
>
>
> Looking up how to generate conda packages:
>
>
>
> https://conda.io/projects/conda-build/en/latest/concepts/recipe.html
>
> https://github.com/conda/conda-recipes
>
> https://conda.io/projects/conda-build/en/latest/resources/define-metadata.html
>
>
>
> conda-forge has its own system on top of recipes:
>
>
>
> https://conda-forge.org/docs/maintainer/updating_pkgs.html#maintaining-pkgs
>
> https://github.com/conda-forge/pyjnius-feedstock
>
>
>
> There would need to be a maintainer.
>
>
>
> -Andreas
>
>
>
>
>
> On Tue, May 21, 2019 at 2:05 PM John Carlson <yottzumm at gmail.com> wrote:
>
> >
>
> > Yeah, that jar in the X3DJSAIL repo is ancient, and not kept up-to-date.
>
> >
>
> >
>
> >
>
> > The one here is 2 months old:
>
> >
>
> >
>
> >
>
> > https://github.com/coderextreme/pythonSAI
>
> >
>
> >
>
> >
>
> > You can build your own X3DJSAIL with this repository, if you like something simple:
>
> >
>
> >
>
> >
>
> > https://github.com/coderextreme/JavaSceneAuthoringInterfaceLibrary
>
> >
>
> >
>
> >
>
> > But it’s not a “fat” jar.  For that, you need Don’s build of the full jar below, or from Don’s X3DJSAIL web page.
>
> >
>
> >
>
> >
>
> > Otherwise, you have to use the ant target create.X3DJSAIL in www.web3d.org/x3d/stylesheets/ (sourceforge download). Jars are found in java/jars below that.
>
> >
>
> >
>
> >
>
> > I’ve been seduced by the dark-side, Don and X3DJSAIL, and have not been maintaining my projects.  X3DPSAIL is a happy medium, and now thanks to you, a nearly publishable medium.
>
> >
>
> >
>
> >
>
> > Are you by chance, working on a Anaconda package so we can import x3dpsail (the first script on your page) into jupyter?  I have a way to generate python application scripts (second script on page) with leading x3dpsail. in front of the constructor calls.   This is to reduce namespace pollution.  Do we just need to install https://github.com/andreasplesch/conda?  Could you provide instructions on how to install  into our own docker or jupyter enviroments?  Looks like https://mybinder.org/ leads the way. Or do you want to support everyone’s development with your docker?  …could get kind of crowded.  I think the best solution is to create a conda package for x3dpysail which includes the python and the jar.  I saw one issue on it, but it was VERY long, and closed, so I assume there’s documentation on how to include a jar in a conda package somewhere, just not sure where yet.
>
> >
>
> >
>
> >
>
> > John
>
> >
>
> >
>
> >
>
> > Sent from Mail for Windows 10
>
> >
>
> >
>
> >
>
> > From: Andreas Plesch
>
> > Sent: Tuesday, May 21, 2019 11:10 AM
>
> > To: John Carlson
>
> > Cc: X3D Graphics public mailing list
>
> > Subject: Re: [x3d-public] jupyter notebook
>
> >
>
> >
>
> >
>
> > Hi John,
>
> >
>
> >
>
> >
>
> > thanks for the quick response. I had provided an older X3DJSAIL.jar
>
> >
>
> > from https://github.com/coderextreme/X3DJSAIL which had the advantage
>
> >
>
> > of being small.
>
> >
>
> >
>
> >
>
> > Now, that I found the more up to date
>
> >
>
> > http://www.web3d.org/specifications/java/jars/X3DJSAIL.3.3.full.jar
>
> >
>
> > and use that instead, things start to work (!). [Most links to the jar
>
> >
>
> > on the page need to be updated].
>
> >
>
> >
>
> >
>
> > Try again, the same link:
>
> >
>
> > https://mybinder.org/v2/gh/andreasplesch/conda/master?filepath=sphere.ipynb
>
> >
>
> >
>
> >
>
> > The errors are gone when you execute the cells.
>
> >
>
> >
>
> >
>
> > The generated xml looks good.
>
> >
>
> >
>
> >
>
> > But the IPython.display HTML function does not display anything. Does
>
> >
>
> > that work locally for you ? HTML(data='<h1>Title</h1>') works. Maybe
>
> >
>
> > an iframe is necessary.
>
> >
>
> >
>
> >
>
> > -Andreas
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > On Tue, May 21, 2019 at 11:20 AM John Carlson <yottzumm at gmail.com> wrote:
>
> >
>
> > >
>
> >
>
> > > Hi Andreas.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Summary:  I don’t think the X3DJSAIL .jar was found in .
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I tried a very similar script to yours, putting the jar in the home folder.  I suspect that you don’t have access to your home folder, or the jar was uploaded as unreadable. Once I put my X3DJSAIL.3.3.full.jar in my local environment home, the classpath started working.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I tried without the jar in place, and got similar issues with PointProperties.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I tried running your remote jupyter and got similar results.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I suspect readability issues or something configured with your classpath/jar.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > We need to get the jar into the x3dpsail conda package, I think.  An unsolved problem.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > It should run okay with a local anaconda.  I realize you want to run remote.  We understand, and will attempt to deliver a conda package in the next month or so.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > If you would like to help, we’re working on creating an x3dpsail package which includes all dependencies.  We have the start of a pip package, but so far, it won’t upload.   A Jupyter conda package is probably more acceptable to most people.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > It might be instructive to issue the first script with a single Java class, to see if it can find one Java class.  That will direct you to the smoking gun.  If it can’t load one class, then the classpath isn’t working.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > If you set a CLASSPATH environmental variable (java’s classpath) in your docker image, it might work better, give it a try. I am staying away from docker for now.   Ensure that OpenJDK or similar is deployed with jnius.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Conclusion:
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > X3dpsail has been shown to work with an absolute path or the jar on a local system.  Try to use an absolute path in conda in the short term (within your sandbox), until we get a conda package for x3dpsail.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > John
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Sent from Mail for Windows 10
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > From: Andreas Plesch
>
> >
>
> > > Sent: Tuesday, May 21, 2019 9:22 AM
>
> >
>
> > > To: X3D Graphics public mailing list
>
> >
>
> > > Subject: [x3d-public] jupyter notebook
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Hi John,
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I was curious and gave Pyjnius+X3DJSAIL.3.3 from your repo a try with
>
> >
>
> > >
>
> >
>
> > > your sphere.ipynb, using online jupyter with mybinder.org:
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > https://github.com/andreasplesch/conda
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Use this link
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > https://mybinder.org/v2/gh/andreasplesch/conda/master?filepath=sphere.ipynb
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > and wait until the server starts with the mybinder built docker image
>
> >
>
> > >
>
> >
>
> > > (takes a bit).
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Executing then the first cell with all the autoclass generation does
>
> >
>
> > >
>
> >
>
> > > something until there is an error:
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > JavaException                             Traceback (most recent call last)
>
> >
>
> > >
>
> >
>
> > > <ipython-input-1-149e86182885> in <module>
>
> >
>
> > >
>
> >
>
> > >      87 HAnimHumanoid =
>
> >
>
> > >
>
> >
>
> > > autoclass('org.web3d.x3d.jsail.HAnim.HAnimHumanoidObject')
>
> >
>
> > >
>
> >
>
> > >      88 HAnimJoint = autoclass('org.web3d.x3d.jsail.HAnim.HAnimJointObject')
>
> >
>
> > >
>
> >
>
> > > ---> 89 HAnimMotion = autoclass('org.web3d.x3d.jsail.HAnim.HAnimMotionObject')
>
> >
>
> > >
>
> >
>
> > >      90 HAnimSegment = autoclass('org.web3d.x3d.jsail.HAnim.HAnimSegmentObject')
>
> >
>
> > >
>
> >
>
> > >      91 HAnimSite = autoclass('org.web3d.x3d.jsail.HAnim.HAnimSiteObject')
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > /srv/conda/envs/notebook/lib/python3.7/site-packages/jnius/reflect.py
>
> >
>
> > >
>
> >
>
> > > in autoclass(clsname)
>
> >
>
> > >
>
> >
>
> > >     157
>
> >
>
> > >
>
> >
>
> > >     158     # c = Class.forName(clsname)
>
> >
>
> > >
>
> >
>
> > > --> 159     c = find_javaclass(clsname)
>
> >
>
> > >
>
> >
>
> > >     160     if c is None:
>
> >
>
> > >
>
> >
>
> > >     161         raise Exception('Java class {0} not found'.format(c))
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > jnius/jnius_export_func.pxi in jnius.find_javaclass()
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > JavaException: Class not found b'org/web3d/x3d/jsail/HAnim/HAnimMotionObject'
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > The good news is that the online jupyter notebook seems to work in
>
> >
>
> > >
>
> >
>
> > > principle, eg. Pyjnius and java is installed, and the X3DJSAIL.3.3.jar
>
> >
>
> > >
>
> >
>
> > > seems to be found as well.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Have you seen problems with the HAnimMotion before ?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Commenting out HAnimMotion, uncovers similar errors for PointProperties and X3D.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > JavaException                             Traceback (most recent call last)
>
> >
>
> > >
>
> >
>
> > > <ipython-input-1-f7be65079716> in <module>
>
> >
>
> > >
>
> >
>
> > >     255 Scene = autoclass('org.web3d.x3d.jsail.Core.SceneObject')
>
> >
>
> > >
>
> >
>
> > >     256 unit = autoclass('org.web3d.x3d.jsail.Core.unitObject')
>
> >
>
> > >
>
> >
>
> > > --> 257 X3D = autoclass('org.web3d.x3d.jsail.Core.X3DObject')
>
> >
>
> > >
>
> >
>
> > >     258 SFBool = autoclass('org.web3d.x3d.jsail.fields.SFBoolObject')
>
> >
>
> > >
>
> >
>
> > >     259 MFBool = autoclass('org.web3d.x3d.jsail.fields.MFBoolObject')
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > /srv/conda/envs/notebook/lib/python3.7/site-packages/jnius/reflect.py
>
> >
>
> > >
>
> >
>
> > > in autoclass(clsname)
>
> >
>
> > >
>
> >
>
> > >     157
>
> >
>
> > >
>
> >
>
> > >     158     # c = Class.forName(clsname)
>
> >
>
> > >
>
> >
>
> > > --> 159     c = find_javaclass(clsname)
>
> >
>
> > >
>
> >
>
> > >     160     if c is None:
>
> >
>
> > >
>
> >
>
> > >     161         raise Exception('Java class {0} not found'.format(c))
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > jnius/jnius_export_func.pxi in jnius.find_javaclass()
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > JavaException: Class not found b'org/web3d/x3d/jsail/Core/X3DObject'
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Is there another Pyjnius or X3DJSAIL.jar to try ?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Pyjnius is installed with conda and a pyjnius line in environment.yml.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > -Andreas
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > --
>
> >
>
> > >
>
> >
>
> > > Andreas Plesch
>
> >
>
> > >
>
> >
>
> > > Waltham, MA 02453
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > _______________________________________________
>
> >
>
> > >
>
> >
>
> > > x3d-public mailing list
>
> >
>
> > >
>
> >
>
> > > x3d-public at web3d.org
>
> >
>
> > >
>
> >
>
> > > http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > Andreas Plesch
>
> >
>
> > Waltham, MA 02453
>
> >
>
> >
>
>
>
>
>
>
>
> --
>
> Andreas Plesch
>
> Waltham, MA 02453
>
>



-- 
Andreas Plesch
Waltham, MA 02453



More information about the x3d-public mailing list