Skip to content

Commit

Permalink
perf(datasets): lazily load datasets in init files
Browse files Browse the repository at this point in the history
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
  • Loading branch information
deepyaman committed Jul 22, 2023
1 parent 5d9db24 commit a1e8d15
Showing 1 changed file with 17 additions and 39 deletions.
56 changes: 17 additions & 39 deletions kedro-datasets/kedro_datasets/pandas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
"""``AbstractDataSet`` implementations that produce pandas DataFrames."""

__all__ = [
"CSVDataSet",
"DeltaTableDataSet",
"ExcelDataSet",
"FeatherDataSet",
"GBQTableDataSet",
"GBQQueryDataSet",
"HDFDataSet",
"JSONDataSet",
"ParquetDataSet",
"SQLQueryDataSet",
"SQLTableDataSet",
"XMLDataSet",
"GenericDataSet",
]
import lazy_loader as lazy

from contextlib import suppress

with suppress(ImportError):
from .csv_dataset import CSVDataSet
with suppress(ImportError):
from .deltatable_dataset import DeltaTableDataSet
with suppress(ImportError):
from .excel_dataset import ExcelDataSet
with suppress(ImportError):
from .feather_dataset import FeatherDataSet
with suppress(ImportError):
from .gbq_dataset import GBQQueryDataSet, GBQTableDataSet
with suppress(ImportError):
from .hdf_dataset import HDFDataSet
with suppress(ImportError):
from .json_dataset import JSONDataSet
with suppress(ImportError):
from .parquet_dataset import ParquetDataSet
with suppress(ImportError):
from .sql_dataset import SQLQueryDataSet, SQLTableDataSet
with suppress(ImportError):
from .xml_dataset import XMLDataSet
with suppress(ImportError):
from .generic_dataset import GenericDataSet
__getattr__, __dir__, __all__ = lazy.attach(
__name__,
submod_attrs={
"csv_dataset": ["CSVDataSet"],
"deltatable_dataset": ["DeltaTableDataSet"],
"excel_dataset": ["ExcelDataSet"],
"feather_dataset": ["FeatherDataSet"],
"gbq_dataset": ["GBQQueryDataSet", "GBQTableDataSet"],
"generic_dataset": ["GenericDataSet"],
"hdf_dataset": ["HDFDataSet"],
"json_dataset": ["JSONDataSet"],
"parquet_dataset": ["ParquetDataSet"],
"sql_dataset": ["SQLQueryDataSet", "SQLTableDataSet"],
"xml_dataset": ["XMLDataSet"],
},
)

0 comments on commit a1e8d15

Please sign in to comment.