common.py 462 Bytes
Newer Older
1
2
3
4
#  SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#  SPDX-License-Identifier: Apache-2.0

import importlib
5
import importlib.util
6
7
8
9
10
11
12
13
14
15
16


def check_module_available(module_name: str) -> bool:
    """For tests / pre-commit"""
    if importlib.util.find_spec(module_name) is None:
        return False
    try:
        importlib.import_module(module_name)
        return True
    except ImportError:
        return False