materialsproject / fireworks

The Fireworks Workflow Management Repo.
https://materialsproject.github.io/fireworks
Other
361 stars 185 forks source link

[Bug]: ModuleNotFoundError: No module named 'pytest' #535

Open ikondov opened 2 months ago

ikondov commented 2 months ago

Code snippet

# On a Red Hat Enterprise Linux release 8.8 (Ootpa)
python3.9 -m venv python-3.9.16
. python-3.9.16/bin/activate
# install from main branch due to this issue: https://github.com/materialsproject/fireworks/issues/531
python -m pip install git+https://github.com/materialsproject/fireworks.git
lpad reset
lpad add_scripts date
lpad get_fws -i 1
# the last command produces error messages

What happened?

  1. I am attepting to get an overview of the firework.
  2. Expected behavior is to get only this output:
    {
    "fw_id": 1,
    "created_on": "2024-09-06T08:00:38.113144",
    "updated_on": "2024-09-06T08:00:38.113207",
    "state": "READY",
    "name": "Unnamed FW"
    }
  3. What happens is I get error messages (see section Log output below).
  4. Suggested solution: workaround: install pytest package; fix: catch both ImportError and ModuleNotFoundError.

Version

main branch

Which OS?

Log output

/truncated/path/python-3.9.16/lib64/python3.9/site-packages/fireworks/utilities/fw_serializers.py:375: UserWarning: None in fireworks.user_objects.firetasks.tests.test_fileio_tasks cannot be loaded because of No module named 'pytest'. Skipping..
  warnings.warn(f"{m_object} in {mod_name} cannot be loaded because of {ex!s}. Skipping..")
Traceback (most recent call last):
  File "/truncated/path/python-3.9.16/lib64/python3.9/site-packages/fireworks/utilities/fw_serializers.py", line 368, in load_object
    m_module = importlib.import_module(mod_name)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/truncated/path/python-3.9.16/lib64/python3.9/site-packages/fireworks/user_objects/firetasks/tests/test_fileio_tasks.py", line 10, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'
/truncated/path/python-3.9.16/lib64/python3.9/site-packages/fireworks/utilities/fw_serializers.py:375: UserWarning: None in fireworks.user_objects.firetasks.tests.test_filepad_tasks cannot be loaded because of No module named 'pytest'. Skipping..
  warnings.warn(f"{m_object} in {mod_name} cannot be loaded because of {ex!s}. Skipping..")
Traceback (most recent call last):
  File "/truncated/path/python-3.9.16/lib64/python3.9/site-packages/fireworks/utilities/fw_serializers.py", line 368, in load_object
    m_module = importlib.import_module(mod_name)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/truncated/path/python-3.9.16/lib64/python3.9/site-packages/fireworks/user_objects/firetasks/tests/test_filepad_tasks.py", line 6, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'
ikondov commented 2 months ago

This issue resembles very much issue #450. The crash here comes from another line. IMHO the code should try to catch both ImportError and ModuleNotFoundError in both lines.

ikondov commented 2 months ago

A workaround is to install the pytest package.