Skip to content

@reactive.event cause RuntimeError: shiny.express.input can only be used inside of a Shiny Express app. #1741

@wdesaintjean

Description

@wdesaintjean

Hello
I wrote an app in shiny express python, and its worked well in a local server on my computer. But when I try to install my app on a server, (with a docker image, and irequired python packages), I have an error that said:

Traceback (most recent call last):
  File "/home/app/app.py", line 197, in <module>
    @reactive.event(input.action_button)
  File "/usr/local/lib/python3.10/site-packages/shiny/express/__init__.py", line 76, in __getattr__
    raise RuntimeError(
RuntimeError: shiny.express.input can only be used inside of a Shiny Express app.

It seems to not accept the utilization of @reactive.event() in a shiny express application, but I saw in the documentation that the reactive module is unchanged between Core and Express. I don't understand the problem. Here the problematic part of my code:

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

ui.panel_title("Exploration of Nanopore RNAseq results")

ui.input_text("gene_name", "Gene name Symbol", "Enter gene")   

ui.input_action_button("action_button", "Search", disabled=False)

@render.text 
@reactive.event(input.action_button)
def txt():

    gene_conv=pl.read_csv("./data/geneToSymbol_GRCm38.99.csv", separator="\t", has_header = False)
    if input.gene_name() in gene_conv['column_2']:
        return f"The chosen gene is {input.gene_name()}"
    else: 
        return f"The gene symbol is not in mm10 reference"

What's bug me is that worked perfectly fine on my computer with manual import of python packages.
I suppose I can always convert my code in Shiny Core python, but it will be a lot of works, I will gain a lot of time if It 's only a little mistake.

Can you help me?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions