SimonBiggs / scriptedforms

Quickly create live-update GUIs for Python packages using Markdown and simple HTML elements.
Apache License 2.0
508 stars 34 forks source link

Arbitrary Kernels #235

Open ctm22396 opened 6 years ago

ctm22396 commented 6 years ago

Hi, I came across this repo while browsing the jupyterlab-extensions tag and this looks like a great way to extend the developing environment, particularly for quickly mocking up a document for data exploration or sharing analysis results. I am excited to see where this project goes!

I feel that it would be a useful addition to allow users to select a language kernel as they do for a notebook or console from the launcher.

Is this something you are interested in having in scriptedforms; or are you primarily focused on having it run python code?

I notice in kernel.service.ts you have the python3 kernel hardcoded:

function connectToNewSession(serviceManager: ServiceManager, path: string): Promise<Session.ISession> {
  const promiseDelegate = new PromiseDelegate<Session.ISession>();

  const settings = ServerConnection.makeSettings({});
  const startNewOptions = {
    kernelName: 'python3',
    serverSettings: settings,
    path: path
  };
...

Could this instead accept a parameter from the launcher? I apologize if this is oversimplifying, I'm not familiar with how the launcher passes the selected kernel to the notebook or console.

Thanks for putting this together!

SimonBiggs commented 6 years ago

Hi,

Thank you for your interest. I do agree that it would be great to be able to support more kernels.

Unfortunately as it stands ScriptedForms is closely tied to Python. It is much deeper than a hardcoded kernel name unfortunately.

For example, pulling variables from the kernel and keeping them in sync uses the filkowing:

https://github.com/SimonBiggs/scriptedforms/blob/08b6e316d8ee2535af98dd5f97cb9319ee6960ce/scriptedforms/_utilities.py#L107-L153

None of these are insurmountable. But as of yet I am the only developer on this project and I am developing this primarily supporting the use cases required in my work. I would be more than happy to work with someone to help them make it accept another kernel. I won't be supporting other kernels if i remain the only developer. For each kernel required there would need to be specific code written.

One idea is, as it stands, that you could have the kernel that is used to run the code be defined by the language name written after the code fence. I've thought about this in the past. It would mean any variable definition would need to be kept synced between every language. Currently the syncing is happening between Python and JavaScript only. I don't know how big an issue that would be, but it is something that needs thinking about