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
data
folder 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.resources
is used to get a path to the file through the package.This function may raise a
DeprecationWarning
when 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
data
folder. For example,openei
to access the OpenEI dataset. This dataset cannot be nested, e.g.,dataset/subdataset
ordataset.subdataset
will not work.filename – The name of the desired file, within the
dataset
folder.
- Returns:
A path to the desired file.