Skip to content
New issue

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

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

Already on GitHub? # to your account

Server crash #7211

Closed
MarcSkovMadsen opened this issue Aug 31, 2024 · 1 comment
Closed

Server crash #7211

MarcSkovMadsen opened this issue Aug 31, 2024 · 1 comment
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Aug 31, 2024

I'm on the current main branch trying to help with #7178.

The wish was a transparent background, so I tried setting background="transparent". This crashes the server without a meaningful error message. As I'm using --autoreload I would expect this issue to be catched, the server started and the error shown in the browser.

import panel as pn

pn.extension(template="fast")

class CustomDial(pn.indicators.Dial):
    """"""
    def _get_model(self, doc, root=None, parent=None, comm=None):
        model = pn.indicators.Dial._get_model(self, doc, root, parent, comm)
        model.background_fill_color = self.background
        return model

custom_style = {
    "border": "0.5px solid grey",
    "border-radius": "5px",
    "margin": "5px",
}
colour = "pink"

pn.Column(
    pn.Spacer(height=30),
    pn.Row(
        CustomDial(
            name="Similarity",
            value=60,
            title_size="11px",
            bounds=(0, 100),
            width=150,
            height=150,
            colors=[(0, "grey"), (0.5, "grey"), (1, colour)],
            margin=(0, 20, 0, 0),
            background="transparent",
        ),
        CustomDial(
            name="Strength",
            value=68,
            title_size="11px",
            bounds=(0, 100),
            width=150,
            height=150,
            colors=[(0, "grey"), (0.5, "grey"), (1, colour)],
            margin=(0, 20, 0, 0),
            styles=custom_style,
            background=None
        ),
    ),
).servable()
$ panel serve script.py --autoreload --index script
ERROR: cannot access local variable 'session' where it is not associated with a value

If you change background="transparent" to background="green" the server will start and the app show nicely.

@MarcSkovMadsen MarcSkovMadsen added TRIAGE Default label for untriaged issues type: bug and removed TRIAGE Default label for untriaged issues labels Aug 31, 2024
@holoviz holoviz deleted a comment Aug 31, 2024
@holoviz holoviz deleted a comment Aug 31, 2024
@philippjfr philippjfr added this to the v1.5.0 milestone Sep 11, 2024
@philippjfr
Copy link
Member

I will consider this fixed, it no longer crashes with the obscure error message mentioned above, but does cause a 500 error, a clear traceback on the console and when you fix it and reload the page it resolves.

I don't think we can reasonably do better than that because implementing a custom component means you are leaving user land and entering developer APIs. In fact implementing _get_model takes you well into advanced developer APIs since the JS/React/Py components let you do stuff like this in a cleaner way. Handling this better would involve adding try/except clauses all over the Panel internals which I don't think is desirable.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants