nf1s / covid

Python package to fetch information regarding the novel corona virus provided by Johns Hopkins university and worldometers.info
https://ahmednafies.github.io/covid/
MIT License
42 stars 25 forks source link

John Hopkins Retrieval For Sweden and MS Zaandam No Longer Succeeds #42

Closed nuertey closed 4 years ago

nuertey commented 4 years ago

Hello @ahmednafies , Thanks for the python module. It has been working for me for all countries but just today I discovered that for some reason retrieval for Sweden fails. The error observed is:

Netherlands

{'id': '12', 'country': 'Netherlands', 'confirmed': 47945, 'active': 41729, 'deaths': 6035, 'recovered': 181, 'latitude': 52.3167, 'longitude': 5.55, 'last_update': 1591652013000}

Sweden

Traceback (most recent call last):
  File "nuertey_covid19_final.py", line 76, in <module>
    combined_output = [retrieve_covid_statistics(country) for country in data['name']] 
  File "nuertey_covid19_final.py", line 76, in <listcomp>
    combined_output = [retrieve_covid_statistics(country) for country in data['name']] 
  File "nuertey_covid19_final.py", line 68, in retrieve_covid_statistics
    country_status = cov_19.get_status_by_country_name(country_name_input)
  File "/home/rena/MyEnv37/lib/python3.7/site-packages/covid/john_hopkins/covid.py", line 238, in get_status_by_country_name
    return CovidModel(**case).dict()
  File "pydantic/main.py", line 283, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for CovidModel
Recovered
  none is not an allowed value (type=type_error.none.not_allowed)

My package versions are as follows:

pip show pydantic
Name: pydantic
Version: 1.4
Summary: Data validation and settings management using python 3.6 type hinting
Home-page: https://github.com/samuelcolvin/pydantic
Author: Samuel Colvin
Author-email: s@muelcolvin.com
License: MIT
Location: /home/rena/MyEnv37/lib/python3.7/site-packages
Requires: 
Required-by: covid

pip show requests
Name: requests
Version: 2.22.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache 2.0
Location: /home/rena/MyEnv37/lib/python3.7/site-packages
Requires: chardet, idna, urllib3, certifi
Required-by: world-bank-data, tensorboard, scrapelib, requests-oauthlib, rebound-cli, Quandl, percy, pandas-datareader, gspread, google-api-core, folium, dash, covid, alpha-vantage

pip show covid
Name: covid
Version: 2.2.0
Summary: Python SDK to get information regarding the novel corona virus provided by Johns Hopkins university and worldometers.info
Home-page: https://ahmednafies.github.io/covid/
Author: Ahmed Nafies
Author-email: ahmed.nafies@gmail.com
License: MIT
Location: /home/rena/MyEnv37/lib/python3.7/site-packages
Requires: requests, pydantic, beautifulsoup4
Required-by: 

Am I missing something? Thanks Nuertey

nuertey commented 4 years ago

@ahmednafies, Note that the same error occurs for MS Zaandam. The exception then caught (I print out the country id and country name for debug first) is:

116
MS Zaandam

Caught an unexpected exception:
1 validation error for CovidModel
Recovered
  none is not an allowed value (type=type_error.none.not_allowed)
nf1s commented 4 years ago

I will investigate it, it is the first time that the integration johnhopkins has issues. :)

nf1s commented 4 years ago

I issue was reproduced.

nf1s commented 4 years ago

Issue is fixed, please update your package to version 2.2.11, it seems that John Hopkins API is now returning None for recovered cases

nuertey commented 4 years ago

Thank you. It is confirmed on my end that the issue is indeed fixed. I upgraded the package as instructed and do confirm that retrieval of all the countries is working successfully. Thanks again.