caikit.core.toolkit.compatibility ================================= .. py:module:: caikit.core.toolkit.compatibility Attributes ---------- .. autoapisummary:: caikit.core.toolkit.compatibility.log caikit.core.toolkit.compatibility.error Functions --------- .. autoapisummary:: caikit.core.toolkit.compatibility.unsupported_platforms caikit.core.toolkit.compatibility.is_importable_on_platform Module Contents --------------- .. py:data:: log .. py:data:: error .. py:function:: unsupported_platforms(platforms) This decorator can be used to raise NotImplementedError if it's run on a given platform. Otherwise it runs as normal. For guidance on different permissible values of platforms, see: https://docs.python.org/3/library/sys.html#sys.platform Args: platforms (List | Tuple | str): Platforms on which this capability is not implemented. .. py:function:: is_importable_on_platform(module, package, exc_type, platforms, platform_hint) Some modules have trouble on specific operating systems. This function takes a module and package from which we want to import, and an exception type to look out for on a given problem. If the exception is raised, we warn the platform hint. NOTE: This function does set any properties on your package. You should use this function to check if something is importable, then you should import it. This will only run the package initialization one time, because this function will add your module into the loaded packages if it's successful, but doing things this way prevents your package from having a bunch of undesirable attributes and keeps it cleaner than other approaches. It also ensures that the import stack trace doesn't look abnormally handled if we raise on other platforms. Args: module (str): Module that we want to import. package (str): Package from which we want to import the module. exc_type (Exception): Exception that we want to warn a hint for if we hit it on import for a given platform. platforms (str): Platform on which we expect potential bad import from for this module. platform_hint (str): Hint to warn if we hit the exception type on the provided platform.