Skip to content

Conversation

@dachengx
Copy link
Collaborator

@dachengx dachengx commented Oct 5, 2024

What is the problem / what does the code in this PR do

Sometimes we want to know which plugin is higher in the dependency tree than another. This PR adds the tree_levels function of Context, which returns the dictionary containing relative information.

For Example, for a given class with Records, Peaks registered, the tree_levels will return:

{'records': {'level': 0, 'class': 'Records', 'index': 0, 'order': 0}, 'peaks': {'level': 1, 'class': 'Peaks', 'index': 0, 'order': 1}}

Can you briefly describe how it works?

Go through the dependency tree and assign level for the data_types first. The level of a data_type will be higher by at least 1 than its dependencies.

Then the data_types will be sorted by level, class, and index. Where the index is the index of this data_type in provides.

Can you give a minimal working example (or illustrate with a figure)?

Please include the following if applicable:

  • Update the docstring(s)
  • Update the documentation
  • Tests to check the (new) code is working as desired.
  • Does it solve one of the open issues on github?

Please make sure that all automated tests have passed before asking for a review (you can save the PR as a draft otherwise).

@coveralls
Copy link

coveralls commented Oct 5, 2024

Coverage Status

coverage: 90.302% (-0.03%) from 90.331%
when pulling 4a92b0d on level_in_dependency_tree
into ef2861e on master.

@dachengx dachengx marked this pull request as ready for review October 6, 2024 23:45
@dachengx dachengx requested a review from yuema137 October 7, 2024 06:57
@dachengx dachengx merged commit ad1c13e into master Oct 7, 2024
@dachengx dachengx deleted the level_in_dependency_tree branch October 7, 2024 18:35
dachengx added a commit that referenced this pull request May 9, 2025
* Add function of dependency level of `data_types`

* Cache results of tree_levels

* Minor simplify

* Minor change

* Add `get_dependency_plugins` to get the plugins of dependencies
initialized
dachengx added a commit that referenced this pull request May 9, 2025
* Add function of dependency level of `data_types`

* Cache results of tree_levels

* Minor simplify

* Minor change

* Add `get_dependency_plugins` to get the plugins of dependencies
initialized
dachengx added a commit that referenced this pull request May 9, 2025
* Add function of dependency level of `data_types`

* Cache results of tree_levels

* Minor simplify

* Minor change

* Add `get_dependency_plugins` to get the plugins of dependencies
initialized
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