ivy-llc / ivy

The Unified ML Representation
https://ivy.dev
Other
14.02k stars 5.82k forks source link

[Bug]: Issues with setting up tests with codespace #10261

Open anshulcgm opened 1 year ago

anshulcgm commented 1 year ago

Bug Explanation

I was following the docs at https://lets-unify.ai/ivy/contributing/setting_up.html#setting-up and when trying to setup the tests with codespace, I get the following error output:

==================================== ERRORS ====================================
_ ERROR collecting ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py _
ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py:8: in <module>
    from ivy_tests.test_ivy.test_frontends.test_torch.test_tensor import _array_and_index
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
/usr/local/lib/python3.8/dist-packages/_pytest/assertion/rewrite.py:168: in exec_module
    exec(co, module.__dict__)
ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py:427: in <module>
    init_num_positional_args: pf.NumPositionalArgFn,
E   NameError: name 'pf' is not defined
_ ERROR collecting ivy_tests/test_ivy/test_frontends/test_numpy/test_matrix/test_methods.py _
ivy_tests/test_ivy/test_frontends/test_numpy/test_matrix/test_methods.py:155: in <module>
    as_variable: pf.AsVariableFlags,
E   AttributeError: module 'ivy_tests.test_ivy.helpers.test_parameter_flags' has no attribute 'AsVariableFlags'
_ ERROR collecting ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py _
ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py:122: in <module>
    as_variable: pf.AsVariableFlags,
E   NameError: name 'pf' is not defined
_ ERROR collecting ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py _
ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py:427: in <module>
    init_num_positional_args: pf.NumPositionalArgFn,
E   NameError: name 'pf' is not defined
_______ ERROR collecting ivy_tests/test_ivy/test_misc/test_exceptions.py _______
/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/local/lib/python3.8/dist-packages/_pytest/python.py:262: in pytest_pycollect_makeitem
    return list(collector._genfunctions(name, obj))
/usr/local/lib/python3.8/dist-packages/_pytest/python.py:489: in _genfunctions
    self.ihook.pytest_generate_tests.call_extra(methods, dict(metafunc=metafunc))
/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py:292: in call_extra
    return self(**kwargs)
/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/local/lib/python3.8/dist-packages/_pytest/python.py:148: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker)
/usr/local/lib/python3.8/dist-packages/_pytest/python.py:1272: in parametrize
    argnames, parametersets = ParameterSet._for_parametrize(
/usr/local/lib/python3.8/dist-packages/_pytest/mark/structures.py:160: in _for_parametrize
    parameters = cls._parse_parametrize_parameters(argvalues, force_tuple)
/usr/local/lib/python3.8/dist-packages/_pytest/mark/structures.py:146: in _parse_parametrize_parameters
    return [
E   TypeError: 'function' object is not iterable
=============================== warnings summary ===============================
../../usr/local/lib/python3.8/dist-packages/flatbuffers/compat.py:19
  /usr/local/lib/python3.8/dist-packages/flatbuffers/compat.py:19: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
ERROR ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py - Na...
ERROR ivy_tests/test_ivy/test_frontends/test_numpy/test_matrix/test_methods.py
ERROR ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py
ERROR ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py - NameError...
ERROR ivy_tests/test_ivy/test_misc/test_exceptions.py - TypeError: 'function'...
!!!!!!!!!!!!!!!!!!! Interrupted: 5 errors during collection !!!!!!!!!!!!!!!!!!!!
============= 15148 tests collected, 5 errors in 142.02s (0:02:22) =============

    at ChildProcess.<anonymous> (/root/.vscode-remote/extensions/ms-python.python-2022.20.2/out/client/extension.js:2:245886)
    at Object.onceWrapper (node:events:646:26)
    at ChildProcess.emit (node:events:526:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)]

Steps to Reproduce Bug

Following the steps at https://lets-unify.ai/ivy/contributing/setting_up.html#github-codespaces. I didn't setup any virtual environments beforehand or do any docker setup, I an not sure if this is contributing to the issue.

Environment

GitHub codespaces on Visual Studio Code

Ivy Version

fc7e267 (latest master hash as of 2/1/2023)

Backend

Device

No response

anshulcgm commented 1 year ago

After deleting the codespace and just setting up another one, I run into this error prompt when I try to get the tests working:

> /bin/python3 ~/.vscode-remote/extensions/ms-python.python-2022.20.2/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear ivy_tests
cwd: .
[ERROR 2023-1-2 1:58:10.82]: Error discovering pytest tests:
 n [Error]: 2023-02-02 01:58:06.493123: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
ImportError while loading conftest '/workspaces/ivy/ivy_tests/test_array_api/conftest.py'.
ivy_tests/test_array_api/conftest.py:10: in <module>
    from reporting import pytest_metadata, pytest_json_modifyreport, add_extra_json_metadata # noqa
ivy_tests/test_array_api/reporting.py:1: in <module>
    from array_api_tests.dtype_helpers import dtype_to_name
ivy_tests/test_array_api/array_api_tests/dtype_helpers.py:183: in <module>
    if dtype_nbits[default_int] == 32:
ivy_tests/test_array_api/array_api_tests/dtype_helpers.py:71: in __getitem__
    raise KeyError(f"{key!r} not found")
E   KeyError: "'int32' not found"

    at ChildProcess.<anonymous> (/root/.vscode-remote/extensions/ms-python.python-2022.20.2/out/client/extension.js:2:245886)
    at Object.onceWrapper (node:events:646:26)
    at ChildProcess.emit (node:events:526:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
anshulcgm commented 1 year ago

Hi, just following up about this, I have written some code that I want to contribute but I want to make sure I can test it beforehand.

fnhirwa commented 1 year ago

Hey @anshulcgm Feel free to open a PR for this

NanoCode012 commented 1 year ago

Hello @anshulcgm , I got this issue as well, but found out it as because I did not complete the third step.

  1. Configure the _array_module.py file in the array_api_tests to be set to one of the supported frameworks.

The image was a bit unclear, but it was changing from

# old
array_module = None

# new
import ivy as array_module
array_module.set_backend('numpy')