lephare-photoz / lephare

LePHARE is a code for calculating photometric redshifts.
MIT License
5 stars 1 forks source link

Example code downloading lephare data gives: TypeError: 'NoneType' object is not iterable #180

Closed hdante closed 2 months ago

hdante commented 2 months ago

Hello, when running code similar to the example:

import os
os.environ['LEPHAREDIR']='/path/to/my/preferred/directory/'
# You must import lephare after setting the variables
import lephare as lp
# If you do not set a config input to the following function in gets everything.
lp.data_retrieval.get_auxiliary_data()

Gives:

Python 3.11.9 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['LEPHAREDIR']='/lustre/t1/cl/lsst/tmp/henrique.almeida/testlephare/data'
>>> # You must import lephare after setting the variables
>>> import lephare as lp
User defined LEPHAREDIR is set. Code runs depend on all required
                auxiliary data being present at /lustre/t1/cl/lsst/tmp/henrique.almeida/testlephare/data.
Default work cache at /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/work
                    is already linked. This is linked to the run directory:
                    /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/runs/20240813T173817
>>> # If you do not set a config input to the following function in gets everything.
>>> lp.data_retrieval.get_auxiliary_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lustre/t1/cl/lsst/tmp/henrique.almeida/miniconda3/lib/python3.11/site-packages/lephare/data_retrieval.py", line 434, in get_auxiliary_data
    keymap = all_types_to_keymap(keymap)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/t1/cl/lsst/tmp/henrique.almeida/miniconda3/lib/python3.11/site-packages/lephare/prepare.py", line 170, in all_types_to_keymap
    for k in input_config:
TypeError: 'NoneType' object is not iterable

Versions:

johannct commented 2 months ago

can you specify which example you are starting with? It looks like we need to cut a more recent pypi release, this codebase is lagging behind. If you look at https://github.com/lephare-photoz/lephare/blob/9faf282467b8870a5522bff204623432adcda1e4/src/lephare/data_retrieval.py you can see that indeed the keymap is set to None by default, which will not work with https://github.com/lephare-photoz/lephare/blob/9faf282467b8870a5522bff204623432adcda1e4/src/lephare/prepare.py .
You can compare with main : https://github.com/lephare-photoz/lephare/blob/main/src/lephare/data_retrieval.py where the case keymap=None is treated.

So the root problem seems to be that doc is not reflecting pypi release codebase.

raphaelshirley commented 2 months ago

Again as a temporary solution while we fix the PyPI deployment you could run:

lp.data_retrieval.get_auxiliary_data(keymap=lp.default_cosmos_config)

Which will just download the default additional data sets.

hdante commented 2 months ago

Hello, everyone, tested with lephare 0.1.10 and it worked, thanks,

johannct commented 2 months ago

closed as resolved with v0.1.10