AGENT SKILL

app-callback-workflows

Use for Plotly Dash app layouts, callbacks, pages, assets, configuration, clientside callbacks, Jupyter display, CSP, and app-level debugging.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
app-callback-workflows
license
MIT
metadata
{ "disco-role": "operating" }
description
Use for Plotly Dash app layouts, callbacks, pages, assets, configuration, clientside callbacks, Jupyter display, CSP, and app-level debugging.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

Dash App and Callback Workflows

Use this sub-skill when a task is about using Dash as an application framework: creating layouts, registering callbacks, debugging ID/dependency validation, configuring pages/assets, or moving work into clientside callbacks.

Start here

  1. For layout and callback API details, read references/callbacks-and-layouts.md.
  2. For pages, URL prefixes, assets, dev tools, Jupyter, and CSP, read references/pages-assets-and-config.md.
  3. For browser-side callback functions, read references/clientside-callbacks.md.
  4. For common failures, read references/troubleshooting.md.
  5. Run scripts/smoke_dash_app.py for a no-browser import/layout/callback smoke check and scripts/smoke_pages_app.py for a page-registry smoke check.

Main routes

Build a basic app

Use Dash, component modules, and a component tree:

from dash import Dash, html, dcc

app = Dash(__name__)
app.layout = html.Div([
    dcc.Input(id="input", value="initial"),
    html.Div(id="output"),
])

Important rules:

  • Layout children must be Dash components, strings, numbers, None, or lists of those values. Raw arbitrary dicts are not valid component children.
  • Component IDs can be strings or dictionaries. Use dictionary IDs for pattern-matching callbacks.
  • If a layout is generated dynamically, either ensure callback components exist in the initial validation layout or configure dynamic-layout behavior deliberately.

Register server-side callbacks

Use @app.callback when you have an app object and @dash.callback when you need module-level callback registration. Core dependency classes are Output, Input, and State.

from dash import Input, Output, State, callback, no_update
from dash.exceptions import PreventUpdate

@callback(Output("output", "children"), Input("input", "value"), State("store", "data"))
def update(value, stored):
    if value is None:
        raise PreventUpdate
    if value == "keep":
        return no_update
    return f"{value}: {stored}"

Use callback troubleshooting when callbacks do not fire, fire too early, reference missing components, or form circular dependencies.

Use pattern-matching IDs

Route to dictionary IDs and wildcards when components are generated from data:

from dash import MATCH, ALL, Input, Output

@app.callback(
    Output({"type": "row-output", "index": MATCH}, "children"),
    Input({"type": "row-input", "index": MATCH}, "value"),
)
def per_row(value):
    return value

Use MATCH for one-to-one dynamic pairs, ALL for all matching components, and ALLSMALLER when a callback needs earlier indexed values.

Inspect callback context

Use dash.ctx or dash.callback_context inside callbacks for trigger metadata:

  • ctx.triggered_id gives the component ID that triggered the callback.
  • ctx.triggered_prop_ids maps changed id.property strings to IDs.
  • ctx.args_grouping is useful with flexible callback signatures.
  • ctx.response lets a callback set response cookies/headers in supported backends.
  • ctx.websocket is only available for WebSocket callbacks; route those tasks to server backends and async.

Use pages, assets, and URL prefixes

Use Dash(__name__, use_pages=True) plus dash.register_page and dash.page_container for multi-page apps. Read pages-assets-and-config.md before changing URL prefixes, asset loading, or Jupyter display behavior.

Move simple work clientside

Use clientside callbacks for simple browser-side transformations, browser storage access, or UI work that should avoid a server round trip. Read clientside-callbacks.md for namespace registration, no_update, PreventUpdate, and set_props behavior.

Route elsewhere

Validation checklist

Before declaring an app/callback fix complete:

  • The app imports Dash, html, dcc, and dependency classes from dash.
  • Every callback component ID exists in the layout, validation layout, or a deliberate dynamic-layout configuration.
  • Callback return shape matches the Output grouping.
  • Browser console is clean for browser-backed tasks.
  • If assets, pages, or URL prefixes changed, the generated URLs use app.get_asset_url, dash.get_relative_path, or the app's configured prefix-aware helpers.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351