Cannot see streamlit-drawable-canvas

Hello there,

Just deployed my newest drawable-canvas. The app is loaded correctly but the drawable canvas custom component doesn’t, and the logs don’t show anything specific…

Maybe it only happens to me (and I got it working locally and in a clean Docker Python 3.7 container with and without pinning versions). Can anyone else check on it ?

Thanks a lot!
Fanilo

Hey @andfanilo, looks like the src on your component’s iframe is pointing to localhost:3001 – so it’s probably trying to load the iframe from your local webpack devserver, and just needs to bundled into a release build?

Hi again,

Yeah I thought so too, maybe devserver was still running when I tested, so I republished a new version to Pypi and tested it in a clean environment, I get the correct redirection locally.

So then I thought “what if Streamlit Share, instead of using the installed streamlit_drawable_canvas used the folder streamlit_drawable_canvas because they’re not in order in PYTHON_PATH ?”.

I went to edit the _release=True flag in streamlit_drawable_canvas/__init__.py then I got :

which shows me the project folder prepends the installed packages in PYTHON_PATH.

I’ll just move the script in another folder then.

Fanilo

Can you paste the code you’re using to create the custom component? Your PYTHON_PATH shouldn’t matter - the code should just be reading from your build directory via a project-relative path.

(Also, if you have a public Github repo for your S4A demo app, you can point me there and I’ll take a look!)

Here, it’s the untouched release flag. Also I moved the S4A example to another folder instead of at the root of the project.

I am not pushing the build directory on Github. I actually don’t want from streamlit_drawable_canvas import st_canvas to go into the __init__.py file but use the published package from requirements.txt, to ensure I published properly :wink:.

Ah - I think that’s the issue. Your app imports streamlit_drawable_canvas, but since that package is included in the app’s path, that local copy of the component is what’s being used.

That is: when app.py does from streamlit_drawable_canvas import st_canvas, it’s importing the local streamlit_drawable_canvas directory and not the PyPI package.

In general, if you want to use the published package, I’d recommend moving this S4A app into its own repo. (This is especially true because you essentially have two separate bits of “packaging” data for two separate projects at the root level of the repo - setup.py and MANIFEST.in for the PyPI package, and requirements.txt for the S4A app.)

1 Like

Gotcha. I didn’t want to split the repo into code + example at first but you’re right, the mixing of those 2 packaging bits will trip me off in the future.

I just didn’t want to build a repo for a single 30 line demo :laughing: I’ll look into making a big repo with multiple demos…or I’ll just get used to having multiple 30 lines repos

If S4A lets you specify the project root (that is, if it doesn’t assume that the repo is the project root – I’m not au fait on whether this is currently possible), then you could move requirements.txt into examples alongside app.py, and have examples be the root of your S4A project. (The app.py wouldn’t “see” the local streamlit_drawable_canvas folder in its path.)

Ah I don’t think that’s possible but it would make sub-projects possible with different requirements/packages possible and I love the idea