Last active
May 27, 2020 12:44
-
-
Save WaylonWalker/2f1da8d47e511d188c50b8cccb7e3856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# full article https://waylonwalker.com/blog/creating-the-kedro-preflight-hook/ | |
from kedro.hooks import hook_impl | |
from kedro.io.core import DataSetNotFoundError | |
from colorama import Fore | |
import textwrap | |
@hook_impl | |
def before_pipeline_run(run_params, pipeline, catalog): | |
missing_input = [i for i in pipeline.inputs() if not getattr(catalog.datasets, i)._exists()] | |
if len(missing_input) != 0: | |
raise DataSetNotFoundError(textwrap.dedent(f''' | |
{Fore.LIGHTBLACK_EX}―――――――― {Fore.RED}PREFLIGHT ERROR {Fore.LIGHTBLACK_EX}――――――――― | |
{Fore.RESET} preflight of pipeline failed due to {Fore.YELLOW}missing datasets | |
{Fore.BLUE} {missing_input}{Fore.RESET} | |
''')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment