Giter Club home page Giter Club logo

earth's People

Contributors

horrgs avatar

Watchers

 avatar

earth's Issues

Deprecations in weather.gov Forecast API

Per the documentation on weather.gov, a number of values are being deprecated in the near future. Below are following snippets relevant to the values that are being deprecated.

Snippet 1:

self.temperature = period['temperature']
"""
Sort of deprecated? There are two flags under temperature - description and "?? one of ??". Per NWS for
description, "High/low temperature for the period, depending on whether the period is day or night.
This property as an integer value is deprecated. Future versions will express this value as a quantitative
value object. To make use of the future standard format now, set the "forecast_temperature_qv" feature
flag on the request.
"""
self.temperature_unit = period['temperatureUnit'] # unit of the temperature value.
"""TODO: This property is deprecated. Future versions will indicate the unit within the quantitative value object
for the temperature property. To make use of the future standard format now, set the "forecast_temperature_qv"
feature flag on the request."""

Snippet 2:

self.wind_speed = period['windSpeed'] # wind speed for the period.
"""TODO: This property as an string value is deprecated. Future versions will express this value as a quantitative
value object. To make use of the future standard format now, set the forecast_wind_speed_qv" feature
flag on the request."""
self.wind_gust = period['windGust'] # peak wind gust for the period.
"""TODO: Per NWS docs, This property as an string value is deprecated. Future versions will express this value as
a quantitative value object. To make use of the future standard format now, set the "forecast_wind_speed_qv" feature
flag on the request."""

temperature, windSpeed, and windGust will now become QuantitativeValue objects (as opposed to integers.)
temperatureUnit will be completely deprecated. QuantitativeValue objects have a property for units, and temperatureUnit will go there (in a way) under the QuantitativeValue for temperature.

Issue with NWS headers in generic request services.

Below, we have our generic request method

def req(url, method: RequestMethod, payload=None):
    headers = {
        'User-Agent': 'https://www.github.com/Horrgs/Earth',
        'Feature-Flag': 'forecast_temperature_qv'
    }
    try:
        if payload is not None:  # check if a payload is specified for HTTP request.
            req = requests.request(method=method.value, url=url, headers=headers, data=payload)  # valid payload to send with HTTP request.
        else:
            req = requests.request(method.value, headers=headers, url=url)  # no payload to send, send remaining info.
 

The issue lies with the headers. This method is to serve for multiple services, and therefore the headers for the NWS service shouldn't be sent unless it's the NWS service sending the request. Specifically, the below lines should be removed, and headers shall only send per service need.

Earth/utils/req.py

Lines 36 to 39 in af7c5b1

headers = {
'User-Agent': 'https://www.github.com/Horrgs/Earth',
'Feature-Flag': 'forecast_temperature_qv'
}

See additional details on commit 9 here

Invalid use of typing.Dict

We ran a test to see how things are working so far, here is a snippet of said response:

response = get('https://api.weather.gov/gridpoints/TOP/31,80/forecast', RequestMethod.GET)
print(response['properties'])

p = GridpointForecastGeoJson.from_json(json.dumps(response))
print(p.properties.periods)

The issue here occurs on the 3rd line with the call & loading of GridpointForecastGeoJson.
This loops back to GridpointForecast & then GridpointForecastPeriod, where the error occurs.
Specifically, this line in GridpointForecastPeriod

temperature: Dict[QuantitativeValue]

raises a TypeError with an error message of: Too few parameters for typing.Dict; actual 1, expected 2.

The error here is that Dict[] expects two arguments, see the docs here.

Thus, errors exist in the following locations:

temperature: Dict[QuantitativeValue] # sort of deprecated. see gridpoint.py (old) & docs.

wind_speed: Dict[QuantitativeValue] # sort of deprecated. see gridpoint.py (old) & docs.

elevation: Dict[QuantitativeValue] # QuantitativeValue. elevation of the forecast area.

properties: Dict[GridpointForecast] # returns GridpointForecast object.

& more.

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.