FAIR-Chem/fairchem

ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts'

lbluque opened this issue · 1 comments

I installed directly from PyPI. After the advice of @zulissimeta, I uninstalled the previous installations from pip and installed as indicated in https://github.com/FAIR-Chem/fairchem/blob/main/.github/workflows/build_docs.yml#L29

pip install -e packages/fairchem-core[docs,adsorbml]
pip install -e packages/fairchem-data-oc[dev]
pip install -e packages/fairchem-demo-ocpapi[dev]
pip install -e packages/fairchem-applications-cattsunami

After that, I tried running the tests and now many more run.
pytest fairchem/tests
========================================================================= test session starts =========================================================================
platform linux -- Python 3.11.9, pytest-8.3.2, pluggy-1.5.0
rootdir: /scratch/phys/sin/gonzalm9/fairchem
plugins: syrupy-4.6.1
collected 153 items / 10 errors
=============================================================================== ERRORS ================================================================================
____________________________________________________ ERROR collecting fairchem/tests/applications/cattsunami/tests ____________________________________________________
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1204: in _gcd_import
???
:1176: in _find_and_load
???
:1147: in _find_and_load_unlocked
???
:690: in _load_unlocked
???
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/_pytest/assertion/rewrite.py:174: in exec_module
exec(co, module.dict)
fairchem/tests/applications/cattsunami/tests/conftest.py:6: in
from fairchem.core.scripts import download_large_files
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core
/scripts/init.py)
____________________________________________________ ERROR collecting fairchem/tests/core/common/test_gp_utils.py _____________________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/core/common/test_gp_utils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/core/common/test_gp_utils.py:10: in
from fairchem.core.common.test_utils import PGConfig, spawn_multi_process
E ModuleNotFoundError: No module named 'fairchem.core.common.test_utils'
__________________________________________________ ERROR collecting fairchem/tests/core/models/test_equiformer_v2.py __________________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/core/models/test_equiformer_v2.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/core/models/test_equiformer_v2.py:21: in
from fairchem.core.common.test_utils import PGConfig, spawn_multi_process
E ModuleNotFoundError: No module named 'fairchem.core.common.test_utils'
__________________________________________________ ERROR collecting fairchem/tests/core/test_download_large_files.py __________________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/core/test_download_large_files.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/core/test_download_large_files.py:4: in
from fairchem.core.scripts import download_large_files as dl_large
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scripts/init.py)
___________________________________________________ ERROR collecting fairchem/tests/data/oc/tests/test_adsorbate.py ___________________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/data/oc/tests/test_adsorbate.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/data/oc/tests/test_adsorbate.py:6: in
from fairchem.data.oc.core import Adsorbate
fairchem/src/fairchem/data/oc/core/init.py:5: in
from .bulk import Bulk
fairchem/src/fairchem/data/oc/core/bulk.py:12: in
from fairchem.core.scripts import download_large_files
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scripts/init.py)
_____________________________________________ ERROR collecting fairchem/tests/data/oc/tests/test_adsorbate_slab_config.py _____________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/data/oc/tests/test_adsorbate_slab_config.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/data/oc/tests/test_adsorbate_slab_config.py:6: in
from fairchem.data.oc.core import Adsorbate, AdsorbateSlabConfig, Bulk, Slab
fairchem/src/fairchem/data/oc/core/init.py:5: in
from .bulk import Bulk
fairchem/src/fairchem/data/oc/core/bulk.py:12: in
from fairchem.core.scripts import download_large_files
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scripts/init.py)
_____________________________________________________ ERROR collecting fairchem/tests/data/oc/tests/test_bulk.py ______________________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/data/oc/tests/test_bulk.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/data/oc/tests/test_bulk.py:9: in
from fairchem.data.oc.core import Bulk
fairchem/src/fairchem/data/oc/core/init.py:5: in
from .bulk import Bulk
fairchem/src/fairchem/data/oc/core/bulk.py:12: in
from fairchem.core.scripts import download_large_files
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scripts/init.py)
____________________________________________________ ERROR collecting fairchem/tests/data/oc/tests/test_inputs.py _____________________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/data/oc/tests/test_inputs.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/data/oc/tests/test_inputs.py:6: in
from fairchem.data.oc.core import Adsorbate, AdsorbateSlabConfig, Bulk, Slab
fairchem/src/fairchem/data/oc/core/init.py:5: in
from .bulk import Bulk
fairchem/src/fairchem/data/oc/core/bulk.py:12: in
from fairchem.core.scripts import download_large_files
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scripts/init.py)
__________________________________________ ERROR collecting fairchem/tests/data/oc/tests/test_multi_adsorbate_slab_config.py __________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/data/oc/tests/test_multi_adsorbate_slab_config.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/data/oc/tests/test_multi_adsorbate_slab_config.py:8: in
from fairchem.data.oc.core import Adsorbate, Bulk, MultipleAdsorbateSlabConfig, Slab
fairchem/src/fairchem/data/oc/core/init.py:5: in
from .bulk import Bulk
fairchem/src/fairchem/data/oc/core/bulk.py:12: in
from fairchem.core.scripts import download_large_files
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scripts/init.py)
_____________________________________________________ ERROR collecting fairchem/tests/data/oc/tests/test_slab.py ______________________________________________________
ImportError while importing test module '/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/data/oc/tests/test_slab.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
fairchem/tests/data/oc/tests/test_slab.py:6: in
from fairchem.data.oc.core import Bulk, Slab
fairchem/src/fairchem/data/oc/core/init.py:5: in
from .bulk import Bulk
fairchem/src/fairchem/data/oc/core/bulk.py:12: in
from fairchem.core.scripts import download_large_files
E ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scripts/init.py)
========================================================================== warnings summary ===========================================================================
fairchem/tests/demo/ocpapi/tests/integration/client/test_client.py:169
/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/demo/ocpapi/tests/integration/client/test_client.py:169: PytestUnknownMarkWarning: Unknown pytest.mark.ocpapi_integration_test - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
@pytest.mark.ocpapi_integration_test

fairchem/tests/demo/ocpapi/tests/integration/client/test_client.py:261
/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/demo/ocpapi/tests/integration/client/test_client.py:261: PytestUnknownMarkWarning: Unknown pytest.mark.ocpapi_integration_test - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
@pytest.mark.ocpapi_integration_test

fairchem/tests/demo/ocpapi/tests/integration/workflows/test_adsorbates.py:74
/scratch/phys/sin/gonzalm9/fairchem/fairchem/tests/demo/ocpapi/tests/integration/workflows/test_adsorbates.py:74: PytestUnknownMarkWarning: Unknown pytest.mark.ocpapi_integration_test - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
@pytest.mark.ocpapi_integration_test

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================= short test summary info =======================================================================
ERROR fairchem/tests/applications/cattsunami/tests - ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/cor...
ERROR fairchem/tests/core/common/test_gp_utils.py
ERROR fairchem/tests/core/models/test_equiformer_v2.py
ERROR fairchem/tests/core/test_download_large_files.py
ERROR fairchem/tests/data/oc/tests/test_adsorbate.py
ERROR fairchem/tests/data/oc/tests/test_adsorbate_slab_config.py
ERROR fairchem/tests/data/oc/tests/test_bulk.py
ERROR fairchem/tests/data/oc/tests/test_inputs.py
ERROR fairchem/tests/data/oc/tests/test_multi_adsorbate_slab_config.py
ERROR fairchem/tests/data/oc/tests/test_slab.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 10 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================================== 3 warnings, 10 errors in 5.40s ====================================================================

All the errors now seem to span from not correctly importing download_large_files from fairchem.core.scripts.
This is the same error I encounter now when I try to run the tutorial https://fair-chem.github.io/tutorials/adsorbml_walkthrough.html:

Traceback (most recent call last):
File "/scratch/phys/sin/gonzalm9/fairchem/try_fairchem.py", line 5, in
from fairchem.data.oc.core import Adsorbate, AdsorbateSlabConfig, Bulk, Slab
File "/scratch/phys/sin/gonzalm9/fairchem/fairchem/src/fairchem/data/oc/core/init.py", line 5, in
from .bulk import Bulk
File "/scratch/phys/sin/gonzalm9/fairchem/fairchem/src/fairchem/data/oc/core/bulk.py", line 12, in
from fairchem.core.scripts import download_large_files
ImportError: cannot import name 'download_large_files' from 'fairchem.core.scripts' (/home/gonzalm9/.conda/envs/fairchem/lib/python3.11/site-packages/fairchem/core/scr
ipts/init.py)

As a side note, some test failed because syrupy was not installed. It haven't found it in env.cpu.yml, env.gpu.yml, requirements.txt and requirements-optional.txt. Maybe it should be added to any of those files.

Originally posted by @edmanft in #785 (comment)

I managed to recreate the error as above :)

In the case above and in #785 the installation procedure was that used for building the docs which is slightly different than what we use to build for tests.

https://github.com/FAIR-Chem/fairchem/blob/main/.github/workflows/build_docs.yml#L29
vs
https://github.com/FAIR-Chem/fairchem/blob/main/.github/workflows/test.yml#L39

This line,

pip install -e packages/fairchem-core[docs,adsorbml]

should be

pip install -e packages/fairchem-core[dev]

[dev] installs pytest, otherwise in the [docs,adsorbml] version you are using whatever pytest is available.
If I install with [dev] I do not got any issues with running pytest tests