From 095e50f140e894d7d484f0c86ecb19664853abd2 Mon Sep 17 00:00:00 2001 From: Matej Aleksandrov Date: Thu, 19 Nov 2026 08:56:41 -0800 Subject: [PATCH] Use standard library `importlib.resources` directly in `models.py` and remove the obsolete Python <3.7 `importlib_resources` fallback import. PiperOrigin-RevId: 1025634341 --- src/python/tensorflow_cloud/core/experimental/models.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/python/tensorflow_cloud/core/experimental/models.py b/src/python/tensorflow_cloud/core/experimental/models.py index cbabe599..52505490 100644 --- a/src/python/tensorflow_cloud/core/experimental/models.py +++ b/src/python/tensorflow_cloud/core/experimental/models.py @@ -13,6 +13,7 @@ # limitations under the License. """Module that contains the `run_models` wrapper for training models from TF Model Garden.""" +from importlib import resources as pkg_resources import os import pickle from typing import Any, Dict, Optional @@ -26,14 +27,6 @@ from official.legacy.image_classification.efficientnet import efficientnet_model from official.legacy.image_classification.resnet import resnet_model -# pylint: disable=g-import-not-at-top -try: - import importlib.resources as pkg_resources -except ImportError: - # Backported for python<3.7 - import importlib_resources as pkg_resources -# pylint: enable=g-import-not-at-top - _PARAMS_FILE_NAME_FORMAT = '{}_params' _ENTRY_POINT_FORMAT = '{}.py' _ENTRY_POINT_TEMPLATE = 'models_entry_point.py'