-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(datasets): lazily load datasets in init files
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
- Loading branch information
Showing
1 changed file
with
17 additions
and
39 deletions.
There are no files selected for viewing
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
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"], | ||
}, | ||
) |