judithabk6 / med_bench

BSD 3-Clause "New" or "Revised" License
8 stars 3 forks source link

tests are slightly broken #59

Closed judithabk6 closed 6 months ago

judithabk6 commented 6 months ago
bthirion commented 6 months ago

Sorry I don't understand the pb.

judithabk6 commented 6 months ago

I don't understand why it does not work to go to the root of the repo and run pytest src/tests

(causal2023) [jabecass@marg039 med_bench]$ pytest src/tests
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.7.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /data/parietal/store/work/jabecass/med_bench
collected 0 items / 2 errors                                                                                                                                                                               

================================================================================================== ERRORS ==================================================================================================
_______________________________________________________________________ ERROR collecting src/tests/estimation/test_get_estimation.py _______________________________________________________________________
ImportError while importing test module '/data/parietal/store/work/jabecass/med_bench/src/tests/estimation/test_get_estimation.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../miniconda3/envs/causal2023/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/tests/estimation/test_get_estimation.py:19: in <module>
    from med_bench.get_simulated_data import simulate_data
E   ModuleNotFoundError: No module named 'med_bench'
___________________________________________________________________ ERROR collecting src/tests/simulate_data/test_get_simulated_data.py ____________________________________________________________________
ImportError while importing test module '/data/parietal/store/work/jabecass/med_bench/src/tests/simulate_data/test_get_simulated_data.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../miniconda3/envs/causal2023/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/tests/simulate_data/test_get_simulated_data.py:21: in <module>
    from med_bench.get_simulated_data import simulate_data
E   ModuleNotFoundError: No module named 'med_bench'
========================================================================================= short test summary info ==========================================================================================
ERROR src/tests/estimation/test_get_estimation.py
ERROR src/tests/simulate_data/test_get_simulated_data.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================ 2 errors in 1.06s =============================================================================================
(causal2023) [jabecass@marg039 med_bench]$ PYTHONPATH=src pytest src/tests
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.7.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /data/parietal/store/work/jabecass/med_bench
collected 976 items                                                                                                                                                                                        

src/tests/estimation/test_get_estimation.py ......................................ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssssssEE........FFssss.........................

it's not that big of a problem, but I am not sure what the right behavior is

bthirion commented 6 months ago

But if you just launch pytest at the root of the repo, it works. Doesnt'it ?

judithabk6 commented 6 months ago

yes! you're right

houssamzenati commented 6 months ago

Unfortunately it does not work from my side even if I go the root of the repo...

`(base) MAC-11108352:med_bench hzenati$ pytest ============================= test session starts ============================== platform darwin -- Python 3.11.5, pytest-7.4.0, pluggy-1.0.0 rootdir: /Users/hzenati/Documents/Work/causal inference/med_bench plugins: anyio-3.5.0 collected 0 items / 2 errors

==================================== ERRORS ==================================== _ ERROR collecting src/tests/estimation/test_getestimation.py ImportError while importing test module '/Users/hzenati/Documents/Work/causal inference/med_bench/src/tests/estimation/test_get_estimation.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: ../../../../anaconda3/lib/python3.11/importlib/init.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) src/tests/estimation/test_get_estimation.py:19: in from med_bench.get_simulated_data import simulate_data E ModuleNotFoundError: No module named 'medbench' ____ ERROR collecting src/tests/simulate_data/test_get_simulated_data.py __ ImportError while importing test module '/Users/hzenati/Documents/Work/causal inference/med_bench/src/tests/simulate_data/test_get_simulated_data.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: ../../../../anaconda3/lib/python3.11/importlib/init.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) src/tests/simulate_data/test_get_simulated_data.py:21: in from med_bench.get_simulated_data import simulate_data E ModuleNotFoundError: No module named 'med_bench' =========================== short test summary info ============================ ERROR src/tests/estimation/test_get_estimation.py ERROR src/tests/simulate_data/test_get_simulated_data.py !!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!! ============================== 2 errors in 0.38s =============================== (base) MAC-11108352:med_bench hzenati$ ls LICENSE medbench.egg-info README.md noisymoons.pdf benchmark_mediation.egg-info notebooks build results dist scripts generate_data.ipynb setup.py med_bench.egg-info src (base) MAC-11108352:med_bench hzenati$ pytest ============================= test session starts ============================== platform darwin -- Python 3.11.5, pytest-7.4.0, pluggy-1.0.0 rootdir: /Users/hzenati/Documents/Work/causal inference/med_bench plugins: anyio-3.5.0 collected 0 items / 2 errors

==================================== ERRORS ==================================== _ ERROR collecting src/tests/estimation/test_getestimation.py ImportError while importing test module '/Users/hzenati/Documents/Work/causal inference/med_bench/src/tests/estimation/test_get_estimation.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: ../../../../anaconda3/lib/python3.11/importlib/init.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) src/tests/estimation/test_get_estimation.py:19: in from med_bench.get_simulated_data import simulate_data E ModuleNotFoundError: No module named 'medbench' ____ ERROR collecting src/tests/simulate_data/test_get_simulated_data.py __ ImportError while importing test module '/Users/hzenati/Documents/Work/causal inference/med_bench/src/tests/simulate_data/test_get_simulated_data.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: ../../../../anaconda3/lib/python3.11/importlib/init.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) src/tests/simulate_data/test_get_simulated_data.py:21: in from med_bench.get_simulated_data import simulate_data E ModuleNotFoundError: No module named 'med_bench' =========================== short test summary info ============================ ERROR src/tests/estimation/test_get_estimation.py ERROR src/tests/simulate_data/test_get_simulated_data.py !!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!! ============================== 2 errors in 0.38s ===============================`

bthirion commented 6 months ago

On which branch ?

Have you run pip install -e . on the module ?

houssamzenati commented 6 months ago

I was working in my own renaming_modules branch, but indeed the command you suggested made everything work! thanks for this help.

Out of curiosity, what does the command pip install -e . do more than the python setup.py install command? should we add it in the Read.me file as well for the installation ??

bthirion commented 6 months ago

It just makes it explicit that the install path is the local path.

houssamzenati commented 6 months ago

Hi @judithabk6 , @bthirion , I think we can close this issue ?

bthirion commented 6 months ago

Closing for now.