From 4ebf11f7d9887db33a5f50490d1cfecdb2d928a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenbo=20Ji=E3=80=80=E5=B5=87=E6=96=87=E5=8D=9A?= <36562829+fusheng-ji@users.noreply.github.com> Date: Thu, 8 Oct 2026 00:32:22 +0200 Subject: [PATCH] [bugfix] Fix test env defaults and server dependencies (#1901) The distributed_setup test fixture now sets MASTER_ADDR and MASTER_PORT when they are not set, with a new port for each test, and restores them after the test. pyproject.toml now declares orjson and python-multipart, which the OpenAI-compatible server needs. Two documents about the SSIM reference bootstrap are corrected. --- docs/contributing/testing.md | 9 +++++---- fastvideo/tests/conftest.py | 19 +++++++++++++++---- fastvideo/tests/ssim/README.md | 5 +++-- pyproject.toml | 2 ++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/docs/contributing/testing.md b/docs/contributing/testing.md index 5d659b8a5..1e09b7bfd 100644 --- a/docs/contributing/testing.md +++ b/docs/contributing/testing.md @@ -233,10 +233,11 @@ test fails. For new-model PRs, CI can run SSIM in bootstrap mode so missing references are uploaded as draft artifacts for review instead of immediately blocking on a missing canonical reference. -Buildkite enables SSIM bootstrap mode when either condition is true: - -- the PR title or Buildkite message contains `[new-model]`; -- `FASTVIDEO_SSIM_BOOTSTRAP_MODE=1` is set for the Buildkite job. +The active Slurm SSIM lane (`.buildkite/scripts/lanes/ssim.sh`) enables +bootstrap mode only when `FASTVIDEO_SSIM_BOOTSTRAP_MODE=1` is set for the +Buildkite job. A `[new-model]` PR title does not enable it on this path (only +the retired Modal script `.buildkite/scripts/pr_test.sh` checked the title), so +ask a maintainer to start the SSIM job with that variable set. Bootstrap mode passes `--ssim-bootstrap-mode` to pytest. When a generated artifact is available, the test uploads it under the `drafts/...` namespace in diff --git a/fastvideo/tests/conftest.py b/fastvideo/tests/conftest.py index a010e5ecb..dd5d65764 100644 --- a/fastvideo/tests/conftest.py +++ b/fastvideo/tests/conftest.py @@ -1,12 +1,15 @@ # SPDX-License-Identifier: Apache-2.0 import contextlib +import os import pytest import torch import numpy as np +from fastvideo import envs from fastvideo.distributed import (maybe_init_distributed_environment_and_model_parallel, cleanup_dist_env_and_memory) +from fastvideo.utils import get_open_port @pytest.fixture(scope="function") @@ -18,10 +21,18 @@ def distributed_setup(): """ torch.manual_seed(42) np.random.seed(42) - maybe_init_distributed_environment_and_model_parallel(1, 1) - yield - - cleanup_dist_env_and_memory() + with contextlib.ExitStack() as stack: + # The env:// rendezvous needs these outside the CI runner. Keep values the + # launcher provides; otherwise use a fresh port per test and restore on exit. + if os.environ.get("MASTER_ADDR") is None: + stack.enter_context(envs.override_external("MASTER_ADDR", "127.0.0.1")) + if os.environ.get("MASTER_PORT") is None: + stack.enter_context(envs.override_external("MASTER_PORT", str(get_open_port()))) + maybe_init_distributed_environment_and_model_parallel(1, 1) + try: + yield + finally: + cleanup_dist_env_and_memory() @pytest.fixture diff --git a/fastvideo/tests/ssim/README.md b/fastvideo/tests/ssim/README.md index 0b35fbcef..cf188d452 100644 --- a/fastvideo/tests/ssim/README.md +++ b/fastvideo/tests/ssim/README.md @@ -89,8 +89,9 @@ into one subprocess per model id by setting `FASTVIDEO_SSIM_MODEL_ID`. ## Bootstrapping New References Normal SSIM runs are strict: missing references fail the test. For a new model -PR, add `[new-model]` to the PR title or set `FASTVIDEO_SSIM_BOOTSTRAP_MODE=1` -for the Buildkite job. CI then passes `--ssim-bootstrap-mode` to pytest. +PR, a maintainer sets `FASTVIDEO_SSIM_BOOTSTRAP_MODE=1` for the Buildkite SSIM +job (the Slurm lane does not read the PR title). CI then passes +`--ssim-bootstrap-mode` to pytest. In bootstrap mode, a missing pixel `.mp4` or latent `.pt` reference is treated as an expected draft-reference case after the generated artifact has been diff --git a/pyproject.toml b/pyproject.toml index 9bf3439b3..ea52f6471 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,6 +105,8 @@ dependencies = [ # Job Runner "fastapi>=0.129.0", + "orjson>=3.9.0", # fastapi ORJSONResponse in the OpenAI-compatible server + "python-multipart>=0.0.18", # fastapi Form/UploadFile parsing "uvicorn>=0.41.0" ]