posit-dev / posit-dev/py-shiny

Provide a way for Express app to run/import another file in Express mode?

Open
#1,102 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

Summary: It could be useful to have something like @expressify(), but for imports instead of functions.

A user might want to break a Shiny Express app into multiple files, so the app.py looks something like this:

## app.py ##
from shiny.express import ui

ui.h1("Hello")

import section1

ui.hr()

import section2

Where section1.py and section2.py contain Shiny Express code.

However, this won't work because the import won't evaluate section1 or section2 as Express, displaying contents as it goes.

To allow this, we could export the run_express function. It would also require a few modifications so that it doesn't try to alter any top-level state. The code would then look like this:

## app.py ##
from shiny.express import ui

ui.h1("Hello")

run_express("section1")

ui.hr()

run_express("section2")

It may be possible for it to return the values from running the code, so that you could do:

section1  = run_express("section1")

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing run_express entry point and the shiny.express import behavior described in the issue. Review how app.py executes section1.py and section2.py, then define whether completion requires ordered Express evaluation, avoiding top-level state changes, returning values, or all three.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.