smartgrid.make_env.find_profile_data¶
- smartgrid.make_env.find_profile_data(dataset: str, filename: str) str[source]¶
Finds a data file from the data folder.
The
datafolder can be either:accessible through a relative path, e.g., because the source code was cloned (
./data/path/to/the/desired/file).accessible through imports, e.g., because the package was installed.
How to access files in this folder depends on the actual case; this function (hopefully) solves this problem, by checking first whether the files are directly accessible (through relative paths). If they are not,
importlib.resourcesis used to get a path to the file through the package.This function may raise a
DeprecationWarningwhen accessing files through the package on Python3.11+. It is due to relying on theimportlib.resources.path()function, which is deprecated since Python 3.11. As we support up to Python 3.7, and as the function is only available since Python 3.9, it is still used instead of the more recentimportlib.resources.files().- Parameters:
dataset – The name of the folder containing the desired file, within the
datafolder. For example,openeito access the OpenEI dataset. This dataset cannot be nested, e.g.,dataset/subdatasetordataset.subdatasetwill not work.filename – The name of the desired file, within the
datasetfolder.
- Returns:
A path to the desired file.