Utils#

class sdgx.utils.Singleton[source]#

metaclass for singleton, thread-safe.

mro()#

Return a type’s method resolution order.

sdgx.utils.cache(user_function, /)[source]#

Simple lightweight unbounded cache. Sometimes called “memoize”.

sdgx.utils.download_demo_data(data_dir: str | Path = './dataset') Path[source]#

Download demo data if not exist

Parameters:

data_dir (str | Path) – data directory

Returns:

demo data path

Return type:

pathlib.Path

sdgx.utils.download_multi_table_demo_data(data_dir: str | Path = './dataset', dataset_name='rossman') dict[str, Path][source]#

Download multi-table demo data “Rossman Store Sales” or “Rossmann Store Sales” if not exist

Parameters:

data_dir (str | Path) – data directory

Returns:

dict, the key is table name, value is demo data path

Return type:

dict[str, pathlib.Path]

sdgx.utils.find_free_port()[source]#
sdgx.utils.get_demo_single_table(data_dir: str | Path = './dataset')[source]#

Get demo single table as DataFrame and discrete columns names

Parameters:

data_dir (str | Path) – data directory

Returns:

demo single table list: discrete columns

Return type:

pd.DataFrame

sdgx.utils.time2int(datetime, form='%Y-%m-%d %H:%M:%S')[source]#