interactive icon indicating copy to clipboard operation
interactive copied to clipboard

NotebookScope, getVariable no longer available

Open PawelStadnicki opened this issue 3 years ago • 7 comments

I noticed that interactive variable in JS now has only configureRequire when notebookscope and getVariables disappeared. I know that I can use #!share #!value instead but would like to understand the reason for that.

I personaly preferred the first option as in some of my solutions I just translate js to F# under the cover and it is easier for me to use js instead of magic commands.

Btw, how to achieve now the following:

interactive.javascript.submitCode(command);

It is deep in the loop of code so #!share/#!value will most likely not work

PawelStadnicki avatar Jan 03 '22 07:01 PawelStadnicki

The goal for this change was 1) to make #!share work consistently in all languages and 2) make the JavaScript variable sharing API consistent with other languages by using commands and events, which removed the requirement of having an HTTP connection to the kernel. I'll find a code sample for how to do this now without that API.

jonsequitur avatar Jan 03 '22 21:01 jonsequitur

cool, I would appreciate a sample of how to read js variable value in C#/F# (my today tries haven't worked)

PawelStadnicki avatar Jan 03 '22 22:01 PawelStadnicki

I'm still trying to figure out how it should work. F# -> JS seems to work , other way not

image

PawelStadnicki avatar Jan 10 '22 08:01 PawelStadnicki

Sharing from JavaScript is still not implemented but there's work in progress on it.

jonsequitur avatar Jan 11 '22 23:01 jonsequitur

I wonder how much work is left/needed to share variables and run code between JS -> .NET as it used to work before the changes. In which area in the repository should it happen so I can take a look? I mean not only the variable sharing that stop working but also an alternative to "interactive.javascript.submitCode"

Almost all my uses cases used that approach for very creative scenarios, as it enables avoiding a lot of static C#/F# constraints (it literally allows a lot of stuff that is forbidden in F# , like using const parameter in JsonTypeProvider: normally you can do it only at module/namespace level and once, but with .NET Interactive not only we can do it anytime, including any function body, but we also can change it anytime).

I can see that C#/Python has a high-impact badge (although it doesn't even exist) and this used to work and has a medium badge.

PawelStadnicki avatar Feb 23 '22 06:02 PawelStadnicki

I've been looking for any notebook, that doesn't need a ton of dependencies in vscode for javascript notebooks.

IMO lack of sharing between different cells in JS is a deal breaker, almost to the point of not seeing why you would use a notebook at all, compared to a .js file.

I've tried and failed to get both Jupyter and a third party JS Notebook to work in vscode. Jupyter I ran into a bunch of python dependency issues installing kernels, (and I'm not a python developer) and in .net interactive I ran into issues with sharing variables.

Perfect for JS would be to treat a single notebook as a single js file, or at least allow them to export stuff that is in global scope similar to node modules or something.

ryantheleach avatar Aug 03 '22 20:08 ryantheleach

IMO lack of sharing between different cells in JS is a deal breaker, almost to the point of not seeing why you would use a notebook at all, compared to a .js file.

Are you referring to lack of sharing between multiple JavaScript cells? This does work, and #!share works both to and from JavaScript.

image

jonsequitur avatar Aug 05 '22 18:08 jonsequitur

These variables were removed 10 months ago, and no one has bothered to update the Javascript sample file(s) linked from the front page to not depend on it? The JavaScript experience is very poor right now, as it is very difficult to find current documentation or examples.

kcaswick avatar Nov 07 '22 21:11 kcaswick

Weird, it might have been a scoping issue / user error on my part. I'll give it a shot the next time I'm working some data, but I'd since moved on.

ryantheleach avatar Nov 10 '22 13:11 ryantheleach