Python script node does not visualize the Bokeh library output

I found this earlier discussion which is closed unfortunatelly. When I want to try the example from the bottom of the thread it does not work anymore.

Also to work offline I would like to serve the files offline. Where do you even save the files for KNIME JS to find it?

I guess here but it does not work

AppData\Local\Temp\16\knimeViewContainerxxxxx\org\knime\core

so I cannot even make this code run:

// Function to load CSS file for Bokeh
function loadCss(url) {
    var link = document.createElement("link");
    link.type = "text/css";
    link.rel = "stylesheet";
    link.href = url;
    document.getElementsByTagName("head")[0].appendChild(link);
}

requirejs.config({
    paths: {
        bokeh: "./bokeh-3.2.2.min",
        bokehapi: "./bokeh-api-3.2.2.min" 
    },
    shim: {
        bokeh: {
            exports: "Bokeh"
        }
    }
});

require

(["bokeh", "bokehapi"]);

@domerich welcome to the KNIME forum.

You can use local copies of the necessary bokeh libraries and even automatically load them from the source.

I have edited @st11 example and now send the JSON string via KNIME data stream to the graphic node. My impression was that the FlowVariable might not have enough characters for more complex charts. I also struggled with some binary data that sometimes was stored in the JSON string.

I was not able to properly export the result as a SVG (or PNG) file but you could manually download the data.

A nice experiment. I still would prefer the direct integration of Python graphics from Matplotlib and Seaborn (Create an Interactive Dashboard with KNIME Components and Python | by Markus Lauber | Low Code for Data Science | Medium) over the (for me?) quite complicated implementation via the Generic JavaScript View (JavaScript) – KNIME Community Hub.

kn_example_python_graphic_bokeh_json.knwf (707.3 KB)

2 Likes

Thanks for this. It seems the link download does not work for me. I can store the files manually no problem.

.

It seems your sample upload is different from your screenshots, here we do not use the local files.

@domerich you will have to reset the workflow I would assume.

Then I have included both: the one using the online resources and one example with a local file. Of course you can just put the files in a local folder and reference them with an absolute path. The thing with determining the version automatically is maybe just overenineering.

ok thanks, I think me sitting behind a proxy is the problem. I will try and make it work somehow

1 Like

@domerich the current versions are already in the /data/ folder so you can just use them if they match your bokeh version (3.0.3). I might add a yaml etc. and Environment Propagation to provide a clean setup later.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.