yera.ui.run

Entry point for launching Yera applications via a local server.

Symbols

def discover_apps — Discover all apps in a directory.
def extract_apps_from_py_file — Extract AppFunctionWrapper instances from a Python file.
class ServerPortInUseError — Report that Yera cannot bind its requested local server port.
def start_server_process — Start the YeraServer for the given apps and open the UI in a browser.

discover_apps

discover_apps(
    directory: Path | str,
) → dict[str, AppFunctionWrapper]

Discover all apps in a directory.

Scans the directory tree for .py files and loads all apps from each file. Hidden directories (names starting with .) are not entered, so typical trees like .venv or .git are skipped. Files that fail to load are logged and skipped rather than aborting the scan.

Keys are produced by extract_apps_from_py_file and embed the file path verbatim, so they follow the form of directory: pass a relative path and the keys are relative.

Parameters

directory
type: Path | str

Directory to scan for app files.

Returns

type: dict[str, AppFunctionWrapper]

Mapping of app key to wrapper, across every file scanned.

Raises

FileNotFoundError

If the directory does not exist.

ValueError

If the path is not a directory.

extract_apps_from_py_file

extract_apps_from_py_file(
    file_path: Path | str,
) → dict[str, AppFunctionWrapper]

Extract AppFunctionWrapper instances from a Python file.

Parameters

file_path
type: Path | str

Path to the Python file containing apps.

Returns

type: dict[str, AppFunctionWrapper]

Mapping of app identifiers to wrappers. Keys embed file_path verbatim, so they follow the form the caller supplied.

Raises

FileNotFoundError

If the specified file does not exist.

ImportError

If the module cannot be loaded.

ServerPortInUseError

Inherits: YeraError

Report that Yera cannot bind its requested local server port.

start_server_process

start_server_process(
    apps: Mapping[str, AppReference],
    host: str,
    port: int | None,
    open_browser: bool,
    launch_config: ServerLaunchConfig | None = None,
) → None

Start the YeraServer for the given apps and open the UI in a browser.

Runs until SIGINT or SIGTERM, then shuts the server down cleanly.

Parameters

apps
type: Mapping[str, AppReference]

The applications to be served.

host
type: str

The hostname or IP address to bind the server to.

port
type: int | None

Explicit TCP port, or None to prefer Yera's default and ask before using an available alternative.

open_browser
type: bool

Whether to open a browser window on server start.

launch_config
type: ServerLaunchConfig | None = None

Configuration controlling server entry behavior.