Skip to content

Logger in all nodes. #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 2, 2025
Merged

Logger in all nodes. #217

merged 7 commits into from
Jun 2, 2025

Conversation

kkeroo
Copy link
Collaborator

@kkeroo kkeroo commented May 29, 2025

Purpose

We dont have any logs in events happening inside nodes/parsers which is not the best when we will inspect users pipelines. Ideally, we should add something similar to DAI debug logging.

Specification

We add logger to every parser/node and debug few events:

  • node initialization with default params
  • node build with params
  • setting the parser attrs. via setters
  • entry in the main run function
  • everytime new input data is received
  • everytime when msg is created
  • everytime when msg is sent to the output

We also add logging (info, debug) in the E2E tests.

Example of output in E2E test:

[2025-05-29 14:06:11] [depthai-nodes] [INFO] [depthai-nodes] Using log level: LogLevel.DEBUG
[2025-05-29 14:06:13] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (1) Connected to device with IP/mxid: 
[2025-05-29 14:06:13] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (2) Camera node created.
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (3) NN archive downloaded.
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (4) NN archive loaded.
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.depthai_nodes.node.parsing_neural_network] ParsingNeuralNetwork initialized
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] DetectionParser initialized with conf_threshold=0.80, iou_threshold=0.30, max_det=5000
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] YuNetParser initialized with conf_threshold=0.80, iou_threshold=0.30, max_det=5000
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] DetectionParser built with conf_threshold=0.60, iou_threshold=0.30, max_det=5000
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] YuNetParser built with input_size=(320, 240), layout='NCHW'
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.depthai_nodes.node.parsing_neural_network] ParsingNeuralNetwork built with fps=20.0, type_of_nn_source=NNArchive, parsers=1
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (5) ParsingNeuralNetwork node created.
[2025-05-29 14:06:15] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (6) Parser output queues created.
[2025-05-29 14:06:16] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (7) Pipeline started.
[2025-05-29 14:06:16] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] YuNetParser run started
[2025-05-29 14:06:16] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] (8) Pipeline is running.
[2025-05-29 14:06:16] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] Processing input with layers: ['conf', 'iou', 'loc']
[2025-05-29 14:06:16] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] Created detections message with 1 faces
[2025-05-29 14:06:16] [depthai-nodes] [DEBUG] [depthai-nodes.YuNetParser] Detections message sent successfully
[2025-05-29 14:06:16] [depthai-nodes] [DEBUG] [depthai-nodes.__main__] Parser output 0 - <class 'depthai_nodes.message.img_detections.ImgDetectionsExtended'>
PASSED

Debug logging is triggered by:

DEPTHAI_NODES_LEVEL=debug python main.py

or with standard DAI debug mode:

DEPTHAI_LEVEL=debug python main.py

allowing us to get the debug logs for all the pipeline components (native DAI nodes & depthai-nodes parsers).

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

None / not applicable

@github-actions github-actions bot added the enhancement New feature or request label May 29, 2025
@codecov-commenter
Copy link

codecov-commenter commented May 29, 2025

Codecov Report

Attention: Patch coverage is 30.52632% with 198 lines in your changes missing coverage. Please review.

Project coverage is 53.31%. Comparing base (36debf4) to head (406b3c1).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
depthai_nodes/node/parsers/xfeat.py 0.00% 28 Missing ⚠️
depthai_nodes/node/parsers/fastsam.py 0.00% 17 Missing ⚠️
depthai_nodes/node/parsers/yolo.py 11.76% 15 Missing ⚠️
depthai_nodes/node/parsers/lane_detection.py 0.00% 11 Missing ⚠️
depthai_nodes/node/parsers/mlsd.py 0.00% 11 Missing ⚠️
depthai_nodes/node/parsers/keypoints.py 16.66% 10 Missing ⚠️
depthai_nodes/node/parsers/scrfd.py 0.00% 10 Missing ⚠️
...thai_nodes/node/parsers/classification_sequence.py 0.00% 9 Missing ⚠️
depthai_nodes/node/parsers/image_output.py 0.00% 8 Missing ⚠️
depthai_nodes/node/parsers/map_output.py 0.00% 8 Missing ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
- Coverage   53.62%   53.31%   -0.31%     
==========================================
  Files          87       87              
  Lines        5205     5488     +283     
==========================================
+ Hits         2791     2926     +135     
- Misses       2414     2562     +148     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kkeroo
Copy link
Collaborator Author

kkeroo commented May 29, 2025

I am looking into having this logging in one place because its quite repetitive but I didnt come with a totally general solution. Any ideas are welcome.

One thing that is possible is to have python decorator for setters (very repetitive pattern) which will log the parameter that we set.

@klemen1999 klemen1999 marked this pull request as ready for review June 2, 2025 08:02
@klemen1999 klemen1999 merged commit 80ff6f0 into main Jun 2, 2025
12 checks passed
@klemen1999 klemen1999 deleted the feat/logging branch June 2, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants