Skip to content
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

Fix/restructure #173

Merged
merged 12 commits into from
Mar 5, 2025
Merged

Fix/restructure #173

merged 12 commits into from
Mar 5, 2025

Conversation

klemen1999
Copy link
Collaborator

Purpose

Restructures project structure so that the classes are accessable in similar pattern as with DepthAI.

Specification

Moved all messages and message creators under message. Nodes are now under node (for now only parsers are in their own folder).

Dependencies & Potential Impact

Previously:

from depthai_nodes import ParsingNeuralNetwork
from depthai_nodes import Classifications
from depthai_nodes import ClassificationParser

Now:

from depthai_nodes.node import ParsingNeuralNetwork
from depthai_nodes import Classifications
from depthai_nodes.node import ClassificationParser

Deployment Plan

This is a breaking change so when merged in all scripts (e.g. depthai-experiments) relying on unreleased, main branch of dai-nodes will faill because of import errors. So before merge we should have PRs on other relevant projects that depend on this one already made.

Testing & Validation

Tests were adjusted for the new structure.

@github-actions github-actions bot added examples Changes affecting examples. fix Fixing a bug labels Feb 9, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 9, 2025

Codecov Report

Attention: Patch coverage is 91.87817% with 16 lines in your changes missing coverage. Please review.

Project coverage is 38.63%. Comparing base (78903fc) to head (3ab33d4).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
depthai_nodes/node/parsers/utils/keypoints.py 13.33% 13 Missing ⚠️
depthai_nodes/node/parser_generator.py 83.33% 1 Missing ⚠️
depthai_nodes/node/parsers/utils/activations.py 75.00% 1 Missing ⚠️
depthai_nodes/node/tiles_patcher.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #173      +/-   ##
==========================================
+ Coverage   38.42%   38.63%   +0.21%     
==========================================
  Files          78       75       -3     
  Lines        4305     4253      -52     
==========================================
- Hits         1654     1643      -11     
+ Misses       2651     2610      -41     

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

Copy link

@PetrNovota PetrNovota left a comment

Choose a reason for hiding this comment

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

Good job on re-structuring the depthai_nodes package. The agreed upon user facing structure is there.

I try to avoid utils packages as much as possible, I think the top-level one, where the constants.py and logging.py are, should be removed. I would move the scripts to the top level.

The node.parsers.utils is a collection of many different things and again applies that the utils package is not a good solution, it doesn't say much about its contains. It's a collections of things we did not know where to put them. But we probably don't have the resources to do something about this atm.

What is the motivation behind creating the creators package in the messages? To me, it just looks like what should be part of the class constructors has been moved to separate functions for some reason. I don't see why this is needed. Things that belong together should be together. Object construction usually happens in the constructor of a class, so why not use it?

Copy link
Contributor

@dominik737 dominik737 left a comment

Choose a reason for hiding this comment

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

Looks good. As was suggested by Petr in the future it would be nice to get rid of the utils and alike folders in the repo. Also using the constructor instead of the functional creators would be nice in the future.

For now it's good that both these things that we would like to change in the future are quite internal to the library. Thus no big breaking changes affecting users will be introduced.

@klemen1999 klemen1999 marked this pull request as ready for review February 18, 2025 13:45
Copy link
Collaborator

@jkbmrz jkbmrz left a comment

Choose a reason for hiding this comment

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

Generally LGTM. However, I'm wondering what’s the reasoning behind having the node directory at the top level of depthai_nodes? It feels a bit odd. Would it make sense to move parsers to the top level and rename node to helpers instead? That way, the imports would be more intuitive:

  • depthai_nodes.message
  • depthai_nodes.parsers
  • depthai_nodes.helpers

Additionally, I’d recommend using plural forms for module names (e.g., message → messages, node → nodes) since the modules contain multiple related classes or functions.

@klemen1999
Copy link
Collaborator Author

@jkbmrz
Main reason is that we want to "mimic" how depthai already does it so we have same pattern of accesing "same things". And how DAI does it is: Messages are importable top level like depthai.ImgDetections() and all nodes are importable like depthai.node.NeuralNetwork().
And same reasoning goes for plural vs singular - DAI has singular so we want to be inline with them.

Copy link
Collaborator

@kkeroo kkeroo left a comment

Choose a reason for hiding this comment

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

LGTM. One note: inside node folder we have parsers folder where parsers are but other "host nodes" like DepthMerger are left in the node folder. In the future we should probably move them to separate subfolder when there will be a lot of such nodes?

@dominik737
Copy link
Contributor

@kkeroo
Yes, the idea is that now there are a few nodes and no meaningful groups can be formed yet. When we have more nodes we should be able to group them into subfolders.

@klemen1999 klemen1999 merged commit bbee6ac into main Mar 5, 2025
11 checks passed
@klemen1999 klemen1999 deleted the fix/restructure branch March 5, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Changes affecting examples. fix Fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants