Exemple #1
0
def discover_preferences_pluggables():
    """
    Discovers the pluggable modules on the directory and subdirectories of the preferences package
    and attempts to register them. Pluggable modules should subclass Pluggable Base classes.
    """
    from qiskit_aqua_cmd import Preferences
    preferences = Preferences()
    packages = preferences.get_packages([])
    for package in packages:
        try:
            mod = importlib.import_module(package)
            if mod is not None:
                _discover_local_pluggables(os.path.dirname(mod.__file__),
                                           mod.__name__,
                                           names_to_exclude=['__main__'],
                                           folders_to_exclude=['__pycache__'])
            else:
                # Ignore package that could not be initialized.
                # print('Failed to import package {}'.format(package))
                logger.debug('Failed to import package {}'.format(package))
        except Exception as e:
            # Ignore package that could not be initialized.
            # print('Failed to load package {} error {}'.format(package, str(e)))
            logger.debug('Failed to load package {} error {}'.format(
                package, str(e)))
Exemple #2
0
def _get_logging_names():
    names = OrderedDict()
    names['qiskit_aqua'] = None
    preferences = AquaPreferences()
    packages = preferences.get_packages([])
    for package in packages:
        names[package] = None

    return list(names.keys())