Skip to content

[feat] [1/n] API improvements: add intial files for new fastvideo public API#1218

Merged
SolitaryThinker merged 6 commits intomainfrom
will/api_refactor
Apr 6, 2026
Merged

[feat] [1/n] API improvements: add intial files for new fastvideo public API#1218
SolitaryThinker merged 6 commits intomainfrom
will/api_refactor

Conversation

@SolitaryThinker
Copy link
Copy Markdown
Collaborator

Purpose

This PR lays the groundwork for the inference API refactor without changing runtime behavior yet.

  • a schema parity inventory for the current public inference surface in docs/design/inference_schema_parity_inventory.yaml
  • the initial typed inference config layer under fastvideo/api
  • strict parsing, validation, YAML/JSON loading, and dotted override helpers
  • focused API tests under fastvideo/tests/api
  • a lightweight GitHub Actions workflow for the new schema tests

This PR does not yet hook the new schema into VideoGenerator, CLI runtime entrypoints, or the server path. It is a boundary-definition and test-foundation PR.

Changes

The current inference surface mixes init-time config, request-time sampling, and model-specific knobs across flat kwargs and flags. This PR creates a typed, testable
boundary so the later runtime migration can happen with explicit parity checks instead of ad hoc argument churn.

Test Plan

/home/william5lin/miniconda3/envs/fv-main/bin/python -m pytest -q fastvideo/tests/api

Test Results

Test output
# Paste output here

Checklist

  • I ran pre-commit run --all-files and fixed all issues
  • I added or updated tests for my changes
  • I updated documentation if needed
  • I considered GPU memory impact of my changes

For model/pipeline changes, also check:

  • I verified SSIM regression tests pass
  • I updated the support matrix if adding a new model

@SolitaryThinker
Copy link
Copy Markdown
Collaborator Author

/test full

@mergify mergify bot added type: feat New feature or capability scope: infra CI, tests, Docker, build labels Apr 6, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 6, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 PR merge requirements

This rule is failing.
  • #approved-reviews-by>=1
  • check-success=full-suite-passed
  • check-success=fastcheck-passed
  • check-success~=pre-commit
  • title~=(?i)^\[(feat|feature|bugfix|fix|refactor|perf|ci|doc|docs|misc|chore|kernel|new.?model)\]

@mergify mergify bot added the scope: docs Documentation label Apr 6, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a typed configuration system for the FastVideo inference API, replacing legacy argument handling with a structured, dataclass-based schema. The implementation includes a recursive schema parser in fastvideo/api/parser.py that supports nested dataclasses, unions, and literals, along with a mechanism for applying dotted-key overrides from the CLI. Additionally, a comprehensive schema parity inventory and a suite of tests are provided to ensure consistency during the migration. The review feedback highlights opportunities to improve the parser's robustness, specifically by enhancing error reporting for Union types and adding explicit support for Enum types in both general values and dictionary keys.

Comment on lines +182 to +184
expected = ", ".join(_type_name(candidate) for candidate in candidates)
detail = errors[0] if errors else f"expected one of ({expected})"
raise ConfigValidationError(path, detail)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing a Union, if all candidates fail, the current implementation only returns the error message from the first candidate. This can be misleading for users. For example, if the type is int | list[int] and the user provides a list with an invalid element, they might see an error saying 'expected int' instead of a more specific error about the list element. Consider aggregating errors or providing a more descriptive 'expected one of' message that includes the specific failure if only one candidate of the same base type (e.g., a collection) was attempted.

Comment on lines +238 to +241
def _parse_instance(self, annotation: Any, value: Any, path: str) -> Any:
if isinstance(annotation, type) and not isinstance(value, annotation):
raise ConfigValidationError(path, f"expected {annotation.__name__}")
return value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _parse_instance method and the general parser currently lack explicit support for Enum types. If a dataclass field is an Enum, isinstance(value, annotation) will fail when value is a raw string or integer from the configuration file. Although the current schema uses Literal to avoid this, adding Enum support would improve the robustness and extensibility of the API config layer.

Comment on lines +225 to +236
def _parse_dict_key(self, annotation: Any, value: Any, path: str) -> Any:
if annotation is Any:
return value
if annotation is str:
if not isinstance(value, str):
raise ConfigValidationError(path, "expected string dictionary keys")
return value
if annotation is int:
if not isinstance(value, int) or isinstance(value, bool):
raise ConfigValidationError(path, "expected integer dictionary keys")
return value
return value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _parse_dict_key method only explicitly validates str and int keys. If a dictionary uses a different key type (like an Enum), it falls through and returns the raw value without validation or conversion. This could lead to type mismatches in the resulting dataclass if the key requires instantiation from a string.

@SolitaryThinker SolitaryThinker merged commit 76c62d7 into main Apr 6, 2026
10 of 11 checks passed
@SolitaryThinker SolitaryThinker deleted the will/api_refactor branch April 6, 2026 01:13
shijiew555 pushed a commit to Gary-ChenJL/FastVideo that referenced this pull request Apr 8, 2026
alexzms pushed a commit to FoundationResearch/FastVideo that referenced this pull request Apr 8, 2026
alexzms pushed a commit to FoundationResearch/FastVideo that referenced this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs Documentation scope: infra CI, tests, Docker, build type: feat New feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant