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

add parameter to Worker Constructor? #1

Closed
DerThorsten opened this issue Oct 11, 2021 · 9 comments
Closed

add parameter to Worker Constructor? #1

DerThorsten opened this issue Oct 11, 2021 · 9 comments

Comments

@DerThorsten
Copy link
Collaborator

Within the worker.ts we import the kernel specific js file (here it is still xeus_lua.js)
https://github.com/jupyterlite/xeus-kernel/blob/ded2690d2a0a706dfa3b7dc2608cf41a5a57429e/src/worker.ts#L3
The question is, can we pass the actual import to the constructor here https://github.com/jupyterlite/xeus-kernel/blob/ded2690d2a0a706dfa3b7dc2608cf41a5a57429e/src/xeus_server_kernel.ts#L20
or do we need to send the import statement as a message to the worker?

I would like to avoid sending the actual import path (like xeus_lua.js / xeus_wren.js) to the worker via message and would prefer if that could be done at construction time of the worker, if possible.

@jtpio any suggestions =)

@jtpio
Copy link
Member

jtpio commented Oct 11, 2021

One way could have been to use dynamic imports:

const createXeusModule = await import(urlToXeusJsFile);

But looks like it might not work from within a worker on Firefox: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility

@DerThorsten
Copy link
Collaborator Author

But even with dynamic imports, we import the stuff from the worker so we would need to pass urlToXeusJsFile to the worker.
Of course we could do this via postMesage but I would have preferred to pass it somehow via the Worker constructor.

Different suggestion, could we use the same filename for all xeus kernels? The files life in a dedicated folder per extension anyhow, right?

@jtpio
Copy link
Member

jtpio commented Oct 11, 2021

Different suggestion, could we use the same filename for all xeus kernels? The files life in a dedicated folder per extension anyhow, right?

Yes sounds like it would work? Federated extensions live in their own subfolder indeed, for example:

  • /lab/extensions/@jupyterlite/xeus-lua
  • /lab/extensions/@jupyterlite/xeus-wren

Would be two different folders but they both can have a file with the same name. Not sure how it would play if we let webpack handle the bundling later (jupyterlite/xeus-lua-kernel#5), but it's probably not something to worry about for now.

@DerThorsten
Copy link
Collaborator Author

The files already have the same name, ie xeus_kernel.{js,wasm}
https://github.com/jupyterlite/xeus-lua-kernel/blob/f53e035f17066388a6052e94ffde68398d2ab7ef/src/worker.ts#L7

So only the Dockerfile building the xeus_kernel.{js,wasm} files differs from kernel to kernel. (and the name / logo of the kernels)

@jtpio
Copy link
Member

jtpio commented Jan 31, 2022

So only the Dockerfile building the xeus_kernel.{js,wasm} files differs from kernel to kernel. (and the name / logo of the kernels)

👍

@SylvainCorlay
Copy link
Member

So only the Dockerfile building the xeus_kernel.{js,wasm} files differs from kernel to kernel. (and the name / logo of the kernels)

👍 exactly what we should get to.

The current content of xeus_server_kernel could essentially be renamed webworker_kernel.js and moved to the JupyterLite code base.

@jtpio
Copy link
Member

jtpio commented Feb 1, 2022

moved to the JupyterLite code base.

Moved to https://github.com/jupyterlite/xeus-kernel at least as a first step.

There is a chance kernels will be moved out of the main JupyterLite code base (see jupyterlite/jupyterlite#386 for reference), especially since they can be developed as separated federated extensions.

@SylvainCorlay
Copy link
Member

The current content of xeus_server_kernel could essentially be renamed webworker_kernel.js and moved to the JupyterLite code base.

Moved to https://github.com/jupyterlite/xeus-kernel at least as a first step.

But presumaby, it is not about xeus, but about any web worker kernel.

@bollwyvl
Copy link

bollwyvl commented Feb 1, 2022 via email

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

4 participants