Coder Social home page Coder Social logo

Comments (9)

EJEP avatar EJEP commented on August 15, 2024 2

This sort of error is checked for elsewhere, so it should be checked for here as well. I'll have a look at putting some in

from datapoint-python.

tonyjward avatar tonyjward commented on August 15, 2024

Here are a few more examples of site_id where it falls over
[354281, 354091, 322183, 352294, 310120, 350410]

from datapoint-python.

EJEP avatar EJEP commented on August 15, 2024

I can't reproduce the error currently:

>>> conn = datapoint.Manager(api_key=key)
>>> ids = [354281, 354091, 322183, 352294, 310120, 350410] 
>>> for id in ids:
...     forecast = conn.get_forecast_for_site(id, "3hourly")
...     print(forecast.continent)
... 
EUROPE
EUROPE
EUROPE
EUROPE
EUROPE
EUROPE

From the error in the screenshot it looks like some data wasn't returned from the API and the package failed to handle this.

from datapoint-python.

tonyjward avatar tonyjward commented on August 15, 2024

In the past I've had similar issues with 'Location' being the error rather than 'continent'.

I can raise another issue if it happens again.

from datapoint-python.

tonyjward avatar tonyjward commented on August 15, 2024

Just to let you know the issue happened again today between 2pm and 3pm.

The error this time was 'Location'

The following sites failed 354352,324164,324228,353879,353006,351392,350413,352458,351625,3784,352664,99203,350891,354251,3876,353217,350702,353358,350266,3796,353607,350153,352930,353007,350236,353289,351029,351668,351802,350193,353058,350047,353039,353965,351976,3693,351081,350768,350883,350812,350893,352823,354137,352730,350602,354243,324189,353233,354357,351854,353128,352438,354344,351634,352251,350885,352791,352785,353394,350163,351850,351742,352806,354362,351493,354169,353179,352061,352880,353525,350929,350842,353733,352068,356043

from datapoint-python.

jacobtomlinson avatar jacobtomlinson commented on August 15, 2024

This problem is due to the API rather than this library. The focus here just needs to be on good error handling.

from datapoint-python.

EJEP avatar EJEP commented on August 15, 2024

Another thing to check:

 line 370, in get_forecast_for_site
 for day in data['SiteRep']['DV']['Location']['Period']:
KeyError: 'Location'

Need to check if this is fixed in #103

from datapoint-python.

tonyjward avatar tonyjward commented on August 15, 2024

This has happened today at 945am and still ongoing.

running simple_forecast.py with

site = conn.get_nearest_forecast_site(52.5998000, -2.14030000)

gives

Wolverhampton Racecourse
Traceback (most recent call last):
  File "simple_forecast.py", line 12, in <module>
    forecast = conn.get_forecast_for_site(site.id, "3hourly")
  File "/home/d14xj1/.venvs/datapoint/lib/python3.6/site-packages/datapoint/Manager.py", line 370, in get_forecast_for_site
    for day in data['SiteRep']['DV']['Location']['Period']:
KeyError: 'Location'

and the following site id's are known to be effected
354281,353639,351907,351223,354352,351392,350413,3876,353217,353358,353007,350236,353289,351029,351414,351668,351802,353058,350047,3693,350883,350893,352823,350602,324189,3781,351854,353128,352251,350885,350163,354169,352061,352880,353525,356043

Note i'm using version 0.9.1

from datapoint-python.

EJEP avatar EJEP commented on August 15, 2024

The change in #103 did not fix the issue - that change leaves some fields empty if the location key is missing and then falls over when the key is accessed again. We should fail if the location key is missing as I think that means that there is no forecast data to return

from datapoint-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.