cuml icon indicating copy to clipboard operation
cuml copied to clipboard

[BUG] **`_process_generic` defined in `base_helpers` but needed in `base_return_types`, circular import restricted**

Open dcolinmorgan opened this issue 6 months ago • 2 comments

_process_generic is defined in base_helpers but needed in base_return_types

Since base_helpers imports base_return_types, circular import restrict base_return_types from importing _process_generic from base_helpers... so why not just define it where it is called?**

leads to error: AttributeError: type object 'list' has no attribute 'replace'

moving _process_generic to base_return_types solves both initial and knock-on effect errors


NameError                                 Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/cuml/internals/base_return_types.py](https://localhost:8080/#) in _get_base_return_type(class_name, attr)
     80             if is_generic:
---> 81                 return _process_generic(ret_type)
     82             elif issubclass(ret_type, CumlArray):

NameError: name '_process_generic' is not defined

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)

[/usr/local/lib/python3.10/dist-packages/cuml/internals/base_helpers.py](https://localhost:8080/#) in __new__(cls, classname, bases, classDict)
    155             if callable(attribute):
    156 
--> 157                 classDict[attributeName] = _wrap_attribute(
    158                     classname, attributeName, attribute
    159                 )

[/usr/local/lib/python3.10/dist-packages/cuml/internals/base_helpers.py](https://localhost:8080/#) in _wrap_attribute(class_name, attribute_name, attribute, **kwargs)
     77         return attribute
     78 
---> 79     return_type = _get_base_return_type(class_name, attribute)
     80 
     81     if return_type == "generic":

[/usr/local/lib/python3.10/dist-packages/cuml/internals/base_return_types.py](https://localhost:8080/#) in _get_base_return_type(class_name, attr)
     95         # annotations. Strings end up wrapped in an extra layer of quotes,
     96         # which we have to replace here.
---> 97         if attr.__annotations__["return"].replace("'", "") == class_name:
     98             return "base"
     99         # try:

[/usr/lib/python3.10/typing.py](https://localhost:8080/#) in __getattr__(self, attr)
    981         # Also for simplicity we don't relay any dunder names
    982         if '__origin__' in self.__dict__ and not _is_dunder(attr):
--> 983             return getattr(self.__origin__, attr)
    984         raise AttributeError(attr)
    985 


AttributeError: type object 'list' has no attribute 'replace'

Steps/Code to reproduce bug

 !pip install --extra-index-url=https://pypi.nvidia.com cuml-cu11==23.10.00 cudf-cu11==23.10.00 
import cuml,cudf,os
cuml.__version__

!pip install cu-cat
import cu_cat

Expected behavior imported fine under 23.06

Environment details (please complete the following information):

  • google colab
  • Linux Distro/Architecture: [Ubuntu 22.04]
  • GPU Model/Driver: [T4 and driver 525.105.17]
  • CUDA: [12.0]
  • Method of cuDF & cuML install: [conda, Docker, or from source]
    • !pip install --extra-index-url=https://pypi.nvidia.com cuml-cu11==23.10.00 cudf-cu11==23.10.00

dcolinmorgan avatar Dec 11 '23 06:12 dcolinmorgan

#5695

dcolinmorgan avatar Dec 11 '23 07:12 dcolinmorgan

Thanks for the issue and PR @dcolinmorgan! This is tech debt we have from some code re-organizations we have done.

dantegd avatar Dec 13 '23 04:12 dantegd