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

New Zealand parser broke in new arrow #2416

Closed
jarek opened this issue Apr 25, 2020 · 2 comments
Closed

New Zealand parser broke in new arrow #2416

jarek opened this issue Apr 25, 2020 · 2 comments
Labels
bug 🐞 techdebt Unpleasantness that does (or may in future) affect development

Comments

@jarek
Copy link
Collaborator

jarek commented Apr 25, 2020

arrow library used to manipulate times has been upgraded, and apparently parsers/NZ.py has been depending on some removed functionality.

In Kibana:

for production:

  File "/home/src/electricitymap/contrib/parsers/NZ.py", line 61, in fetch_production
    datetime = arrow.get(obj['soPgenGraph']['timestamp']).datetime
arrow.parser.ParserError: Could not match input '1587818770' to any of the following formats: YYYY-MM-DD, YYYY-M-DD, YYYY-M-D, YYYY/MM/DD, YYYY/M/DD, YYYY/M/D, YYYY.MM.DD, YYYY.M.DD, YYYY.M.D, YYYYMMDD, YYYY-DDDD, YYYYDDDD, YYYY-MM, YYYY/MM, YYYY.MM, YYYY

for exchange:

  File "/home/src/electricitymap/contrib/parsers/NZ.py", line 121, in fetch_exchange
    datetime = datetime_start.replace(minutes=+item[0])
AttributeError: unknown attribute: "minutes"
@jarek jarek added bug 🐞 techdebt Unpleasantness that does (or may in future) affect development labels Apr 25, 2020
@peterhughgriffin
Copy link
Contributor

Seems to be two different problems.

The production problem was brought in with 0.15.0. The arrow.get() method no longer accepts string without a format string. This is really easily fixed, as described in the Arrow documentation:

[CHANGE] Timestamps of type str are no longer supported without a format string in the arrow.get() method. This change was made to support the ISO 8601 basic format and to address bugs such as #447.

The following will NOT work in v0.15.0:

>>> arrow.get("1565358758")
>>> arrow.get("1565358758.123413")

The following will work in v0.15.0:

>>> arrow.get("1565358758", "X")
>>> arrow.get("1565358758.123413", "X")
>>> arrow.get(1565358758)
>>> arrow.get(1565358758.123413)

There's a warning about this if you run in older versions:

ArrowParseWarning: The .get() parsing method with a format string will parse more strictly in version 0.15.0.See arrow-py/arrow#612 for more details.

The exchange problem is a little older, from 0.14.5:

[CHANGE] Removed deprecated replace shift functionality. Users looking to pass plural properties to the replace function to shift values should use shift instead.

Very easily solved too, just change replace to shift.

I'll get on with making a pull request for both of these.

@robertahunt
Copy link
Contributor

fixed by #2420

martincollignon added a commit that referenced this issue May 28, 2020
* Fix New Zealand parser issues due to upgrade to arrow (#2416)

* Merge new CL parser

* Put validation from BR back in

* CL Parser - Simple fixes

* CL Parser - Log unexpected generation and fix total overwrite TERMICAS bug

* CL Parser - Use Correct Live data sources

* CL Parser - remove redundant TYPE_MAPPING_LIVE

* Upgrade live data part to return a list of all available data

* CL Parser - Add key checking for the live solar and wind data

* CL Parser - Update comments

* CL Parser - Convert PD timestamp object to datetime

Co-authored-by: martincollignon <2604526+martincollignon@users.noreply.github.com>
con-cat pushed a commit to con-cat/electricitymap-contrib that referenced this issue May 18, 2021
)

* Fix New Zealand parser issues due to upgrade to arrow (electricitymaps#2416)

* Merge new CL parser

* Put validation from BR back in

* CL Parser - Simple fixes

* CL Parser - Log unexpected generation and fix total overwrite TERMICAS bug

* CL Parser - Use Correct Live data sources

* CL Parser - remove redundant TYPE_MAPPING_LIVE

* Upgrade live data part to return a list of all available data

* CL Parser - Add key checking for the live solar and wind data

* CL Parser - Update comments

* CL Parser - Convert PD timestamp object to datetime

Co-authored-by: martincollignon <2604526+martincollignon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 techdebt Unpleasantness that does (or may in future) affect development
Projects
None yet
Development

No branches or pull requests

3 participants