Esempio n. 1
0
    def test_print_process_info(self):
        """Test the `print_process_info` method."""
        from aiida.cmdline.utils.common import print_process_info
        from aiida.common.utils import Capturing
        from aiida.engine import Process

        class TestProcessWithoutDocstring(Process):
            # pylint: disable=missing-docstring

            @classmethod
            def define(cls, spec):
                super(TestProcessWithoutDocstring, cls).define(spec)
                spec.input('some_input')

        class TestProcessWithDocstring(Process):
            """Some docstring."""
            @classmethod
            def define(cls, spec):
                super(TestProcessWithDocstring, cls).define(spec)
                spec.input('some_input')

        # We are just checking that the command does not except
        with Capturing():
            print_process_info(TestProcessWithoutDocstring)
            print_process_info(TestProcessWithDocstring)
Esempio n. 2
0
def plugin_list(entry_point_group, entry_point):
    """Display a list of all available plugins."""
    from aiida.common import EntryPointError
    from aiida.cmdline.utils.common import print_process_info
    from aiida.engine import Process
    from aiida.plugins.entry_point import get_entry_point_names, load_entry_point

    if entry_point_group is None:
        echo.echo_info('Available entry point groups:')
        for group in sorted(ENTRY_POINT_GROUP_TO_MODULE_PATH_MAP.keys()):
            echo.echo('* {}'.format(group))

        echo.echo('')
        echo.echo_info(
            'Pass one of the groups as an additional argument to show the registered plugins'
        )
        return

    if entry_point:
        try:
            plugin = load_entry_point(entry_point_group, entry_point)
        except EntryPointError as exception:
            echo.echo_critical(str(exception))
        else:
            try:
                if (inspect.isclass(plugin) and issubclass(
                        plugin, Process)) or plugin.is_process_function:
                    print_process_info(plugin)
                else:
                    echo.echo(str(plugin.get_description()))
            except AttributeError:
                echo.echo_error(
                    'No description available for {}'.format(entry_point))
    else:
        entry_points = get_entry_point_names(entry_point_group)
        if entry_points:
            echo.echo(
                'Registered entry points for {}:'.format(entry_point_group))
            for registered_entry_point in entry_points:
                echo.echo('* {}'.format(registered_entry_point))

            echo.echo('')
            echo.echo_info(
                'Pass the entry point as an argument to display detailed information'
            )
        else:
            echo.echo_error(
                'No plugins found for group {}'.format(entry_point_group))