"nndet/models/encoder/abstract.py" did not exist on "94d6ac2085a4b95261d7de63ea8f71c26b1aec7b"
build_ntops.py 1.18 KB
Newer Older
1
import concurrent.futures
Jiacheng Huang's avatar
Jiacheng Huang committed
2
3
4
5
6
7
8
9
10
11
12
13
14
import importlib
import pathlib

from infiniop.ninetoothed.build import BUILD_DIRECTORY_PATH

CURRENT_FILE_PATH = pathlib.Path(__file__)

SRC_DIR_PATH = CURRENT_FILE_PATH.parent.parent / "src"


def _find_and_build_ops():
    ops_path = SRC_DIR_PATH / "infiniop" / "ops"

15
16
    with concurrent.futures.ProcessPoolExecutor() as executor:
        futures = []
Jiacheng Huang's avatar
Jiacheng Huang committed
17

18
19
        for op_dir in ops_path.iterdir():
            ninetoothed_path = op_dir / "ninetoothed"
Jiacheng Huang's avatar
Jiacheng Huang committed
20

21
22
23
            if not ninetoothed_path.is_dir():
                continue

24
25
26
27
            build_file = ninetoothed_path / "build.py"
            if not build_file.exists():
                continue

28
29
            futures.append(executor.submit(_build, ninetoothed_path))

30
31
        for future in concurrent.futures.as_completed(futures):
            future.result()
32
33
34
35
36
37
38
39
40


def _build(ninetoothed_path):
    module_path = ninetoothed_path / "build"
    relative_path = module_path.relative_to(SRC_DIR_PATH)
    import_name = ".".join(relative_path.parts)
    module = importlib.import_module(import_name)

    module.build()
Jiacheng Huang's avatar
Jiacheng Huang committed
41
42
43


if __name__ == "__main__":
44
    BUILD_DIRECTORY_PATH.mkdir(parents=True, exist_ok=True)
Jiacheng Huang's avatar
Jiacheng Huang committed
45
46

    _find_and_build_ops()