skbase.lookup.get_package_metadata#
- skbase.lookup.get_package_metadata(package_name: str, path: str | None = None, recursive: bool = True, exclude_non_public_items: bool = True, exclude_non_public_modules: bool = True, modules_to_ignore: str | ~typing.List[str] | ~typing.Tuple[str] = ('tests', ), package_base_classes: type | ~typing.Tuple[type, ...] = (<class 'skbase.base._base.BaseObject'>, ), class_filter: type | ~typing.Sequence[type] | None = None, tag_filter: str | ~typing.Sequence[str] | ~typing.Mapping[str, ~typing.Any] | None = None, classes_to_exclude: type | ~typing.Sequence[type] | None = None, suppress_import_stdout: bool = True) Mapping[source]#
Return a dictionary mapping all package modules to their metadata.
- Parameters:
- package_namestr
The name of the package/module to return metadata for.
If path is not None, this should be the name of the package/module associated with the path. package_name (with “.” appended at end) will be used as prefix for any submodules/packages when walking the provided path.
If path is None, then package_name is assumed to be an importable package or module and the path to package_name will be determined from its import.
- pathstr, default=None
If provided, this should be the path that should be used as root to find any modules or submodules.
- recursivebool, default=True
Whether to recursively walk through submodules.
If True, then submodules of submodules and so on are found.
If False, then only first-level submodules of package are found.
- exclude_non_public_itemsbool, default=True
Whether to exclude nonpublic functions and classes (where name starts with a leading underscore).
- exclude_non_public_modulesbool, default=True
Whether to exclude nonpublic modules (modules where names start with a leading underscore).
- modules_to_ignorestr, tuple[str] or list[str], default=”tests”
The modules that should be ignored when searching across the modules to gather objects. If passed, all_objects ignores modules or submodules of a module whose name is in the provided string(s). E.g., if modules_to_ignore contains the string “foo”, then “bar.foo”, “foo”, “foo.bar”, “bar.foo.bar” are ignored.
- package_base_classes: type or Sequence[type], default = (BaseObject,)
The base classes used to determine if any classes found in metadata descend from a base class.
- class_filterobject or Sequence[object], default=None
Classes that klass is checked against. Only classes that are subclasses of the supplied class_filter are returned in metadata.
- tag_filterstr, Sequence[str] or dict[str, Any], default=None
Filter used to determine if klass has tag or expected tag values.
If a str or list of strings is provided, the return will be filtered to keep classes that have all the tag(s) specified by the strings.
If a dict is provided, the return will be filtered to keep classes that have all dict keys as tags. Tag values are also checked such that:
If a dict key maps to a single value only classes with tag values equal to the value are returned.
If a dict key maps to multiple values (e.g., list) only classes with tag values in these values are returned.
- classes_to_exclude: objects or iterable of object, default=None
Classes to exclude from returned metadata.
- Returns:
- module_info: dict
Mapping of string module name (key) to a dictionary of the module’s metadata. The metadata dictionary includes the following key:value pairs:
“path”: str path to the submodule.
“name”: str name of the submodule.
“classes”: dictionary with submodule’s class names (keys) mapped to dictionaries with metadata about the class.
“functions”: dictionary with function names (keys) mapped to dictionary with metadata about each function.
“__all__”: list of string code artifact names that appear in the submodules __all__ attribute
“authors”: contents of the submodules __authors__ attribute
“is_package”: whether the submodule is a Python package
“contains_concrete_class_implementations”: whether any module classes inherit from
BaseObjectand are not package_base_classes.“contains_base_classes”: whether any module classes that are package_base_classes.
“contains_base_objects”: whether any module classes that inherit from
BaseObject.
- Other Parameters:
- suppress_import_stdoutbool, default=True
Whether to suppress stdout printout upon import.