Skip to content

Conversation

@jcheng5
Copy link
Collaborator

@jcheng5 jcheng5 commented Jan 29, 2024

@gadenbuie Did I put the Express example in the right place?

@gadenbuie
Copy link
Collaborator

@gadenbuie Did I put the Express example in the right place?

Yup, the example's in the right place. 👍

@jcheng5
Copy link
Collaborator Author

jcheng5 commented Jan 29, 2024

The Playwright failures appear to be real!? api-examples/Progress/app-express.py is throwing an error shiny.express.input can only be used inside of a Shiny Express app upon startup.

Yes, my adding the __bool__ operator to MockSession caused this problem. @cpsievert @wch are either of you available to take a look at this? I'm in and out of meetings all afternoon.

@gadenbuie
Copy link
Collaborator

gadenbuie commented Jan 29, 2024

The issue specifically depends on using a reactive.effect(input.___) or reactive.event(). Here's a minimal reprex -- uncommenting the @reactive.event() introduces the error:

from shiny import reactive
from shiny.express import input, render, ui

ui.input_action_button("btn", "Press me!")


@render.text
# @reactive.event(input.btn)
def text():
    return f"Number of clicks: {input.btn()}"

@wch
Copy link
Collaborator

wch commented Jan 29, 2024

Shouldn't it be reactive.event, not reactive.effect?

@gadenbuie
Copy link
Collaborator

gadenbuie commented Jan 29, 2024

Shouldn't it be reactive.event, not reactive.effect?

Yes it should, but reactive.effect() introduces the bug. I'll update the example. Updated: I can reproduce the issue when either reactive.effect() or reactive.event() are used. The example now uses reactive.event()

@gadenbuie
Copy link
Collaborator

gadenbuie commented Jan 29, 2024

In case it matters to anyone, I found the source of the bug in get_current_session():

return _current_session.get() or _default_session

should be

    cs = _current_session.get()
    return cs if cs is not None else _default_session

@wch
Copy link
Collaborator

wch commented Jan 29, 2024

@gadenbuie good find! I feel like falsiness in general causes more problems than it helps with. I think we should fix that in another PR.

@wch
Copy link
Collaborator

wch commented Jan 30, 2024

Closing because this was fixed by #1085.

@wch wch closed this Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants