Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] cuDF Pandas now requires pytest at runtime #16062

Closed
beckernick opened this issue Jun 19, 2024 · 1 comment · Fixed by #16063
Closed

[BUG] cuDF Pandas now requires pytest at runtime #16062

beckernick opened this issue Jun 19, 2024 · 1 comment · Fixed by #16063
Labels
bug Something isn't working

Comments

@beckernick
Copy link
Member

beckernick commented Jun 19, 2024

It looks like we currently have an explicit runtime dependency on pytest (via assert_eq) in 24.08, blocking cuDF Pandas in the default RAPIDS/cuDF runtime environment (since it doesn't include pytest). Looks like it may have been introduced in this PR.

We should gate this functionality behind a conditional import or find an alternative approach.

In [2]: %load_ext cudf.pandas
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 get_ipython().run_line_magic('load_ext', 'cudf.pandas')

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2480, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
   2478     kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2479 with self.builtin_trap:
-> 2480     result = fn(*args, **kwargs)
   2482 # The code below prevents the output from being displayed
   2483 # when using magics with decorator @output_can_be_silenced
   2484 # when the last Python token in the expression is a ';'.
   2485 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/site-packages/IPython/core/magics/extension.py:33, in ExtensionMagics.load_ext(self, module_str)
     31 if not module_str:
     32     raise UsageError('Missing module name.')
---> 33 res = self.shell.extension_manager.load_extension(module_str)
     35 if res == 'already loaded':
     36     print("The %s extension is already loaded. To reload it, use:" % module_str)

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/site-packages/IPython/core/extensions.py:62, in ExtensionManager.load_extension(self, module_str)
     55 """Load an IPython extension by its module name.
     56
     57 Returns the string "already loaded" if the extension is already loaded,
     58 "no load function" if the module doesn't have a load_ipython_extension
     59 function, or None if it succeeded.
     60 """
     61 try:
---> 62     return self._load_extension(module_str)
     63 except ModuleNotFoundError:
     64     if module_str in BUILTINS_EXTS:

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/site-packages/IPython/core/extensions.py:77, in ExtensionManager._load_extension(self, module_str)
     75 with self.shell.builtin_trap:
     76     if module_str not in sys.modules:
---> 77         mod = import_module(module_str)
     78     mod = sys.modules[module_str]
     79     if self._call_load_ipython_extension(mod):

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:688, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:883, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/site-packages/cudf/pandas/__init__.py:10
      6 import warnings
      8 import rmm.mr
---> 10 from .fast_slow_proxy import is_proxy_object
     11 from .magics import load_ipython_extension
     12 from .profiler import Profiler

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/site-packages/cudf/pandas/fast_slow_proxy.py:20
     17 import numpy as np
     19 from ..options import _env_get_bool
---> 20 from ..testing._utils import assert_eq
     21 from .annotation import nvtx
     24 def call_operator(fn, args, kwargs):

File /raid/nicholasb/miniconda3/envs/rapids-24.08/lib/python3.10/site-packages/cudf/testing/_utils.py:13
     11 import numpy as np
     12 import pandas as pd
---> 13 import pytest
     14 from numba.core.typing import signature as nb_signature
     15 from numba.core.typing.templates import AbstractTemplate

ModuleNotFoundError: No module named 'pytest'
@beckernick beckernick added the bug Something isn't working label Jun 19, 2024
@wence-
Copy link
Contributor

wence- commented Jun 19, 2024

Yes, we should gate.

wence- added a commit to wence-/cudf that referenced this issue Jun 19, 2024
The testing._utils module imports pytest, which is not advertised as a
default run dependency of cudf, so we must avoid importing it in the
proxy wrappers at top-level.

Instead, try importing, and provide an ImportError-specific warning in
addition to the catch all if things fail.

- Closes rapidsai#16062.
wence- added a commit to wence-/cudf that referenced this issue Jun 24, 2024
This way, importing it won't require pytest.

- Closes rapidsai#16062
@rapids-bot rapids-bot bot closed this as completed in 1bc1f45 Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants