diff --git a/idaes/apps/grid_integration/examples/utils.py b/idaes/apps/grid_integration/examples/utils.py index a20a07cdb7..1675704485 100644 --- a/idaes/apps/grid_integration/examples/utils.py +++ b/idaes/apps/grid_integration/examples/utils.py @@ -11,14 +11,14 @@ # for full copyright and license information. ################################################################################# -from importlib import resources +from importlib.resources import as_file, files from pathlib import Path import os import pandas as pd -with resources.as_file(resources.files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: +with as_file(files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: prescient_5bus = Path(pkg_file).parent # rts_gmlc_generator_dataframe = pd.read_csv("gen.csv") diff --git a/idaes/apps/grid_integration/tests/test_integration.py b/idaes/apps/grid_integration/tests/test_integration.py index b36ddb5d8f..26e9ad0830 100644 --- a/idaes/apps/grid_integration/tests/test_integration.py +++ b/idaes/apps/grid_integration/tests/test_integration.py @@ -11,7 +11,7 @@ # for full copyright and license information. ################################################################################# -from importlib import resources +from importlib.resources import as_file, file from numbers import Number from pathlib import Path from typing import Dict, Union @@ -51,11 +51,7 @@ def data_path(self) -> Path: # where importlib.resources.path() requires the resource to be a file # directories are not supported and will raise an error if attempted - ### old version - # with resources.path("idaes.tests.prescient.5bus", "__init__.py") as pkg_file: - # return Path(pkg_file).parent - - with resources.as_file(resources.files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: + with as_file(files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: prescient_5bus = Path(pkg_file).parent @@ -77,7 +73,7 @@ def self_scheduler_output_dir(self, tmp_path: Path) -> Path: @pytest.fixture def self_scheduler_plugin_path(self) -> Path: - with resources.as_file(resources.files("idaes.apps.grid_integration.tests").joinpath("self_scheduler_integration_test_plugin.py")) as p: + with as_file(files("idaes.apps.grid_integration.tests").joinpath("self_scheduler_integration_test_plugin.py")) as p: return Path(p) @pytest.mark.unit diff --git a/idaes/tests/prescient/test_prescient.py b/idaes/tests/prescient/test_prescient.py index 09cef146c4..cf04d7e681 100644 --- a/idaes/tests/prescient/test_prescient.py +++ b/idaes/tests/prescient/test_prescient.py @@ -11,7 +11,7 @@ # for full copyright and license information. ################################################################################# -from importlib import resources +from importlib.resources import files, as_file from numbers import Number from pathlib import Path from typing import Dict, Union @@ -33,7 +33,7 @@ def data_path(self) -> Path: # we need to specify __init__.py as a workaround for Python 3.9, # where importlib.resources.path() requires the resource to be a file # directories are not supported and will raise an error if attempted - with resources.as_file(resources.files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: + with as_file(files("idaes.tests.prescient.5bus").joinpath("__init__.py")) as pkg_file: prescient_5bus = Path(pkg_file).parent @pytest.mark.unit