Jupyter ❤️ FreeCAD

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
SylvainCorlay
Posts: 6
Joined: Fri Aug 14, 2020 12:40 pm

Jupyter ❤️ FreeCAD

Post by SylvainCorlay »

Hello there,

Jupyter developer here. Our team at QuantStack has been working for some time on a few things that may really be of interest for folks in the FreeCAD community and we would love to engage with you and show some of the recent developments.

Possible discussion items include:

- streamlining the use of in-process Jupyter kernels in desktop applications based on Qt. (I know there has been some interest in this subject and even a GSOC project) cc @looo @kryptokommunist
- edition of FreeCAD models in a Jupyter-based UI - and collaborative editing on 3-D models.

What would be a good way to engage with interested FreeCAD developers? We would love to have a call and demo showing where we are going.

Best,
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Jupyter ❤️ FreeCAD

Post by onekk »

Some time ago there were some discussion about internal editor improvements.

From what I know Jupyter is not an editor but has editor like abilities.

One of the most challenging things is due to the fact that most used way to have FreeCADvis to use AppImage on Linux, and is not so easy to use an external editor that could retrieve the "temporary directory expanded" tree of "FreeCAD Python" to an external IDE.

As distribution are not updating very often FreeCAD versions this is a common problem for many users.

Same will be as you must match Python versions between FreeCAD and the external Python interpreter if you intend to use "FreeCAD" as a Library, in other word executing FreeCAD code in an external Python interpreter using.

Code: Select all

import FreeCAD
import FreeCADGui

import Part



and similar.

It will be a great things if some of these problems could eased, but I don't know how Jupyter is working, as I've done some experiments with it some years ago.

If I rembeber correctly Jupyter could use different version of the Python Interpreter so it could be used even if the "system installed" Python has not the same version of the "FreeCAD Python version"?

As part of FreeCAD is using Python internally this version mismatch could be create subtle problems and mixed results.

@wmayer is lacking from you mention list. He probably have more in depth clues about a possible use of Jupyter in FreeCAD.

Sorry if this is a very generic answer, but I'm thinking with an user point of view.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Jupyter ❤️ FreeCAD

Post by heda »

wow, if anyone can bring jupyter closer to fc it is you guys.
imho, this is a call that has to be supported!
can't get better than this...
people that really can move the needle on jupyter has just knocked on the door,
so let's open it and greet with open arms.

sounds like you already have poc, or are ready to make one?

these things are way above my pay-grade,
but care to explain a bit more on what is different this time in terms of "technology"?

in-process jupyter kernel.

so, attaching a jk to an already running qt-fc?
or a jk starting and governing a qt-fc?

or just making it simpler to have a future option to use a jpy-qt console?
as option within fc (like a drop-in for current py-console)

to your second point.
so, basically a jupyter-lab? plug-in, that would then be the gui.
talking to fc-cmd or fc-gui (or a "new" middle-ware would be needed, or are we truly talking a fc-jupyter instead of a fc-cmd - so many questions...)?
in such case, how would it show up in a notebook?
what are the thoughts on rendering engine for the 3d part in this case?

can imagine that if the infra structure of making a gui in j-lab is there (and working),
evenso just opening a file, people will over time port functionality piece by piece.

on the colab thingy, is that virtually for free if you manage to run fc
as a j-lab plug-in (assuming one is running j-colab server)?

@chennes or @uwestoehr should be able to hook you up to a dev-meeting

in any case, this is a potential massive thing which I assume
will take some time to just take in what is potentially possible,
and how to support it best possible.

in any case, a bit more meat on the bone of what type of doors
you are potentially about to unlock would be highly appreciated.
imho dissertating that in this thread will work just fine.

finally just want to say as response to title
everyone ❤️ jupyter
User avatar
chennes
Veteran
Posts: 3882
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Jupyter ❤️ FreeCAD

Post by chennes »

