From bdb1a27313d7865b867cdc71041e6fd2bdd0b6b6 Mon Sep 17 00:00:00 2001 From: Matt Seddon Date: Mon, 15 Jul 2024 09:43:14 +1000 Subject: [PATCH] move image and text imports out of top level (avoid cv dependencies) --- src/datachain/__init__.py | 5 ----- src/datachain/image/__init__.py | 3 +++ src/datachain/text/__init__.py | 3 +++ tests/unit/test_module_exports.py | 5 ++--- 4 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 src/datachain/image/__init__.py create mode 100644 src/datachain/text/__init__.py diff --git a/src/datachain/__init__.py b/src/datachain/__init__.py index 0242cdbdd..152fe8ba2 100644 --- a/src/datachain/__init__.py +++ b/src/datachain/__init__.py @@ -2,8 +2,6 @@ from datachain.lib.feature import Feature from datachain.lib.feature_utils import pydantic_to_feature from datachain.lib.file import File, FileError, FileFeature, IndexedFile, TarVFile -from datachain.lib.image import ImageFile, convert_images -from datachain.lib.text import convert_text from datachain.lib.udf import Aggregator, Generator, Mapper from datachain.lib.utils import AbstractUDF, DataChainError from datachain.query.dataset import UDF as BaseUDF # noqa: N811 @@ -23,12 +21,9 @@ "FileError", "FileFeature", "Generator", - "ImageFile", "IndexedFile", "Mapper", "Session", "TarVFile", - "convert_images", - "convert_text", "pydantic_to_feature", ] diff --git a/src/datachain/image/__init__.py b/src/datachain/image/__init__.py new file mode 100644 index 000000000..7e381de13 --- /dev/null +++ b/src/datachain/image/__init__.py @@ -0,0 +1,3 @@ +from datachain.lib.image import ImageFile, convert_images + +__all__ = ["ImageFile", "convert_images"] diff --git a/src/datachain/text/__init__.py b/src/datachain/text/__init__.py new file mode 100644 index 000000000..87881b3eb --- /dev/null +++ b/src/datachain/text/__init__.py @@ -0,0 +1,3 @@ +from datachain.lib.text import convert_text + +__all__ = ["convert_text"] diff --git a/tests/unit/test_module_exports.py b/tests/unit/test_module_exports.py index 77aec6dea..95e5a1179 100644 --- a/tests/unit/test_module_exports.py +++ b/tests/unit/test_module_exports.py @@ -18,14 +18,13 @@ def test_module_exports(): FileError, FileFeature, Generator, - ImageFile, IndexedFile, Mapper, Session, TarVFile, - convert_images, - convert_text, pydantic_to_feature, ) + from datachain.image import ImageFile, convert_images + from datachain.text import convert_text except Exception as e: # noqa: BLE001 pytest.fail(f"Importing raised an exception: {e}")