Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source demographic data from UN Population API #4

Closed
SeaCelo opened this issue Oct 19, 2022 · 3 comments · Fixed by #14
Closed

Source demographic data from UN Population API #4

SeaCelo opened this issue Oct 19, 2022 · 3 comments · Fixed by #14
Assignees
Labels
data Data calibration for South Africa

Comments

@SeaCelo
Copy link
Collaborator

SeaCelo commented Oct 19, 2022

Update demographics.py to use demographic data from UN Population API

  • fertility
  • mortality
  • population

Also define the base (start) year.

@SeaCelo SeaCelo added the data Data calibration for South Africa label Oct 19, 2022
@SeaCelo
Copy link
Collaborator Author

SeaCelo commented Oct 27, 2022

Linking pull request: #7

@SeaCelo SeaCelo linked a pull request Oct 27, 2022 that will close this issue
@SeaCelo
Copy link
Collaborator Author

SeaCelo commented Nov 12, 2022

I'm documenting an issue and fix I ran into when connecting to the UN Population API. On any conda environment except for (base), I was getting an SSL error when trying to download from the API. To replicate from within conda, run these in a python prompt:
python
import pandas as pd
url = 'https://population.un.org/dataportalapi/api/v1/data/indicators/47/locations/710/start/2021/end/2021?format=csv'
df = pd.read_csv(url)
df

If you do this in the base environment, it should work fine. If you switch to another environment it fails with an SSL error:
ssl.SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED]

What I think is happening:
The (base) environment uses an older version of openssl (version 1.1.1). When you create a new environment, it installs a newer version (mine was 3.0.7). Openssl version 3 is not fully backward compatible and it seems this newer version doesn't support the older protocols that the UN uses.
The solution is to install the same openssl as (base) on your (ogzaf-dev) environment:
conda install openssl=1.1.1

I will test further to see the latest version of openssl that will still work with the UN site. We may consider adding a version of openssl to the environment.yml file (#15)

@sarvonz Please test this

@SeaCelo
Copy link
Collaborator Author

SeaCelo commented Nov 15, 2022

This is confirmed on the Mac installation and I'm suggesting a change to the installation instructions to require openssl version 1.1.1.

Still need to confirm this on a Windows installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Data calibration for South Africa
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants