Skip to content

Comments

Snaps update#272

Open
FSAFTik wants to merge 4 commits intomainfrom
snaps_update
Open

Snaps update#272
FSAFTik wants to merge 4 commits intomainfrom
snaps_update

Conversation

@FSAFTik
Copy link
Contributor

@FSAFTik FSAFTik commented Jan 14, 2026

Purpose

Update of SnapsUploader Node and SnapData Message

Specification

Update to the Snaps Uploader node to expose all the snaps related methods of the dai.EventsManager + removal of unrelated methods. Changed structure of SnapData to use dai.FileGroup

Dependencies & Potential Impact

After merge and release, apps and examples who use SnapData will need to migrate to new SnapData structure. Also set_url method of SnapsUploader is removed, check for usage

Deployment Plan

Change oak-examples examples who use SnapData or SnapsUploader to be compatible with new versions

Testing & Validation

Tested manually with data-collection application + with unit tests

@FSAFTik FSAFTik marked this pull request as ready for review January 14, 2026 14:59
@FSAFTik FSAFTik requested review from PetrNovota and Copilot and removed request for kkeroo, klemen1999 and tersekmatija January 14, 2026 14:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the SnapsUploader node and SnapData message to better align with the DepthAI Hub Events API. The key change is migrating from individual frame/detections parameters to using dai.FileGroup for more flexible data handling.

Changes:

  • Refactored SnapData to use dai.FileGroup instead of separate frame, file_name, and detections parameters
  • Updated SnapsUploader to use camelCase method names (setToken, setCacheDir, setCacheIfCannotSend, setLogResponse) and removed set_url method
  • Updated all tests to work with the new SnapData structure and added test coverage for new SnapsUploader methods

Reviewed changes

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

File Description
depthai_nodes/message/snap_data.py Simplified constructor to accept file_group parameter instead of individual frame/detections, updated documentation
depthai_nodes/node/snaps_uploader.py Renamed methods to camelCase, removed set_url, added new configuration methods (setCacheDir, setCacheIfCannotSend, setLogResponse), simplified process logic
tests/unittests/test_messages/test_snap_data.py Updated all test cases to use dai.FileGroup, removed mutability tests for removed fields, added new tests for multiple files in group
tests/unittests/test_nodes/test_host_nodes/test_snaps_uploader_node.py Restructured tests, added coverage for new methods, removed tests for deleted set_url functionality, improved test assertions

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

def set_token(self, token: str):
os.environ.setdefault("DEPTHAI_HUB_API_KEY", token)
def setToken(self, token: str):
os.environ["DEPTHAI_HUB_API_KEY"] = token
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

The setToken method unconditionally overwrites the environment variable. If the token is already set, this will silently replace it. Consider either using setdefault (as before) or adding a parameter to control the overwrite behavior, or logging when an existing token is being replaced.

Copilot uses AI. Check for mistakes.
def setCacheDir(self, cacheDir: str):
"""Set the cache directory for storing cached data.

By default, the cache directory is set to /internal/private
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

Documentation formatting inconsistency: this comment doesn't end with a period, while the comments in setCacheIfCannotSend (line 35) and setLogResponse (line 44) do. Maintain consistent punctuation in docstrings.

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 45
By default, logResponse is set to false. Logs are visible in depthAI logs with
INFO level.
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

Corrected capitalization of 'DepthAI' to match the standard product name formatting (should be 'DepthAI' not 'depthAI').

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +79 to +82
uploader._em.setCacheDir.assert_called_once_with("/custom/cache/path")
mock_snaps_uploader_logger.info.assert_called_with(
"Set cache directory to: /custom/cache/path"
)
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

The test verifies that setCacheDir calls the underlying _em.setCacheDir and logs appropriately, but doesn't test the behavior with invalid paths (e.g., None, empty string). Consider adding edge case tests for input validation.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI commented Jan 14, 2026

@FSAFTik I've opened a new pull request, #273, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

3 participants