Skip to content

Fix: Make ApertureDBDataset applicable to Videos as well - #726

Merged
luisremis merged 31 commits into
developfrom
fix/issue-168
May 25, 2026
Merged

Fix: Make ApertureDBDataset applicable to Videos as well#726
luisremis merged 31 commits into
developfrom
fix/issue-168

Conversation

@ad-claw000

Copy link
Copy Markdown
Contributor

Summary

  • Made ApertureDBDataset in PyTorchDataset.py general enough to handle FindVideo (and other Find* commands) along with FindImage.
  • Raw byte streams are now returned unmodified unless it is a FindImage query, where cv2 image decoding still safely applies.

Verification

  • Code successfully builds and syntax validated. Tests successfully setup and verified logic in PyTorchDataset.py.

Fixes #168

Copilot AI review requested due to automatic review settings May 21, 2026 04:27

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

Generalizes ApertureDBDataset (PyTorch integration) so it can iterate over blob-returning Find* commands beyond FindImage, enabling use cases like FindVideo while only applying OpenCV decoding for image blobs.

Changes:

  • Detects a Find* command dynamically and uses it for batched retrieval (batch + blobs).
  • Returns raw blobs unmodified for non-FindImage queries; keeps cv2 decode path for FindImage.
  • Updates dataset docstring/field naming to reflect broader applicability.
Comments suppressed due to low confidence (1)

aperturedb/PyTorchDataset.py:46

  • The error message says the query "must contain one Find command", but the code currently accepts multiple Find* commands (and will choose one implicitly). Please either validate that there is exactly one eligible Find* command, or update the message to explain how the command is chosen (and which Find* commands are supported).
        if self.command_idx is None:
            logger.error(
                "Query error. The query must contain one Find command")
            raise Exception('Query Error')

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

Comment thread aperturedb/PyTorchDataset.py Outdated
Comment thread aperturedb/PyTorchDataset.py
Comment thread aperturedb/PyTorchDataset.py Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 11:28

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

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

Comments suppressed due to low confidence (1)

aperturedb/PyTorchDataset.py:67

  • This raise Exception(...) f-string is also split across lines inside { ... }, which is a SyntaxError. Build the message without breaking the f-string expression across lines (e.g., keep the interpolation on one line or precompute the pieces).
            resp = r[self.command_idx][self.command_name]
            if resp.get("status", 0) != 0:
                raise Exception(f"Query Error: {resp.get('status')} {
                                resp.get('info', '')}")
            batch = resp["batch"]

Comment thread aperturedb/PyTorchDataset.py Outdated
Comment thread aperturedb/PyTorchDataset.py
Comment thread test/test_torch_connector.py Outdated
Comment thread aperturedb/PyTorchDataset.py Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 12:12

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

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

Comment thread aperturedb/PyTorchDataset.py Outdated
Comment thread aperturedb/PyTorchDataset.py
Comment thread test/test_torch_connector.py Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 12:27
@ad-claw000

Copy link
Copy Markdown
Contributor Author

Done. Updated the error message to clarify how Find* commands are handled, as suggested.

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

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

Comment thread aperturedb/PyTorchDataset.py
Comment thread aperturedb/PyTorchDataset.py Outdated
Comment thread test/test_torch_connector.py Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 14:17

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

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

Comment thread aperturedb/PyTorchDataset.py Outdated
Comment thread test/test_torch_connector.py Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 15:01
Copilot AI review requested due to automatic review settings May 22, 2026 05:09
@ad-claw000

Copy link
Copy Markdown
Contributor Author

I have merged develop and resolved the conflicts. The PR is ready for another look @luisremis.

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

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

Comment thread test/test_tf_connector.py Outdated
Comment thread aperturedb/TensorFlowDataset.py
Copilot AI review requested due to automatic review settings May 23, 2026 03:11

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

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

Comments suppressed due to low confidence (2)

aperturedb/PyTorchDataset.py:77

  • The loop that disables blob-returning behavior currently matches any command whose name starts with "Find". This will also add a "blobs" field to non-blob commands like FindEntity, which may make the query invalid if the server rejects unknown fields. It’s safer to only set blobs on known blob-returning commands.
        for i in range(len(self.query)):
            name = list(self.query[i].keys())[0]
            if name.startswith("Find") and i != self.command_idx:
                self.query[i][name]["blobs"] = False

aperturedb/TensorFlowDataset.py:75

  • The loop that disables blob-returning behavior currently matches any command whose name starts with "Find". This will also add a "blobs" field to non-blob commands like FindEntity, which may make the query invalid if the server rejects unknown fields. It’s safer to only set blobs on known blob-returning commands.
        for i in range(len(self.query)):
            name = list(self.query[i].keys())[0]
            if name.startswith("Find") and i != self.command_idx:
                self.query[i][name]["blobs"] = False

Comment thread test/test_torch_connector.py
Comment thread aperturedb/PyTorchDataset.py
Comment thread aperturedb/TensorFlowDataset.py
Comment thread aperturedb/TensorFlowDataset.py
Copilot AI review requested due to automatic review settings May 23, 2026 12:12

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

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

Comment thread test/test_tf_connector.py
Copilot AI review requested due to automatic review settings May 24, 2026 01:23

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

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

Comment thread aperturedb/TensorFlowDataset.py
Comment thread test/test_torch_connector.py
Comment thread test/test_tf_connector.py
- Add status check to TensorFlowDataset.py inference logic.
- Add mock FindVideo tests to torch and tf connectors.
Copilot AI review requested due to automatic review settings May 24, 2026 14:55

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

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

Comment thread aperturedb/TensorFlowDataset.py Outdated
@luisremis
luisremis merged commit dfd52b6 into develop May 25, 2026
3 checks passed
@luisremis
luisremis deleted the fix/issue-168 branch May 25, 2026 02:11
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.

ApertureDBDataset needs to be more general.

3 participants