From f237a8b3e32e7866aa8adae2a22394b93dc5ed70 Mon Sep 17 00:00:00 2001 From: Deepyaman Datta Date: Sat, 29 Jul 2023 10:49:05 -0500 Subject: [PATCH] perf(datasets): lazily load datasets in init files (yaml) Signed-off-by: Deepyaman Datta --- kedro-datasets/kedro_datasets/yaml/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kedro-datasets/kedro_datasets/yaml/__init__.py b/kedro-datasets/kedro_datasets/yaml/__init__.py index b3780de3a..11b3b898b 100644 --- a/kedro-datasets/kedro_datasets/yaml/__init__.py +++ b/kedro-datasets/kedro_datasets/yaml/__init__.py @@ -1,8 +1,11 @@ """``AbstractDataSet`` implementation to load/save data from/to a YAML file.""" +from typing import Any -__all__ = ["YAMLDataSet"] +import lazy_loader as lazy -from contextlib import suppress +# https://github.com/pylint-dev/pylint/issues/4300#issuecomment-1043601901 +YAMLDataSet: Any -with suppress(ImportError): - from .yaml_dataset import YAMLDataSet +__getattr__, __dir__, __all__ = lazy.attach( + __name__, submod_attrs={"yaml_dataset": ["YAMLDataSet"]} +)