dgl icon indicating copy to clipboard operation
dgl copied to clipboard

[Refactor?] Clean up and document the utility function usages

Open BarclayII opened this issue 3 years ago • 3 comments
trafficstars

🚀 Feature

(This is not really a "feature" request, but more like a code organization and refactor request) Clean up, organize, and document all the internal utility functions DGL uses, so that people can find the appropriate utility function to do their job easily.

Motivation

The issue is mainly for the dgl.utils namespace, where we have some issues that hampers readability and maintainability. I'm listing some but not all of them.

  • Index class is largely deprecated, as it is no longer used in dgl.heterograph and dgl.heterograph_index. It still appears in some places like dgl.partition, dgl.traversal etc. which are mostly old code.
  • CtxCachedObject is completely deprecated as it is only used in dgl._deprecate namespace.
  • There are build_relabel_map, build_relabel_dict, make_invmap, and relabel which are all related to "relabeling non-contiguous ID arrays to contiguous ID arrays", and it's hard to identify their differences. In particular, relabel and build_relabel_map have very similar code.
  • The dgl.utils.internal module is too bloated. There are 34 functions and 7 classes all having completely different purposes (set operations, relabeling, setting frames, recursion, etc.). We should at least group the functions and classes by their functionality, and preferably split them into smaller modules.

BarclayII avatar Aug 30 '22 06:08 BarclayII

Is there any tool to find those dead codes?

jermainewang avatar Aug 30 '22 10:08 jermainewang

lgtm might work

https://lgtm.com/projects/g/dmlc/dgl/

VoVAllen avatar Aug 31 '22 07:08 VoVAllen

This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you

github-actions[bot] avatar Oct 09 '22 01:10 github-actions[bot]

This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you

github-actions[bot] avatar Nov 09 '22 01:11 github-actions[bot]

This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you

github-actions[bot] avatar Nov 09 '22 01:11 github-actions[bot]