From 8e8846a282c48db6ac6ab747c17a41fd6cb30b60 Mon Sep 17 00:00:00 2001 From: anna-charlotte Date: Wed, 19 Apr 2023 09:52:25 +0200 Subject: [PATCH 1/3] feat: point to older versions when importing Document or DocumentArray Signed-off-by: anna-charlotte --- docarray/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docarray/__init__.py b/docarray/__init__.py index 903c0947d43..b1e3417b0f6 100644 --- a/docarray/__init__.py +++ b/docarray/__init__.py @@ -4,6 +4,7 @@ from docarray.array import DocList, DocVec from docarray.base_doc.doc import BaseDoc +from docarray.utils._internal.misc import _get_path_from_docarray_root_level __all__ = ['BaseDoc', 'DocList', 'DocVec'] @@ -13,3 +14,16 @@ formatter = logging.Formatter("%(levelname)s - %(name)s - %(message)s") handler.setFormatter(formatter) logger.addHandler(handler) + + +def __getattr__(name: str): + if name in ['Document', 'DocumentArray']: + raise ImportError( + f'Cannot import name \'{name}\' from \'{_get_path_from_docarray_root_level(__file__)}\'.\n' + f'The concept of \'{name}\' does not exist in this version of docarray.\n' + f'If you still want to use \'{name}\' please downgrade to version <=0.21.0.' + ) + else: + raise ImportError( + f'cannot import name \'{name}\' from \'{_get_path_from_docarray_root_level(__file__)}\'' + ) From 4bdbf7c8fd013f639f2646fc02baba2879d5ad76 Mon Sep 17 00:00:00 2001 From: anna-charlotte Date: Wed, 19 Apr 2023 10:00:07 +0200 Subject: [PATCH 2/3] fix: apply suggestion from code review Signed-off-by: anna-charlotte --- docarray/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docarray/__init__.py b/docarray/__init__.py index b1e3417b0f6..9db04d54ff0 100644 --- a/docarray/__init__.py +++ b/docarray/__init__.py @@ -21,7 +21,8 @@ def __getattr__(name: str): raise ImportError( f'Cannot import name \'{name}\' from \'{_get_path_from_docarray_root_level(__file__)}\'.\n' f'The concept of \'{name}\' does not exist in this version of docarray.\n' - f'If you still want to use \'{name}\' please downgrade to version <=0.21.0.' + f'If you still want to use \'{name}\' please downgrade to version <=0.21.0 ' + f'with: `pip install -U docarray==0.21.0`.' ) else: raise ImportError( From 1dff03d3fefc51fc450fd10a137b5798cd3a4cf4 Mon Sep 17 00:00:00 2001 From: Charlotte Gerhaher Date: Wed, 19 Apr 2023 10:10:59 +0200 Subject: [PATCH 3/3] fix: apply suggestions from code review Co-authored-by: samsja <55492238+samsja@users.noreply.github.com> Signed-off-by: Charlotte Gerhaher --- docarray/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docarray/__init__.py b/docarray/__init__.py index 9db04d54ff0..ce2152c8315 100644 --- a/docarray/__init__.py +++ b/docarray/__init__.py @@ -20,7 +20,7 @@ def __getattr__(name: str): if name in ['Document', 'DocumentArray']: raise ImportError( f'Cannot import name \'{name}\' from \'{_get_path_from_docarray_root_level(__file__)}\'.\n' - f'The concept of \'{name}\' does not exist in this version of docarray.\n' + f'The object named \'{name}\' does not exist anymore in this version of docarray.\n' f'If you still want to use \'{name}\' please downgrade to version <=0.21.0 ' f'with: `pip install -U docarray==0.21.0`.' )