Skip to content

Comments

Add frame_format parameter to VideoScene for PNG support#451

Open
vinay553 wants to merge 1 commit intomasterfrom
add-png-frame-format
Open

Add frame_format parameter to VideoScene for PNG support#451
vinay553 wants to merge 1 commit intomasterfrom
add-png-frame-format

Conversation

@vinay553
Copy link
Contributor

@vinay553 vinay553 commented Jan 28, 2026

  • Add FRAME_FORMAT_KEY constant
  • Add frame_format parameter to VideoScene dataclass
  • Update to_payload() to include frame_format when set
  • Supports 'jpeg' (default) or 'png' for lossless frame extraction
  • Bump version to 0.17.12
  • Remove broken test

Greptile Summary

This PR adds an optional frame_format parameter to VideoScene to support PNG (lossless) frame extraction when uploading videos via video_location, defaulting to JPEG. It also bumps the version to 0.17.12 and removes a broken integration test.

  • Bug: VideoScene.from_json() was not updated to deserialize the new frame_format field, so round-tripping through to_payload()from_json() will silently drop it.
  • The validate() method does not enforce that frame_format is one of the documented valid values ("jpeg" or "png").
  • No unit tests were added for the new frame_format parameter (e.g., verifying serialization/deserialization or validation of invalid values).
  • The removed test (test_job_listing_and_retrieval) is unrelated to the feature being added.

Confidence Score: 2/5

  • This PR has a deserialization bug in from_json() that will cause data loss when round-tripping VideoScenes with frame_format set.
  • The from_json() method was not updated alongside to_payload(), creating an asymmetry where frame_format is serialized but never deserialized. This is a functional bug that will affect any code path that reconstructs a VideoScene from JSON (e.g., the existing test fixtures use from_json). Additionally, there are no new tests for the feature.
  • nucleus/scene.py — the from_json() method needs to be updated to include frame_format, and validate() should enforce valid values.

Important Files Changed

Filename Overview
nucleus/scene.py Adds frame_format field and serialization in to_payload(), but from_json() does not deserialize it, breaking round-trip consistency. Also lacks input validation for the new parameter.
nucleus/constants.py Adds FRAME_FORMAT_KEY constant in alphabetical order. Clean, no issues.
CHANGELOG.md Documents the new frame_format parameter with a usage example. Well-formatted.
pyproject.toml Version bump from 0.17.11 to 0.17.12. Straightforward change.
tests/test_jobs.py Removes test_job_listing_and_retrieval integration test described as broken. No replacement test added for the new frame_format feature.

Sequence Diagram

sequenceDiagram
    participant User
    participant VideoScene
    participant Payload as JSON Payload
    participant API as Nucleus API

    User->>VideoScene: Create with frame_format="png"
    VideoScene->>VideoScene: validate()
    VideoScene->>Payload: to_payload()
    Note over Payload: Includes frame_format: "png"
    Payload->>API: Upload scene

    API-->>Payload: Return scene JSON
    Payload->>VideoScene: from_json(payload)
    Note over VideoScene: ⚠️ frame_format is lost<br/>(not extracted from payload)
Loading

Last reviewed commit: 6341865

@vinay553 vinay553 force-pushed the add-png-frame-format branch 2 times, most recently from 7278cf5 to 5066528 Compare January 28, 2026 17:02
- Add FRAME_FORMAT_KEY constant
- Add frame_format parameter to VideoScene dataclass
- Update to_payload() to include frame_format when set
- Supports 'jpeg' (default) or 'png' for lossless frame extraction
- Bump version to 0.17.12
@vinay553 vinay553 force-pushed the add-png-frame-format branch from 5066528 to 6341865 Compare January 28, 2026 18:10
@vinay553 vinay553 requested review from a team and edwinpav January 28, 2026 18:19
@vinay553
Copy link
Contributor Author

To be merged after https://github.com/scaleapi/scaleapi/pull/132674.

Copy link
Contributor

@edwinpav edwinpav left a comment

Choose a reason for hiding this comment

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

Looks good.
Since I was the only one who has redeployed a new SDK version in a while, lmk if help is needed for that part once this is merged.

Worth to take a look at greptile's comment as well

Comment on lines -26 to -33
def test_job_listing_and_retrieval(CLIENT):
jobs = CLIENT.list_jobs()
assert len(jobs) > 0, "No jobs found"
fetch_id = jobs[0].job_id
fetched_job = CLIENT.get_job(fetch_id)
# job_last_known_status can change
fetched_job.job_last_known_status = jobs[0].job_last_known_status
assert fetched_job == jobs[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this considered broken?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CLIENT.get_job(fetch_id)

Throws a 401 error. Honestly no one uses Nucleus jobs anymore though perhaps you'll use it for deduping.

@edwinpav
Copy link
Contributor

@greptileai review this PR

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link

greptile-apps bot commented Feb 23, 2026

Additional Comments (1)

nucleus/scene.py
from_json doesn't restore frame_format

to_payload() correctly serializes frame_format into the payload (line 703-704), but from_json() does not extract it when deserializing. This means a round-trip through to_payload()from_json() will silently drop the frame_format field. The existing test fixture video_scenes in tests/test_video_scene.py uses from_json to reconstruct scenes, so any scene with a frame_format set will lose that value.

        return cls(
            reference_id=payload[REFERENCE_ID_KEY],
            frame_rate=payload.get(FRAME_RATE_KEY, None),
            items=items,
            metadata=payload.get(METADATA_KEY, {}),
            video_location=payload.get(VIDEO_URL_KEY, None),
            tracks=tracks,
            frame_format=payload.get(FRAME_FORMAT_KEY, None),
        )
Prompt To Fix With AI
This is a comment left during a code review.
Path: nucleus/scene.py
Line: 672-679

Comment:
**`from_json` doesn't restore `frame_format`**

`to_payload()` correctly serializes `frame_format` into the payload (line 703-704), but `from_json()` does not extract it when deserializing. This means a round-trip through `to_payload()``from_json()` will silently drop the `frame_format` field. The existing test fixture `video_scenes` in `tests/test_video_scene.py` uses `from_json` to reconstruct scenes, so any scene with a `frame_format` set will lose that value.

```suggestion
        return cls(
            reference_id=payload[REFERENCE_ID_KEY],
            frame_rate=payload.get(FRAME_RATE_KEY, None),
            items=items,
            metadata=payload.get(METADATA_KEY, {}),
            video_location=payload.get(VIDEO_URL_KEY, None),
            tracks=tracks,
            frame_format=payload.get(FRAME_FORMAT_KEY, None),
        )
```

How can I resolve this? If you propose a fix, please make it concise.

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.

2 participants