OpenDRR / opendrr-api

REST API for OpenDRR data / API REST pour les données OpenDRR
MIT License
4 stars 7 forks source link

psra_postgres2es.py: configparser.NoOptionError: No option 'version' in section: 'es' #247

Open anthonyfok opened 6 months ago

anthonyfok commented 6 months ago

Problem

During a full OpenDRR/opendrr-api stack build with processDSRA=true in .env, I encountered into the following errors at RUN python3 psra_postgres2es.py at ## Load Probabilistic Model Indicators in the export_to_elasticsearch() function:

Error logs:

python-opendrr-1  | [add_data.sh:824:export_to_elasticsearch] ## Load Probabilistic Model Indicators
python-opendrr-1  | [add_data.sh:827:export_to_elasticsearch] Creating PSRA indices in Elasticsearch
python-opendrr-1  | [add_data.sh:828:export_to_elasticsearch] RUN: python3 psra_postgres2es.py
python-opendrr-1  | /usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!
python-opendrr-1  |   warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
python-opendrr-1  | Traceback (most recent call last):
python-opendrr-1  |   File "/usr/lib/python3.8/configparser.py", line 789, in get
python-opendrr-1  |     value = d[option]
python-opendrr-1  |   File "/usr/lib/python3.8/collections/__init__.py", line 898, in __getitem__
python-opendrr-1  |     return self.__missing__(key)            # support subclasses that define __missing__
python-opendrr-1  |   File "/usr/lib/python3.8/collections/__init__.py", line 890, in __missing__
python-opendrr-1  |     raise KeyError(key)
python-opendrr-1  | KeyError: 'version'
python-opendrr-1  |
python-opendrr-1  | During handling of the above exception, another exception occurred:
python-opendrr-1  |
python-opendrr-1  | Traceback (most recent call last):
python-opendrr-1  |   File "psra_postgres2es.py", line 14, in <module>
python-opendrr-1  |     version = config.get("es", "version")
python-opendrr-1  |   File "/usr/lib/python3.8/configparser.py", line 792, in get
python-opendrr-1  |     raise NoOptionError(option, section)
python-opendrr-1  | configparser.NoOptionError: No option 'version' in section: 'es'
python-opendrr-1  | Command exited with non-zero status 1
python-opendrr-1  | 0.06user 0.02system 0:00.19elapsed 47%CPU (0avgtext+0avgdata 29260maxresident)k
python-opendrr-1  | 23792inputs+16outputs (102major+8797minor)pagefaults 0swaps
python-opendrr-1  |
python-opendrr-1  | real        0m0.193s
python-opendrr-1  | user        0m0.065s
python-opendrr-1  | sys 0m0.027s
python-opendrr-1  |
python-opendrr-1  | real        0m1.317s
python-opendrr-1  | user        0m0.095s
python-opendrr-1  | sys 0m0.034s
python-opendrr-1 exited with code 1

Diagnosis

git log -p python/sample_config.ini

reveals that, in commit d7e0eeb4c437b55684d9f627b10030e368e8996e which was squashed merged on 2022-06-20, (i.e. Pull Request #211 addressing Issue #193), or, more specifically, commit 1134f60bb50ec77f8b209b1a82d26071508e7d49 dated 2022-06-13 before squashing, the version variable in python/sample_config.ini was replaced with index_version, which is read by python/gen_pygeoapi_config.py:

    version = auth.get("es", "index_version")

It looks like python/psra_postgres2es.py needs a similar edit too.