Add frame_format parameter to VideoScene for PNG support#451
Add frame_format parameter to VideoScene for PNG support#451
Conversation
7278cf5 to
5066528
Compare
- 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
5066528 to
6341865
Compare
|
To be merged after https://github.com/scaleapi/scaleapi/pull/132674. |
| 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] |
There was a problem hiding this comment.
Why is this considered broken?
There was a problem hiding this comment.
CLIENT.get_job(fetch_id)
Throws a 401 error. Honestly no one uses Nucleus jobs anymore though perhaps you'll use it for deduping.
|
@greptileai review this PR |
Additional Comments (1)
Prompt To Fix With AIThis 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. |
Greptile Summary
This PR adds an optional
frame_formatparameter toVideoSceneto support PNG (lossless) frame extraction when uploading videos viavideo_location, defaulting to JPEG. It also bumps the version to 0.17.12 and removes a broken integration test.VideoScene.from_json()was not updated to deserialize the newframe_formatfield, so round-tripping throughto_payload()→from_json()will silently drop it.validate()method does not enforce thatframe_formatis one of the documented valid values ("jpeg"or"png").frame_formatparameter (e.g., verifying serialization/deserialization or validation of invalid values).test_job_listing_and_retrieval) is unrelated to the feature being added.Confidence Score: 2/5
from_json()that will cause data loss when round-tripping VideoScenes withframe_formatset.from_json()method was not updated alongsideto_payload(), creating an asymmetry whereframe_formatis 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 usefrom_json). Additionally, there are no new tests for the feature.nucleus/scene.py— thefrom_json()method needs to be updated to includeframe_format, andvalidate()should enforce valid values.Important Files Changed
frame_formatfield and serialization into_payload(), butfrom_json()does not deserialize it, breaking round-trip consistency. Also lacks input validation for the new parameter.FRAME_FORMAT_KEYconstant in alphabetical order. Clean, no issues.frame_formatparameter with a usage example. Well-formatted.test_job_listing_and_retrievalintegration test described as broken. No replacement test added for the newframe_formatfeature.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)Last reviewed commit: 6341865