Custom pre-built extension in a package #12301
Replies: 1 comment
-
I've experimented with the structure of a prebuilt custom Bokeh extension in an existing The read me files show how the example package is generated, but for brevity I show it mamba env create --file environment.yml
mamba activate bokeh-[flat|src]-layout
pip install --editable ".[dev]"
cd package
bokeh build
cd ..
jupyter lab When I run the Jupyter notebook for either layout I still get the following JavaScript VM302 bokeh-2.4.3.min.js:166 Uncaught Error: Model
'package.sub_package.bokeh_extensions.extension.Extension' does not exist. This could be
due to a widget or a custom model not being registered before first usage.
at _.get (VM302 bokeh-2.4.3.min.js:166:1015)
at E._instantiate_object (VM302 bokeh-2.4.3.min.js:165:4956)
at E._instantiate_references_json (VM302 bokeh-2.4.3.min.js:165:5144)
at E.from_json (VM302 bokeh-2.4.3.min.js:165:8794)
at t.embed_items_notebook (VM302 bokeh-2.4.3.min.js:591:2451)
at embed_document (<anonymous>:5:20)
at <anonymous>:8:5
at <anonymous>:24:3
at a.renderModel (809.dc36b734dbd5fc902f01.js?v=dc36b734dbd5fc902f01:1:2099) Following the instructions for setting the
Every time I modify the TypeScript file, I rebuild the Bokeh extension, reinstall the Do I need to wrap the custom prebuilt Bokeh extension in a Panel app?
|
Beta Was this translation helpful? Give feedback.
-
This was first posted on the discourse page: https://discourse.bokeh.org/t/custom-pre-built-extension-in-a-package/9450 and bryan asked to place it here in a discussion thread. Thanks again for the help @bryevdv.
The basic need is that: I want to have a custom prebuilt Bokeh extension in an already existing python package, so when users install the Python package, they get the Bokeh extensions for use in Jupyter. I cannot have a user install the Python package, and then install the Bokeh extension in a manner similar to Panel or the JSMol extension (this is a hard requirement that I unfortunately cannot change).
first post from discourse
I have the following skeletal structure to my project, where a custom pre-built Bokeh extension exists in a sub-package of a Python package.
I am getting the following error when I try to use the extension in a notebook, e.g. the nb.ipynb in the notebooks folder. I should note that the package has been locally installed via pip, and bokeh build was run manually in the sub_package folder before trying to have the extension display in the Jupyter notebook.
I’ve come across this error before, when experimenting with the custom Bokeh extension workflow, and the fix was to add the line;
to the TypeScript class named Extension that contains the boilerplate properties,
__view_type__, constructor, this.prototype.default_view
property definitions. I always seem to get the same error when I update the__module__
property definition to anything, and was wondering if there is a path issue I am not properly fixing by modifying the__module__
property since this is a sub-package in a Python package.I should also ask if creating a pre-built custom Bokeh extension in a package, and it not being its own installable package, is a viable solution? An outline of the relevant files for the workflow are below.
I know this is an odd use case, but I was not able to make Python Bokeh apps for use in a notebook as the tools being created in the custom extension had to be written in TypeScript. I’ve combed over the work done by MarcSkovMadsen for inspiration, but I cannot seem to find anyone making custom Bokeh extensions specifically for an existing Python package.
second post from discourse
Here’s a little more info on what I’ve tried, and the results of those attempts.
I tried to work around the
...does not exist.
error and supplied the TypeScript directly to the Python object. I did this by refactoring the following;This required an update to the extension’s TypeScript property as follows.
After these updates, I no longer get the ...does not exist. error, but I get a new one having to deal with the TypeScript compiler. The new error is now;
This only sort of makes sense to me, since I’m supplying the TypeScript directly to the Python object. I’m guessing there is no build step in which the compiler would have been informed that my target in tsconfig.json is es2020. If someone knows for certain, it would be great to have a definitive correct/incorrect response to the following statement:
One should not supply any TypeScript directly to the Python object if creating a pre-compiled Bokeh extension.
If it is a definitive correct, then the statement in the documentation about not having to supply a name property as it gets “filled in” by TypeScript make more sense now.
If the above statement is not definitively correct, then I’m even more lost than before the path error in the original post, and any insights would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions