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

Allow defining notebook values in the Notebook API #206

Closed
altavir opened this issue Apr 28, 2021 · 0 comments · Fixed by #215
Closed

Allow defining notebook values in the Notebook API #206

altavir opened this issue Apr 28, 2021 · 0 comments · Fixed by #215

Comments

@altavir
Copy link
Contributor

altavir commented Apr 28, 2021

I would like to be able to define new global variables/values in the notebook both from library descriptors and the Notebook reflection API.

My current use case is the following: I want to be able to change the properties of the plotly server from inside the notebook. For example, I would like to start it, stop it, and change the port. Ideal way is to write something like this:

%use plotly-server

plotlyServer.stop()
plotlyServer.port  = 22
plotlyServer.start()

In order to do that In should be able to define new properties through the notebook API like fun Builder.define(map: Map<String, Any>) or defineVariable(map: Map<String, Any>).

Current workaround suggested by @ileasile is to define empty variable via script execution:

val conf = execute("val libConf = LibConf(...); libConf").value as LibConf

and then substitute the value via

onVariable<LibConf> { value, prop ->
    prop as KMutableProperty<*>
    // prop.set(..)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants