Skip to content

Add public demo application contracts - #454

Open
jarcherNV wants to merge 33 commits into
mainfrom
dev/jarcher/basicdemo
Open

Add public demo application contracts#454
jarcherNV wants to merge 33 commits into
mainfrom
dev/jarcher/basicdemo

Conversation

@jarcherNV

Copy link
Copy Markdown
Collaborator

Introduce the flashdreams.demo facade for application-facing demo protocols and thin adapters over the existing runtime demo stack. Cover the Phase 1 contract shape with focused CPU tests.

Introduce the flashdreams.demo facade for application-facing demo
protocols and thin adapters over the existing runtime demo stack. Cover
the Phase 1 contract shape with focused CPU tests.
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR introduces the public demo application contracts and adapters, migrates text-to-video integrations to application entry points, and strengthens runner and WebRTC lifecycle cleanup.

  • Adds public Application, ApplicationSession, IOHandler, and Runner facades.
  • Adds model-neutral T2V application shells and integration registrations.
  • Tracks all adapter-created runtimes and rejects unsupported launch arguments.
  • Preserves primary execution failures while coordinating application, host, and distributed cleanup.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
flashdreams/flashdreams/demo/application.py Defines the public application contracts, tracks every adapter-created runtime, rejects unsupported launch arguments, and closes retained runtimes.
flashdreams/flashdreams/demo/runner.py Implements synchronous and asynchronous application execution with worker-affine, cancellation-resistant cleanup and primary-outcome preservation.
flashdreams/flashdreams/demo/app.py Adds replay and WebRTC application launch paths with startup-failure cleanup for runtimes and distributed state.
apps/t2v/t2v.py Provides the model-neutral T2V application adapter, scenario handling, runtime/session implementation, and browser resources.
flashdreams/flashdreams/plugins/registry.py Extends plugin discovery to support public application registrations alongside existing runner configuration plugins.
flashdreams/flashdreams/serving/webrtc/bootstrap.py Coordinates WebRTC process cleanup while preserving primary server failures.
flashdreams/flashdreams/serving/webrtc/manager.py Integrates shared-host and session-manager lifecycle behavior used by public WebRTC applications.
flashdreams/flashdreams/scripts/cli.py Adds CLI resolution and launch support for registered public applications.

Sequence Diagram

sequenceDiagram
  participant CLI
  participant Runner
  participant Application
  participant Host as RuntimeHost
  participant Session
  participant IO as IOHandler
  CLI->>Runner: run()
  Runner->>Application: init(launch_args)
  Runner->>Host: register application close hook
  Host->>Application: create_session()
  Application-->>Host: ApplicationSession
  Host->>Session: init()
  loop generation
    Session->>Session: next_step_requirements()
    Runner->>IO: next_window(requirements)
    Runner->>Session: step(model_input)
    Runner->>IO: emit_chunk(result)
  end
  Runner->>Session: close()
  Runner->>IO: close()
  Runner->>Host: dispatch Application.close()
  Runner->>Host: close owned host
Loading

Reviews (25): Last reviewed commit: "Clean up WebRTC distributed state on sta..." | Re-trigger Greptile

Comment thread flashdreams/flashdreams/demo/application.py
Comment thread flashdreams/flashdreams/demo/application.py Outdated
Comment thread flashdreams/flashdreams/demo/application.py Outdated
Expose flashdreams.demo.Runner as an application-facing wrapper over the
existing shared demo session helpers. Adapt public Application and IOHandler
objects into the runtime demo stack while preserving RuntimeHost worker
affinity, StepPipeline execution, metrics, output decisions, and cleanup.

Cover direct sync and async Runner usage with focused CPU tests.
Add application-level cleanup to the public demo contract and make
DemoAdapterApplication close every runtime it creates. Reject unsupported
launch args instead of silently dropping them, and cover repeated session
creation and cleanup with focused CPU tests.
Introduce public replay, native-window, and WebRTC IO factory shapes under
flashdreams.demo. Keep WebRTC server-shaped so handlers are produced per
connection, and move the Runner IO run-mode adapter into the shared factory
module.

Cover factory-produced replay handlers, metric forwarding, native factory
shape, and WebRTC server callback behavior with focused CPU tests.
Add the public DemoApplication app base and route replay launches through
the public replay IO factory plus Runner. Keep the old runtime demo app import
as a compatibility shim.

Expose a server-shaped callback adapter for existing WebRTC serving code, and
update OmniDreams and LingBot demo apps to use the new app-base IO selection
hook instead of prepare_webrtc/serve_webrtc. Repoint non-benchmark finite
flashdreams-run launches at the public replay Runner helper.

Add CPU tests for app-base replay selection, server-shaped selection, and the
adapter-backed Runner path.
Comment thread flashdreams/flashdreams/demo/runner.py Outdated
Make Runner own Application.close() explicitly instead of relying on owned host
cleanup to reach it. Application cleanup now runs through the host worker for
both owned and externally supplied hosts, and is attempted even when context
cleanup raises.

Add focused sync and async coverage for external-host cleanup and cleanup
failure paths.
Make cleanup note handling type-checker friendly and update the fake public
demo session to satisfy the runtime session protocol through a test adapter.
Comment thread flashdreams/flashdreams/demo/runner.py
Comment thread flashdreams/flashdreams/demo/runner.py Outdated
Comment thread flashdreams/flashdreams/demo/runner.py Outdated
Comment thread flashdreams/flashdreams/demo/runner.py Outdated
Add InputName and central input state decoders for public demo IO handlers.
ReplayIOHandler now exposes get_user_input_state as a deterministic view over
the current UserInputWindow, including keyboard state, snapshot-backed state,
and legacy key_* compatibility.

Add fake CPU tests for provider access, pull/window parity, and named state
lookup through the public API.
Comment thread flashdreams/flashdreams/demo/runner.py Outdated
Bind adapter-prepared replay inputs and source schemas onto ReplayIOHandler
before shared runtime validation. This lets DemoAdapterApplication replay
commands advertise provider-required raw user input schemas, including the
OmniDreams Ludus keyboard event schema.

Add CPU coverage for replay IO schema propagation.
Comment thread flashdreams/flashdreams/demo/runner.py Outdated
Add a small T2VApplication/defaults facade and route T2V mp4/null launches
through the public Runner and replay IO handler. This moves the batch T2V demo
onto the application API while preserving the existing WebRTC serving path.

Update focused T2V tests to assert public runner wiring.
Comment thread flashdreams/flashdreams/demo/runner.py
Derive legacy t2v_demo backend metadata and preset selection from the
integration-owned application and runner configs. Add a neutral helper for
building T2V model configs from runner configs, and keep the old t2v runner
bridge working while deleting the app-local backends.py and presets.py copies.
Reject closed external hosts before app initialization, avoid direct
runner-thread application cleanup when worker dispatch is unavailable, and
preserve primary async run failures when cancellation arrives during cleanup.
@jarcherNV
jarcherNV force-pushed the dev/jarcher/basicdemo branch from e2b6f6b to aa69c9b Compare August 13, 2026 11:17
Add finite-mode application launch support to the central CLI for
discovered flashdreams.applications entry points. Route direct mp4 and
null launches through the current public demo Application/Runner API,
while keeping the existing t2v runner bridge for compatibility.
Route discovered application slugs through the shared WebRTC serving path
for direct flashdreams-run app launches. Move T2V WebRTC resources into
the neutral T2V shell and keep the legacy t2v_demo package until the new
WebRTC path is remotely validated.
Comment thread flashdreams/flashdreams/demo/app.py
Ensure direct public WebRTC app launches close the created runtime when
startup fails before aiohttp owns shutdown. Route failure cleanup through
the WebRTC manager and RuntimeHost path, preserving the original startup
error, and add CPU coverage for the cleanup behavior.
Register `wan21-t2v` and `fastvideo-causal-wan22-t2v` under the
`flashdreams.applications` entry-point group so both models launch
directly from `flashdreams-run` alongside the existing three T2V apps.
Each integration gains a `t2v/` subpackage wrapping its existing runner
config, plus the `flashdreams-t2v` workspace dependency.

No shell changes were needed: wan22 is autoregressive like the existing
streaming apps, and wan21 T2V is single-step, which
`model_config_from_runner` already covers via its `total_blocks`
fallback of 1.

Restore the T2V README, lost with `apps/t2v_demo`, documenting the five
slugs, the three launch modes, and the scenario and output overrides.
Comment thread flashdreams/flashdreams/demo/runner.py
Ensure public runner cleanup still invokes Application.close() when an
externally supplied RuntimeHost has already stopped accepting dispatched
work. Add sync and async regression coverage for the closed-host fallback
so application-owned runtimes are not orphaned.
Comment thread flashdreams/flashdreams/demo/app.py
Make BaseWebRTCSessionManager.shutdown attempt every owned cleanup step even
when active-session shutdown fails. Preserve the first cleanup error while
recording later failures as notes, and add regression coverage that shared
RuntimeHost cleanup still runs after session and context close failures.
Do not call Application.close() directly when an external RuntimeHost is
already closed before runner cleanup can dispatch onto the model worker.
Report the invalid lifecycle instead, preserving the worker-affinity
boundary required for model/runtime cleanup. Update sync and async runner
tests to cover the closed-host failure path.
Comment thread flashdreams/flashdreams/demo/app.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant