Skip to content

Add ability to disable looping in holistic replay - #1834

Open
asahtik wants to merge 4 commits into
developfrom
feature/disable_loop_holistic_replay
Open

Add ability to disable looping in holistic replay#1834
asahtik wants to merge 4 commits into
developfrom
feature/disable_loop_holistic_replay

Conversation

@asahtik

@asahtik asahtik commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Purpose

Specification

None / not applicable

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

None / not applicable

AI Usage

Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]

Submitted code was reviewed by a human: YES/NO

The author is taking the responsibility for the contribution: YES/NO

Summary by CodeRabbit

  • New Features

    • Added DEPTHAI_REPLAY_LOOP environment variable to control recorded replay looping behavior (enabled by default).
    • Replay looping is now applied consistently to both video and metadata-only recorded replay modes.
  • Bug Fixes / Improvements

    • Updated replay shutdown behavior to delay pipeline stopping when playback reaches end-of-file.
  • Documentation

    • Updated the README environment variables table to include DEPTHAI_REPLAY_LOOP.

Copilot AI review requested due to automatic review settings June 3, 2026 12:48
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds environment-controlled replay looping, applies it to video and metadata-only replay nodes, documents the setting, and delays pipeline shutdown by five seconds when replay reaches end of file.

Changes

Replay Behavior

Layer / File(s) Summary
Replay loop configuration
src/opencv/HolisticRecordReplay.cpp, README.md
Reads DEPTHAI_REPLAY_LOOP with looping enabled by default, applies it to video and metadata-only replay nodes, and documents the variable.
Delayed replay shutdown
src/pipeline/node/host/Replay.cpp
Adds a five-second wait before stopping the pipeline in video and metadata-only end-of-file paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: matictonin

Poem

A rabbit loops through frames with cheer,
While metadata follows near.
At file’s end, a pause takes flight,
Then pipelines stop after five seconds’ night. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a way to disable looping in holistic replay.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/disable_loop_holistic_replay

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copilot AI left a comment

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.

Pull request overview

Adds an environment-variable switch to control whether holistic replay loops, allowing users to disable looping without code changes.

Changes:

  • Read DEPTHAI_REPLAY_LOOP (default: enabled) when setting up holistic replay.
  • Apply the loop setting to both ReplayVideo and ReplayMetadataOnly nodes created during holistic replay setup.
  • Document the new environment variable in the README.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/opencv/HolisticRecordReplay.cpp Reads DEPTHAI_REPLAY_LOOP and propagates it to replay nodes via setLoop(...).
README.md Documents DEPTHAI_REPLAY_LOOP in the environment variable table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Line 238: Update the README entry for DEPTHAI_REPLAY_LOOP to show how to
disable looping: state it's ON by default and that setting the environment
variable DEPTHAI_REPLAY_LOOP to a falsy value (e.g. 0, false, no, off —
case-insensitive) will disable looping, matching the boolean style used for
DEPTHAI_TELEMETRY; reference the DEPTHAI_REPLAY_LOOP variable name so readers
can find and use it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 66023c8e-a288-499a-b63e-eb3cde0c6ea9

📥 Commits

Reviewing files that changed from the base of the PR and between 314a2c4 and d51b385.

📒 Files selected for processing (2)
  • README.md
  • src/opencv/HolisticRecordReplay.cpp
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: copilot-pull-request-reviewer
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: MaticTonin
Repo: luxonis/depthai-core PR: 1732
File: src/pipeline/Pipeline.cpp:662-662
Timestamp: 2026-03-24T22:39:00.650Z
Learning: In `src/pipeline/Pipeline.cpp`, the `DEPTHAI_AUTOCALIBRATION` environment variable intentionally defaults to `"ON_START"` (not `""`). This means auto-calibration is initialized by default for stereo pipelines at pipeline build time. The resulting implicit EEPROM/calibration writes on startup are by design and should not be flagged as a backward-incompatible change or unintended side-effect in future reviews.
Learnt from: MaticTonin
Repo: luxonis/depthai-core PR: 1753
File: src/pipeline/Pipeline.cpp:834-839
Timestamp: 2026-04-16T01:04:34.569Z
Learning: In `src/pipeline/Pipeline.cpp` (`PipelineImpl::build()`), when `autoCalibrationModeSetByApi` is false, `DEPTHAI_AUTOCALIBRATION` is read with an empty-string default (`""`). If the env var is unset or explicitly empty, `autoCalibrationMode` falls back to the pipeline-configured default (`ON_START`). This means an explicitly empty env var no longer disables auto-calibration — it simply defers to the API/default mode. This behavior is intentional and should not be flagged in future reviews.
📚 Learning: 2026-03-24T22:39:00.650Z
Learnt from: MaticTonin
Repo: luxonis/depthai-core PR: 1732
File: src/pipeline/Pipeline.cpp:662-662
Timestamp: 2026-03-24T22:39:00.650Z
Learning: In `src/pipeline/Pipeline.cpp`, the `DEPTHAI_AUTOCALIBRATION` environment variable intentionally defaults to `"ON_START"` (not `""`). This means auto-calibration is initialized by default for stereo pipelines at pipeline build time. The resulting implicit EEPROM/calibration writes on startup are by design and should not be flagged as a backward-incompatible change or unintended side-effect in future reviews.

Applied to files:

  • README.md
  • src/opencv/HolisticRecordReplay.cpp
📚 Learning: 2026-04-16T01:04:34.569Z
Learnt from: MaticTonin
Repo: luxonis/depthai-core PR: 1753
File: src/pipeline/Pipeline.cpp:834-839
Timestamp: 2026-04-16T01:04:34.569Z
Learning: In `src/pipeline/Pipeline.cpp` (`PipelineImpl::build()`), when `autoCalibrationModeSetByApi` is false, `DEPTHAI_AUTOCALIBRATION` is read with an empty-string default (`""`). If the env var is unset or explicitly empty, `autoCalibrationMode` falls back to the pipeline-configured default (`ON_START`). This means an explicitly empty env var no longer disables auto-calibration — it simply defers to the API/default mode. This behavior is intentional and should not be flagged in future reviews.

Applied to files:

  • README.md
  • src/opencv/HolisticRecordReplay.cpp
🔇 Additional comments (2)
src/opencv/HolisticRecordReplay.cpp (2)

472-472: LGTM!

Also applies to: 496-496


452-452: ⚡ Quick win

getEnvAs call is valid (2-argument overload exists).
src/utility/Environment.hpp defines template <typename T> T getEnvAs(const std::string& var, T defaultValue, bool cache = true), which forwards to the logger-backed overload, so utility::getEnvAs<bool>("DEPTHAI_REPLAY_LOOP", true) compiles.

Comment thread README.md
| DEPTHAI_ZOO_MODELS_PATH | (Default) depthai_models - Folder where zoo model description files are stored |
| DEPTHAI_RECORD | Enables holistic record to the specified directory. |
| DEPTHAI_REPLAY | Replays holistic replay from the specified file or directory. |
| DEPTHAI_REPLAY_LOOP | Loops recorded data (ON by default). |

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.

🧹 Nitpick | 🔵 Trivial | 💤 Low value

Document how to disable looping.

The entry states looping is ON by default but doesn't tell users how to turn it off. Consider noting the accepted falsy values to match the style of other boolean entries (e.g. DEPTHAI_TELEMETRY).

📝 Suggested wording
-| DEPTHAI_REPLAY_LOOP | Loops recorded data (ON by default). |
+| DEPTHAI_REPLAY_LOOP | Loops recorded replay data. Enabled by default; set to `0` or `false` to disable. |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| DEPTHAI_REPLAY_LOOP | Loops recorded data (ON by default). |
| DEPTHAI_REPLAY_LOOP | Loops recorded replay data. Enabled by default; set to `0` or `false` to disable. |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 238, Update the README entry for DEPTHAI_REPLAY_LOOP to
show how to disable looping: state it's ON by default and that setting the
environment variable DEPTHAI_REPLAY_LOOP to a falsy value (e.g. 0, false, no,
off — case-insensitive) will disable looping, matching the boolean style used
for DEPTHAI_TELEMETRY; reference the DEPTHAI_REPLAY_LOOP variable name so
readers can find and use it.

@coderabbitai coderabbitai Bot left a comment

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/opencv/HolisticRecordReplay.cpp (1)

450-453: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Reset replay state when loop configuration parsing fails.

getEnvAs<bool> throws for invalid DEPTHAI_REPLAY_LOOP values, but recordConfig.state is already REPLAY. The catch block returns false without restoring the state, so callers can observe REPLAY after replay setup failed.

     } catch(const std::exception& e) {
+        recordConfig.state = RecordConfig::RecordReplayState::NONE;
         spdlog::warn("Replay disabled: {}", e.what());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/opencv/HolisticRecordReplay.cpp` around lines 450 - 453, Update the
replay setup flow around recordConfig.state and
utility::getEnvAs<bool>("DEPTHAI_REPLAY_LOOP", true) so parsing failures restore
recordConfig.state to its pre-replay value before returning false. Ensure the
catch path handles invalid DEPTHAI_REPLAY_LOOP values without leaving the object
in REPLAY state.
♻️ Duplicate comments (1)
README.md (1)

238-238: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document how to disable looping.

The entry states that looping is enabled by default but does not explain how to turn it off. Document values such as 0, false, or off so users can configure the new behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 238, Update the DEPTHAI_REPLAY_LOOP entry in README.md to
document that looping is enabled by default and can be disabled by configuring
the variable with values such as 0, false, or off.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/opencv/HolisticRecordReplay.cpp`:
- Around line 450-453: Update the replay setup flow around recordConfig.state
and utility::getEnvAs<bool>("DEPTHAI_REPLAY_LOOP", true) so parsing failures
restore recordConfig.state to its pre-replay value before returning false.
Ensure the catch path handles invalid DEPTHAI_REPLAY_LOOP values without leaving
the object in REPLAY state.

---

Duplicate comments:
In `@README.md`:
- Line 238: Update the DEPTHAI_REPLAY_LOOP entry in README.md to document that
looping is enabled by default and can be disabled by configuring the variable
with values such as 0, false, or off.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8007fd9c-123a-4c71-846f-a291d4d6cd34

📥 Commits

Reviewing files that changed from the base of the PR and between d51b385 and 04e3109.

📒 Files selected for processing (3)
  • README.md
  • src/opencv/HolisticRecordReplay.cpp
  • src/pipeline/node/host/Replay.cpp
📜 Review details
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-03-24T22:39:04.364Z
Learnt from: MaticTonin
Repo: luxonis/depthai-core PR: 1732
File: src/pipeline/Pipeline.cpp:705-705
Timestamp: 2026-03-24T22:39:04.364Z
Learning: Do not flag the `!= ""` part of the auto-calibration condition as redundant when it appears in `PipelineImpl::build()` (or closely related pipeline build logic). If the code uses `utility::getEnvAs<std::string>(..., default)` with a default such as `"ON_START"`, the explicit empty-string guard may still be intentional to treat an explicitly empty env var as “OFF/disabled” (or to avoid special-casing elsewhere). Only consider removing `!= ""` if the codebase has an explicit, enforceable guarantee that `DEPTHAI_AUTOCALIBRATION` can never be set to an empty string (e.g., via validated parsing/CI checks); otherwise, keep the guard.

Applied to files:

  • src/pipeline/node/host/Replay.cpp
🔇 Additional comments (2)
src/opencv/HolisticRecordReplay.cpp (1)

27-27: LGTM!

Also applies to: 52-52, 98-98, 472-472, 496-496

src/pipeline/node/host/Replay.cpp (1)

2-2: LGTM!

Also applies to: 208-212, 299-300, 322-323, 450-451

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