Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support developing BasicTemplate Templates outside of Panel project #1787

Closed
MarcSkovMadsen opened this issue Nov 15, 2020 · 4 comments · Fixed by #3284
Closed

Support developing BasicTemplate Templates outside of Panel project #1787

MarcSkovMadsen opened this issue Nov 15, 2020 · 4 comments · Fixed by #3284
Labels
type: enhancement Minor feature or improvement to an existing feature
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Nov 15, 2020

I would like to create a custom BasicTemplate based on the Fast Framework. For now it should be a part of the awesome-panel-extensions package. It's been setup as a package of prebuilt bokeh extensions as described here.

Unfortunately this is not possible without hacks and workarounds as the bundling of the css and js resources of the BasicTemplate only works for BasicTemplate in the Panel project.

This works

I have

  • copied the ReactTemplate files to the folder awesome_panel_extensions\frameworks\fast\templates\fast\
  • changed the relative imports to absolute panel imports

and tested that it works.

image

This does not work

But as soon as I rename ReactTemplate to FastTemplate it no longer works.

image

Attempts to Fix

I ran

python -c "from panel.compiler import bundle_resources;bundle_resources()"

In the hope that it would magically bundle my resources and serve them. It did not work and inspecting the code I can see that it only supports bundling resources from the Panel project.

Reproducible Steps

You can reproduce the issue via

git clone https://github.com/MarcSkovMadsen/awesome-panel-extensions.git
cd awesome-panel-extensions
git checkout 6f92161
python -m venv .venv
source .venv/Scripts/activate
pip install -e .
python -m panel serve 'awesome_panel_extensions/frameworks/fast/templates/test_fast.py' --dev

and you will see among other

$ python -m panel serve 'awesome_panel_extensions/frameworks/fast/templates/test_fast.py' --dev
2020-11-15 05:51:11,318 Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
2020-11-15 05:51:11,320 User authentication hooks NOT provided (default user enabled)
2020-11-15 05:51:11,323 Bokeh app running at: http://localhost:5006/test_fast
2020-11-15 05:51:11,323 Starting Bokeh server with process id: 7584
2020-11-15 05:51:18,932 404 GET /static/extensions/panel/bundled/fasttemplate/bootstrap/3.3.7/css/bootstrap.min.css (::1) 1.00ms
2020-11-15 05:51:18,935 404 GET /static/extensions/panel/bundled/fasttemplate/react.css (::1) 2.00ms
2020-11-15 05:51:18,935 404 GET /static/extensions/panel/bundled/fasttemplate/default.css (::1) 2.00ms
2020-11-15 05:51:18,936 404 GET /static/extensions/panel/bundled/fasttemplate/react@16/umd/react.development.js (::1) 2.50ms
2020-11-15 05:51:18,937 404 GET /static/extensions/panel/bundled/fasttemplate/react-dom@16/umd/react-dom.development.js (::1) 3.00ms
2020-11-15 05:51:18,938 404 GET /static/extensions/panel/bundled/fasttemplate/font-awesome/4.7.0/css/font-awesome.min.css (::1) 3.50ms
2020-11-15 05:51:18,939 404 GET /static/extensions/panel/bundled/fasttemplate/babel-standalone@latest/babel.min.js (::1) 1.50ms
2020-11-15 05:51:18,941 404 GET /static/extensions/panel/bundled/fasttemplate/ajax/libs/react-grid-layout/1.1.1/react-grid-layout.min.js (::1) 1.50ms
2020-11-15 05:51:19,226 404 GET /static/extensions/panel/bundled/fasttemplate/react-dom@16/umd/react-dom.development.js (::1) 1.00ms
2020-11-15 05:51:19,239 404 GET /static/extensions/panel/bundled/fasttemplate/babel-standalone@latest/babel.min.js (::1) 0.50ms
2020-11-15 05:51:19,242 404 GET /static/extensions/panel/bundled/fasttemplate/ajax/libs/react-grid-layout/1.1.1/react-grid-layout.min.js (::1) 0.50ms
@MarcSkovMadsen MarcSkovMadsen added the TRIAGE Default label for untriaged issues label Nov 15, 2020
@Jhsmit
Copy link

Jhsmit commented Nov 16, 2020

FYI: you can get around this issue by adding a static dir with the same directory structure as the templates use and overriding the _template_resources method:

https://github.com/Jhsmit/PyHDX/blob/7c8cf1b3659253c8275aae487d0aca52c8b9d8ef/pyhdx/panel/template.py#L15

@jlstevens jlstevens added type: enhancement Minor feature or improvement to an existing feature and removed TRIAGE Default label for untriaged issues labels Nov 23, 2020
@jlstevens jlstevens added this to the next milestone Nov 23, 2020
@jlstevens
Copy link
Contributor

@philippjfr This sounds like a reasonable request but I'm not sure about its priority. I've assigned it to the the 'next' milestone but feel free to bump it as appropriate.

@MarcSkovMadsen
Copy link
Collaborator Author

@jlstevens , @philippjfr . I think finishing #1730 before this one would make sense. Loading indicators will be simple to use for a lot of users. This request is important. But not the first step for a lot of users.

@jlstevens
Copy link
Contributor

I agree that it makes sense for #1730 to take priority (as it is immediately useful and orthogonal).

@philippjfr philippjfr modified the milestones: next, v0.12.0 Jun 29, 2021
@philippjfr philippjfr modified the milestones: next, 0.13.0 Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants