[refactor]: remove the flat-flag entry point of the OpenAI API server

python -m fastvideo.entrypoints.openai.api_server parsed the hand-written
FastVideoArgs argparse flags, an inference input path next to the typed config
that fastvideo serve reads. It is removed; start the server with
fastvideo serve --config SERVE_CONFIG and dotted overrides such as
--server.port 8000. The GPU integration test starts the server that way, with
the same model, GPU count, and DiT offload.

FastVideoArgs.add_cli_args stays for the legacy training and preprocessing
scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012M91wnVFmPEvJ9h39r5BH7
This commit is contained in:
Davids048
2026-10-03 01:54:34 +00:00
co-authored by Claude Opus 5.5
parent 2cd2018137
commit 74a52c027b
3 changed files with 13 additions and 42 deletions
@@ -174,31 +174,6 @@ def create_app(
return app
def _parse_args() -> tuple[FastVideoArgs, str, int, str]:
"""Parse CLI arguments and return (FastVideoArgs, host, port, output_dir)"""
from fastvideo.utils import FlexibleArgumentParser
logger.warning("python -m fastvideo.entrypoints.openai.api_server and its flat flags are deprecated and will be "
"removed; use `fastvideo serve --config SERVE_CONFIG` with dotted overrides such as "
"`--generator.engine.num_gpus 2` instead.")
parser = FlexibleArgumentParser(description="FastVideo OpenAI-compatible API server")
parser.add_argument("--host", type=str, default=DEFAULT_HOST)
parser.add_argument("--port", type=int, default=DEFAULT_PORT)
parser.add_argument("--output-dir", type=str, default=DEFAULT_OUTPUT_DIR)
parser = FastVideoArgs.add_cli_args(parser)
args = parser.parse_args()
host = args.host
port = args.port
output_dir = args.output_dir
# Build FastVideoArgs from the remaining CLI args
excluded = {"host", "port", "output_dir", "subparser", "config", "dispatch_function"}
cli_kwargs = {k: v for k, v in vars(args).items() if k not in excluded and v is not None}
fastvideo_args = FastVideoArgs.from_kwargs(**cli_kwargs)
return fastvideo_args, host, port, output_dir
def run_server(
fastvideo_args: FastVideoArgs,
host: str = DEFAULT_HOST,
@@ -229,8 +204,3 @@ def run_server(
log_level="info",
timeout_keep_alive=300,
)
if __name__ == "__main__":
fastvideo_args, host, port, output_dir = _parse_args()
run_server(fastvideo_args, host, port, output_dir=output_dir)
+2 -3
View File
@@ -1,8 +1,7 @@
"""Global server state shared across API modules.
Keeping state in a dedicated module prevents the classic '__main__ vs package
module' duplication that occurs when api_server.py is run with ``python -m``.
All modules that need the generator or server args should import from here.
Keeping state in a dedicated module gives every API module the same
generator and server args. All modules that need them should import from here.
"""
from __future__ import annotations
@@ -59,21 +59,23 @@ def server():
env.setdefault("MASTER_ADDR", "127.0.0.1")
env.setdefault("MASTER_PORT", str(_find_free_port()))
config_path = os.path.join(output_dir, "serve.yaml")
with open(config_path, "w", encoding="utf-8") as config_file:
config_file.write(f"generator:\n model_path: {MODEL_PATH}\n"
" engine:\n num_gpus: 1\n offload:\n dit: true\n")
cmd = [
sys.executable,
"-m",
"fastvideo.entrypoints.openai.api_server",
"--model-path",
MODEL_PATH,
"--host",
"fastvideo.entrypoints.cli.main",
"serve",
"--config",
config_path,
"--server.host",
"127.0.0.1",
"--port",
"--server.port",
str(port),
"--output-dir",
"--server.output_dir",
output_dir,
"--num-gpus",
"1",
"--dit-cpu-offload",
]
proc = subprocess.Popen(