@@ -87,12 +87,16 @@ def find_top_level_packages(nemo_root: str) -> List[str]:
87
87
"""Find all top-level packages under nemo directory."""
88
88
packages : List [str ] = []
89
89
nemo_dir = os .path .join (nemo_root , 'nemo' )
90
+ tests_dir = os .path .join (nemo_root , 'tests' )
90
91
91
92
if not os .path .exists (nemo_dir ):
92
93
print (f"Warning: nemo directory not found at { nemo_dir } " )
93
94
return packages
95
+ if not os .path .exists (tests_dir ):
96
+ print (f"Warning: nemo directory not found at { nemo_dir } " )
97
+ return packages
94
98
95
- for item in os .listdir (nemo_dir ):
99
+ for item in os .listdir (nemo_dir ) + os . listdir ( tests_dir ) :
96
100
item_path = os .path .join (nemo_dir , item )
97
101
if os .path .isdir (item_path ) and not item .startswith ('__' ):
98
102
packages .append (item )
@@ -125,17 +129,18 @@ def build_dependency_graph(nemo_root: str) -> Dict[str, List[str]]:
125
129
126
130
dependencies : Dict [str , List [str ]] = {}
127
131
128
- # Second pass: analyze imports and build reverse dependencies
129
132
for file_path in find_python_files (nemo_root ):
130
133
relative_path = os .path .relpath (file_path , nemo_root )
131
134
parts = relative_path .split (os .sep )
132
135
133
- if len (parts ) == 1 or parts [- 1 ] == "__init__.py" or parts [0 ] != "nemo" :
136
+ if len (parts ) == 1 or parts [- 1 ] == "__init__.py" or ( parts [0 ] != "nemo" and parts [ 0 ] != "tests" ) :
134
137
continue
135
138
136
139
module_path = relative_path .replace (".py" , "" ).replace ("/" , "." )
137
140
if parts [1 ] in top_level_packages and parts [1 ] != 'collections' :
138
141
dependencies [module_path ] = list (set (analyze_imports (nemo_root , file_path )))
142
+ elif parts [0 ] == 'tests' :
143
+ dependencies [module_path ] = [relative_path ]
139
144
elif parts [1 ] == 'collections' :
140
145
dependencies [module_path ] = list (set (analyze_imports (nemo_root , file_path )))
141
146
@@ -181,7 +186,7 @@ def build_dependency_graph(nemo_root: str) -> Dict[str, List[str]]:
181
186
simplified_dependencies : Dict [str , List [str ]] = {}
182
187
for package , deps in dependencies .items ():
183
188
package_parts = package .split ('.' )
184
- print ( f" { os . path . join ( * package_parts [: - 1 ]) } .py" )
189
+
185
190
if os .path .isfile ((file_path := f"{ os .path .join (* package_parts [:- 1 ])} .py" )):
186
191
simplified_package_path = file_path
187
192
elif os .path .isdir ((file_path := f"{ os .path .join (* package_parts [:- 1 ])} " )):
@@ -221,13 +226,17 @@ def build_dependency_graph(nemo_root: str) -> Dict[str, List[str]]:
221
226
if "asr" in dep or "tts" in dep or "speechlm" in dep or "audio" in dep :
222
227
new_deps .append ("speech" )
223
228
224
- if "export" in dep or "deploy" in dep :
229
+ elif "export" in dep or "deploy" in dep :
225
230
new_deps .append ("export-deploy" )
226
231
227
- if "llm" in dep or "vlm" in dep or "automodel" in dep :
232
+ elif "llm" in dep or "vlm" in dep or "automodel" in dep :
228
233
new_deps .append ("automodel" )
229
234
230
- if "collections" in dep and not ("asr" in dep or "tts" in dep or "speechlm" in dep or "audio" in dep ):
235
+ elif "tests/collections" in dep :
236
+ new_deps .append ("unit-tests" )
237
+ continue
238
+
239
+ else :
231
240
new_deps .append ("nemo2" )
232
241
233
242
bucket_deps [package ] = sorted (list (set (new_deps )))
0 commit comments