call_tree_app()
Build the call tree of a Shiny for Python App object.
Usage
call_tree_app(
app,
app_fun="app",
ui_fun=None,
server_fun=None,
modules_only=False,
exclude=None,
max_depth=None,
labels="def"
)call_tree_app() takes the server function out of a shiny.App and reads its source. Each name it references is looked up the way the server would see it. When the name is a function defined in the app’s own package (the top level package of the server’s module), it joins the tree and its source is read the same way. Functions from other packages, such as shiny.ui, are left out. A class in the app’s package counts through its __init__, and self.m() and Class().m() are looked up on the class, as in call_stack().
The app is never run, and shiny itself is never imported, so callgrove does not depend on it.
Parameters
app: Any-
A
shiny.App. app_fun: str = "app"-
Label for the root node. The app does not record the name of the function that built it, so this is display text only. Default
"app". ui_fun: str | None = None-
Name of the UI function.
Apprenders a static UI when it is created, so the function behind it is lost. Pass its name here to include the UI branch. When the UI was passed as a function (App(app_ui, server)), it is found without this. When neither applies, the tree has no UI branch and a warning says so. server_fun: str | None = None-
Label for the server node. Default: the server function’s own name.
modules_only: bool = False-
Keep only the root and Shiny module functions; see call_tree_dir().
exclude: str | Iterable[str] | None = None-
Function names to drop; see call_tree_dir().
max_depth: int | None = None-
How many levels to expand.
None(the default) expands everything. labels: str = "def"-
"def"(the default) labels each function by its definition name (Model.fit), so one function reached under two names is one node."call"uses the text at the call site (model.fit). Nested functions are always labeledouter.inner.
Returns
CallTree- The root node. Print it to draw the tree.
Warns
UserWarning-
When the UI is static and
ui_funis not given.
Examples
from myapp.app import app
call_tree_app(app, ui_fun="app_ui")
call_tree_app(app, ui_fun="app_ui", modules_only=True)