[bugfix]: dreamverse modal bypasses ENTRYPOINT — set ffmpeg env + key check - #1413
Conversation
… check Modal's @modal.web_server decorator invokes serve() directly (Popen dreamverse-server) and bypasses the image's ENTRYPOINT (apps/dreamverse/docker/docker_entrypoint.sh). The bypassed entrypoint normally does two things, both of which silently no-op on Modal: 1. ``:?``-validates CEREBRAS_API_KEY and GROQ_API_KEY (fails the container fast if either is missing from the mounted secret). 2. Sources ffmpeg-env.sh, exporting FASTVIDEO_FFMPEG_BIN=/opt/ffmpeg-native/bin/ffmpeg. Symptoms observed when deploying the post-hao-ai-lab#1394 UI image (dreamverse-ui-cuda12.9.1-sha-2c13793): - /opt/ffmpeg-native/bin is not on the container PATH (set in apps/dreamverse/docker/Dockerfile line 24). With FASTVIDEO_FFMPEG_BIN unset, av_streaming.py:28's shutil.which("ffmpeg") returns None and av_fmp4 muxing silently has no encoder. - A misconfigured dreamverse-api-keys secret (e.g. placeholder values) lets the container boot fine; prompt rewriting then fails on the first user request instead of at boot. Fix, both in apps/dreamverse/scripts/modal/modal_app.py: - Set FASTVIDEO_FFMPEG_BIN and FASTVIDEO_VIDEO_CODEC in image.env so av_streaming finds the native ffmpeg the Dockerfile builds. - Add a fail-fast guard in serve() that checks the required secret entries before launching the server, mirroring the entrypoint's ``:?`` behavior.
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 PR merge requirementsWaiting for
This rule is failing.
|
There was a problem hiding this comment.
Code Review
This pull request updates the Modal application script to replicate environment validation and setup that is normally handled by the Docker entrypoint but bypassed by @modal.web_server. Specifically, it defines required secret keys, configures environment variables for the native ffmpeg binary and video codec, and adds a runtime check to ensure all required API keys are present before starting the server. The review feedback suggests improving the API key validation by stripping whitespace from the environment variables to ensure whitespace-only keys are correctly identified as missing.
| ) | ||
| @modal.web_server(8009, startup_timeout=4800) | ||
| def serve(): | ||
| missing = [k for k in _REQUIRED_SECRET_KEYS if not os.environ.get(k)] |
There was a problem hiding this comment.
Checking not os.environ.get(k) will evaluate to False if the environment variable is set to a whitespace-only string (e.g., " "). Stripping the value and defaulting to an empty string ensures that empty or whitespace-only API keys are correctly caught as missing.
| missing = [k for k in _REQUIRED_SECRET_KEYS if not os.environ.get(k)] | |
| missing = [k for k in _REQUIRED_SECRET_KEYS if not os.environ.get(k, "").strip()] |
… check Addresses gemini-code-assist's medium-priority comment on hao-ai-lab#1413: the prior ``not os.environ.get(k)`` only catches missing or empty entries, so a ``dreamverse-api-keys`` secret with a whitespace-only value (e.g. a stray ``" "`` left in place of a real key) would pass the guard and the ``RuntimeError`` would not surface. Strip the value (after collapsing ``None`` to ``""``) before truthiness-checking so unset, empty, and whitespace-only all read as missing.
|
Pushed |
Summary
Modal's
@modal.web_serverdecorator invokesserve()directly (Popenthedreamverse-server) and bypasses the image's ENTRYPOINT (apps/dreamverse/docker/docker_entrypoint.sh). The bypassed entrypoint normally does two things that silently no-op on Modal::?-validatesCEREBRAS_API_KEYandGROQ_API_KEY(fails the container fast if either is missing from the mounted secret).ffmpeg-env.sh, which exportsFASTVIDEO_FFMPEG_BIN=/opt/ffmpeg-native/bin/ffmpeg.Symptoms observed
Deploying the post-#1394 UI image (
dreamverse-ui-cuda12.9.1-sha-2c13793) on Modal:/opt/ffmpeg-native/binis not on the containerPATH(apps/dreamverse/docker/Dockerfile:24). WithFASTVIDEO_FFMPEG_BINunset,av_streaming.py:28'sshutil.which("ffmpeg")returnsNoneandav_fmp4muxing has no encoder.dreamverse-api-keyssecret with placeholder values lets the container come up fine; prompt rewriting then fails on the first user request instead of at boot.Fix
Both changes in
apps/dreamverse/scripts/modal/modal_app.py:FASTVIDEO_FFMPEG_BIN=/opt/ffmpeg-native/bin/ffmpegandFASTVIDEO_VIDEO_CODEC=libx264inimage.envsoav_streamingfinds the native ffmpeg the Dockerfile builds.serve()that checks the required secret entries before launching the server, mirroring the entrypoint's:?behavior.A comment block above the env dict documents why these are needed (entrypoint bypass), so the next reader doesn't lose the context.
Test evidence
pre-commit run --files apps/dreamverse/scripts/modal/modal_app.pyandpython -c "import ast; ast.parse(open(...))"pass.FASTVIDEO_FFMPEG_BINinimage.envwas the workaround that madeav_streaming'sshutil.whichresolve to the right binary during that session.RuntimeErrorwhenos.environ.get(k)is empty for either required key); the message names the missing key(s) and points at the README so the operator knows exactly what to fix.