From 37fa5893e0b96cb7c28c3c77aa0b70b915795167 Mon Sep 17 00:00:00 2001 From: Ali Zaidi <41302741+azaidi06@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:43:35 -0500 Subject: [PATCH] changed import structure back to only bringing in the namespace and accessing functions from that --- idaes/apps/grid_integration/examples/utils.py | 2 +- idaes/apps/grid_integration/tests/test_integration.py | 10 +++++----- idaes/tests/prescient/test_prescient.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/idaes/apps/grid_integration/examples/utils.py b/idaes/apps/grid_integration/examples/utils.py index 1675704485..cf6185dc84 100644 --- a/idaes/apps/grid_integration/examples/utils.py +++ b/idaes/apps/grid_integration/examples/utils.py @@ -11,7 +11,7 @@ # for full copyright and license information. ################################################################################# -from importlib.resources import as_file, files +from importlib import resources from pathlib import Path import os diff --git a/idaes/apps/grid_integration/tests/test_integration.py b/idaes/apps/grid_integration/tests/test_integration.py index 1d9dfd2c62..70d6707d14 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.resources import as_file, file +from importlib import resources from numbers import Number from pathlib import Path from typing import Dict, Union @@ -50,8 +50,8 @@ 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 as_file( - files("idaes.tests.prescient.5bus").joinpath("__init__.py") + with resources.as_file( + resources.files("idaes.tests.prescient.5bus").joinpath("__init__.py") ) as pkg_file: prescient_5bus = Path(pkg_file).parent @@ -73,8 +73,8 @@ def self_scheduler_output_dir(self, tmp_path: Path) -> Path: @pytest.fixture def self_scheduler_plugin_path(self) -> Path: - with as_file( - files("idaes.apps.grid_integration.tests").joinpath( + with resources.as_file( + resources.files("idaes.apps.grid_integration.tests").joinpath( "self_scheduler_integration_test_plugin.py" ) ) as p: diff --git a/idaes/tests/prescient/test_prescient.py b/idaes/tests/prescient/test_prescient.py index c1c6f125b8..9e3746bd6c 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.resources import files, as_file +from importlib import resources from numbers import Number from pathlib import Path from typing import Dict, Union @@ -33,8 +33,8 @@ 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 as_file( - files("idaes.tests.prescient.5bus").joinpath("__init__.py") + with resources.as_file( + resources.files("idaes.tests.prescient.5bus").joinpath("__init__.py") ) as pkg_file: prescient_5bus = Path(pkg_file).parent