Skip to content

Conversation

swheaton
Copy link
Contributor

@swheaton swheaton commented Oct 14, 2025

What changes are proposed in this pull request?

Pipeline type was messed up on-disk in a way that unit tests didn't catch but voxelhub did. This fixes that discrepancy.

How is this patch tested? If it is not, please explain why.

Added more unit tests

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • Refactor

    • Pipeline JSON format changed to an object with a "stages" field instead of a plain list; serialization and deserialization use this shape and default to an empty "stages" list when absent.
  • Tests

    • Added and updated unit tests for pipeline and stage creation, ordering, serialization/deserialization, round-trip behavior, and validation (e.g., missing operator, non-positive distributed task counts).

@swheaton swheaton requested review from a team as code owners October 14, 2025 19:02
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Pipeline JSON shape changed from a list to a dict with a top-level "stages" key; Pipeline.from_json now accepts that dict and Pipeline.to_json returns {"stages": [...]}. Unit tests added for Pipeline/PipelineStage creation, staging, serialization round-trip, and validation errors.

Changes

Cohort / File(s) Summary
Pipeline JSON contract change
fiftyone/operators/_types/pipeline.py
from_json signature changed to accept a dict and read stages from json_dict.get("stages", []); to_json now returns a dict {"stages": [...]} (previously a list); docstrings/examples updated; serialization uses dataclasses.asdict(self).
Operator types unit tests
tests/unittests/operators/types_tests.py
Added tests covering Pipeline and PipelineStage construction, staging order via constructor and .stage(), serialization (to_json) and deserialization (from_json) with the new dict format, and validation errors for missing or invalid operator_uri and num_distributed_tasks.
Factory doc test adjustment
tests/unittests/factory/delegated_operation_doc_tests.py
Updated assertion to compare the serialized pipeline field against op_doc.pipeline.to_json() instead of manual per-element dicts, reflecting the canonical pipeline JSON representation and preserving round-trip comparison via from_pymongo.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Pipeline
    participant JSON as "JSON Dict\n{\"stages\": [...]}"

    Note over Pipeline,JSON: Serialization (new shape)
    Client->>Pipeline: to_json()
    Pipeline-->>Client: {"stages": [ stage_json, ... ]}

    Note over Pipeline,JSON: Deserialization (new input)
    Client->>Pipeline: from_json({"stages": [ stage_json, ... ]})
    Pipeline-->>Client: Pipeline(stages=[...])
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit taps keys with a curious hop,
Packing stages tidy in one little top—
"stages" in a dict, neat rows in a line,
Tests sniff and hop, then give them a sign.
Hooray for small changes that make JSON fine. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly highlights the primary change—fixing the Pipeline type’s JSON serialization and deserialization—and directly relates to the core update in the changeset. It is concise, clear, and focused on the main purpose of the pull request.
Description Check ✅ Passed The pull request description follows the repository template by including the required headings for proposed changes, testing details, release notes, and affected areas, and each section is properly filled out with relevant information.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/foepd-1417-fix-pipeline-type

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6a90d8 and 5240c39.

📒 Files selected for processing (2)
  • fiftyone/operators/_types/pipeline.py (1 hunks)
  • tests/unittests/factory/delegated_operation_doc_tests.py (1 hunks)
🔇 Additional comments (3)
fiftyone/operators/_types/pipeline.py (2)

117-130: LGTM!

The implementation correctly uses dataclasses.asdict(self) to produce the dict format with "stages" key. This is clean and maintainable.


99-115: LGTM! Verify all call sites are updated.

The implementation correctly handles the new dict format with a "stages" key. The use of json_dict.get("stages") or [] properly handles missing keys and None values, and PipelineStage validation will catch invalid stage data.

However, since this is a breaking API change (from accepting a list to accepting a dict), ensure all call sites have been updated accordingly.

Run the following script to verify all call sites of Pipeline.from_json() are passing a dict:

tests/unittests/factory/delegated_operation_doc_tests.py (1)

72-72: LGTM! Improved test maintainability.

Excellent change to use op_doc.pipeline.to_json() instead of manually constructing the expected dict. This makes the test more maintainable and accurately tests the actual serialization output. The round-trip verification on line 75 ensures deserialization works correctly.

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@CamronStaley CamronStaley left a comment

Choose a reason for hiding this comment

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

:shipit:

@swheaton swheaton merged commit 1a712cf into develop Oct 15, 2025
20 checks passed
@swheaton swheaton deleted the fix/foepd-1417-fix-pipeline-type branch October 15, 2025 20:06
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