Have been optimizing my Kotlin notebooks to run be...
# datascience
p
Have been optimizing my Kotlin notebooks to run better on public (low powered) infra like MyBinder. And been happy with the progress so far. One thing I’m not yet be able to fixed is how to include my own javascript file. Seems only options are to specify a local file or a URL (CDN). But problem with local file is that all the JavaScript get included in the notebook itself. Is it possible to reference a JavaScript file via and URL that is then served by the Kotlin Kernel ? You can check the progress out at: https://mybinder.org/v2/gh/neurallayer/roboquant-notebook/main?urlpath=tree/notebooks/ and for example try the charts notebook.
a
Kotlin kernel serves content via ZMQ. You can create additional HTTP server like we do in Plotly-kt and VisionForge, but you can't serve JS through it because Chrome policy forbids cross-origin script loading. All scripts seved through Jupyter must be either embedded or loaded via Jupyter plugin.
Currently it is the main pain point for Jupyter plugin development. I wonder if it would be possible to communicate with Jupyter team to solve that.
By the way, binder is not Jupyter, so maybe it is possible to dynamically load scripts there.
You can use CDN though. The builder I made allows to do that
message has been deleted
p
Thanks, I guess have to live with the restriction for now. I used also CDN in the past, challenge is I have then have to host it separately on some public CDN. But perhaps worthwhile the effort. BTW, I use a docker image for binder, so it is actually plain Jupyter.
You use classPath and url? I thought you only should use one of the two (or are these different files) ?
a
I created it for example, but you can use both. So one is fallback for another (if you are offline - use classpath, if url is accusable - use it).
Check
url
method reference
p
That is good to know, thanks!!!
@altavir played a bit with the resource loading code and noticed there is a check if using classPath loading:
Copy code
private fun checkClassPath(classPath: String) {
            if (javaClass.getResource(classPath) == null) {
                Logger.getLogger("JupyterIntegration").warning("A resource with classpath '$classPath' not found.")
            }
}
This always fails in my case and generates a warning (although the rest of the code still loads the resource, so only the check seems to be wrong). Possible this is the wrong code to execute because I think it only should succeed if the resource is part of the ResourcesBuilder module, and typically it is not.
a
I think PR would be welcome. I can do it myself, but I don't know when I can do that and my GitHub account is still banned.
p
Will have a look at it.