SylvainCorlay wrote: Fri Mar 10, 2023 1:18 pm What would be a good way to engage with interested FreeCAD developers?
Most FreeCAD developers stop by the forums on a relatively regular basis, so simply posting here is a pretty good start. We don't (yet!) have scheduled developer telecons, though the FreeCAD Project Association (FPA) is planning on starting something like that up. So I'd say your best bet right now is to post some details about what you have in mind, and see if we can arrange an ad hoc meetup for those who are interested. I'll bring it up at the FPA admin team meeting on Monday as well.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
SylvainCorlay
Posts: 6
Joined: Fri Aug 14, 2020 12:40 pm

Re: Jupyter ❤️ FreeCAD

Post by SylvainCorlay »

heda wrote: Sat Mar 11, 2023 6:46 am wow, if anyone can bring jupyter closer to fc it is you guys.
imho, this is a call that has to be supported!

can't get better than this...
people that really can move the needle on jupyter has just knocked on the door,
so let's open it and greet with open arms.
Thanks for the warm welcome!
heda wrote: Sat Mar 11, 2023 6:46 am sounds like you already have poc, or are ready to make one?

these things are way above my pay-grade,
but care to explain a bit more on what is different this time in terms of "technology"?
Indeed, we have some POCs!

heda wrote: Sat Mar 11, 2023 6:46 am in-process jupyter kernel.

so, attaching a jk to an already running qt-fc?
or a jk starting and governing a qt-fc?

or just making it simpler to have a future option to use a jpy-qt console?
as option within fc (like a drop-in for current py-console)
We have worked on Jupyter kernels that integrate in the Qt event loops and run in-process of Qt applications. Jupyter clients (like JupyterLab or the notebook) can connect to it externally, but could be embedded in the application.

heda wrote: Sat Mar 11, 2023 6:46 am to your second point.
so, basically a jupyter-lab? plug-in, that would then be the gui.
talking to fc-cmd or fc-gui (or a "new" middle-ware would be needed, or are we truly talking a fc-jupyter instead of a fc-cmd - so many questions...)?
in such case, how would it show up in a notebook?
what are the thoughts on rendering engine for the 3d part in this case?

can imagine that if the infra structure of making a gui in j-lab is there (and working),
evenso just opening a file, people will over time port functionality piece by piece.

on the colab thingy, is that virtually for free if you manage to run fc
as a j-lab plug-in (assuming one is running j-colab server)?
Our POC is indeed a JupyterLab plugin. Collaborative editing is based on CRDTs to do automatic conflict resolution.

heda wrote: Sat Mar 11, 2023 6:46 am @chennes or @uwestoehr should be able to hook you up to a dev-meeting

in any case, this is a potential massive thing which I assume
will take some time to just take in what is potentially possible,
and how to support it best possible.

in any case, a bit more meat on the bone of what type of doors
you are potentially about to unlock would be highly appreciated.
imho dissertating that in this thread will work just fine.

finally just want to say as response to title
everyone loves jupyter
We would love to meet over a dev meeting if there is a possibility!
SylvainCorlay
Posts: 6
Joined: Fri Aug 14, 2020 12:40 pm

Re: Jupyter ❤️ FreeCAD

Post by SylvainCorlay »

Image
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Jupyter ❤️ FreeCAD

Post by heda »

got the vibes you already had something up an running,
and indeed you do, with vastly different "technology" compared to earlier attempts (afaikt).

so, it's official then - it is now possible to run fc in a browser,
through jupyter eco-system and in colab mode judging from the picture

could be a gamechanger for academia & sme adoption of fc.

i am stumped - simply brilliant & hat off from my side.

cannot do much to get a dev onboard, but hope at least some one from
that crowd engages at some point in time.

meanwhile, maybe post instructions of how to get at least a local
version running on a box.
plenty of people around here that are versed in getting various
constellations of pre-alpha-sw up and running with minimal
instructions - so this way you ought to be able to
lure in some brave early testers


