Load prebuilt extension without making node package?


I made a custom glyph (named “Pick”) as part of a python package I’m developing. It works fine when I compile it at runtime, but I’d like to prebuild it and distribute it with the rest of the package. I don’t want to make a node package and put it on NPM, since my extension is small and I don’t need the extra overhead :slight_smile:

I ran bokeh init --interactive and declined to make a package.json or tsconfig.json. I then changed my imports in the typescript for the custom extension to use @bokehjs, and following the Panel guide I modified my index.ts files, removed the __implementation__ attribute on the Python class, and set a __module__ variable on the typescript class. You can see the modifications I made here.

These changes allowed bokeh build to run successfully, but when I run a test script I get a javascript error:

Uncaught (in promise) Error: Model 'ptplot.models.pick.Pick' does not exist. This could be due to a widget or a custom model not being registered before first usage.
    at ModelResolver.get (bokeh-2.3.3.js:1359)
    at Function._instantiate_object (bokeh-2.3.3.js:872)
    at Function._instantiate_references_json (bokeh-2.3.3.js:887)
    at Function.from_json (bokeh-2.3.3.js:1130)
    at _embed_items (bokeh-2.3.3.js:566)
    at Object.embed_items (bokeh-2.3.3.js:558)

Looking at the Chrome inspector my extension is getting registered, but the problem seems to be that it’s getting registered as "Pick" (_all_models.get("Pick") returns the right thing) rather than "ptplot.models.pick.Pick" which is what Bokeh uses as the default location for a Model.

Is there any way I can either register my extension as “ptplot.models.pick.Pick”, or change the Python implementation to look for the JS as “Pick”? Or is this not the right way to go about doing this? Any advice would be appreciated. Thanks!


In case it helps I’ve put together a repo that just contains the code and instructions needed to repro this problem.


@rook the best person to help with this may not see it here. For this specific topic I’d suggest making a GitHub development discussion

Thanks @Bryan! I posted it here in case someone else has the same problem and stumbles across this thread.

1 Like

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