am i getting it right in that it will run as an "isolated" app in j-lab,
like for example a text editor?
i assume that since one is running a j-kernel, that one can also handle a notebook.
or phrased differently, is it now possible to use a notebook in j-lab as fc py-ide?
and it will work seamlessly?
maybe even j-lab debugger will work (fingers crossed) - that would be a gamechanger on it's own...

are there changes to fc core/app code-base to make this happen?
(not obvious yet to me, a mere amateur hobbyist, that it has to be if all you are doing is to "inject" yourself into qt eventloop, sounds like it is at least hypothetically possible to do all needed intermediating outside of fc core...)

btw, how is speed perception? or fps for that matter.
martinRenou
Posts: 2
Joined: Tue Mar 14, 2023 10:07 am
Contact:

Re: Jupyter ❤️ FreeCAD

Post by martinRenou »

Hello!

I'm one of the QuantStack devs who has been working on the JupyterCAD extension :) This extension is our solution for the second item Sylvain mentioned in the top message "edition of FreeCAD models in a Jupyter-based UI - and collaborative editing on 3-D models."

You can find the extension here: https://github.com/QuantStack/jupytercad with some installation instruction. You would basically need FreeCAD and JupyterLab 4 (which is not officially out yet), then a pip install of jupytercad would get you started. It's still very experimental.
am i getting it right in that it will run as an "isolated" app in j-lab,
like for example a text editor?
Yes, it's basically a fcstd file editor in JupyterLab, parallel to the text and notebook file editors. But not only!
is it now possible to use a notebook in j-lab as fc py-ide? [...] maybe even j-lab debugger will work (fingers crossed)
We've been working on making it possible to also open the fcstd files from a Notebook https://github.com/QuantStack/jupytercad/pull/102 and collaborative features would work seamlessly between someone who opened the file from the fcstd file editor and someone who opened it from the Notebook. And because you're running in the Notebook you should be able to use the debugger indeed.
are there changes to fc core/app code-base to make this happen?
We've been testing our extension with FreeCAD 0.20.2. But it would indeed be convenient to make some changes in FreeCAD to make it easier for us.

One of the main issue I see currently is that the FreeCAD Python API would not expose any ViewObject information if not running a Qt application (which we don't want to do, as freecad would run on the server). We rely on the OfflineRenderingUtils module https://github.com/FreeCAD/FreeCAD/blob ... ngUtils.py for loading the colors and visibility information, but we are missing information about the tree structure of the file (I sent an hopeful message on viewtopic.php?p=667278#p667278).
Any hint on that last point would be greatly appreciated! I'd be happy to start contributing to FreeCAD but would need a bit of guidance.
that it has to be if all you are doing is to "inject" yourself into qt eventloop
We're not integrating with a qt eventloop. We use freecad's Python API for loading the files, then our extension on the Jupyter front-end handles the rendering. Note that we use a WASM compiled OpenCascade for actually computing the shapes in the web page, then they are rendered with ThreeJS.
btw, how is speed perception? or fps for that matter
We're using ThreeJS, so we are bound to the WebGL performance -> performance is getting better years after years, but WebGL is not yet close to desktop app 3D rendering.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Jupyter ❤️ FreeCAD

Post by yorik »

This is really thrilling!
I think staying out of Qt is the right move. The real 'gist' of the ViewObject is to provide shape-to-coin translation, and user interaction. For the former, in case you relytonethe coin nodes, there are many other possible methods (but thinking out loud, the code that does that in FreeCAD could actually maybe be separated and used independently?), and for the latter, I guess there is not much sense in reusing any of that in Jupyter anyway.
User avatar
iplayfast
Posts: 256
Joined: Sat Sep 07, 2019 6:55 am

Re: Jupyter ❤️ FreeCAD

Post by iplayfast »

I wonder if you could integrate openscad and freecad through jupyter?
Post Reply