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

[Checklist]: Upgrade all parsers with event classes #6011

Open
55 of 96 tasks
kruschk opened this issue Oct 15, 2023 · 1 comment
Open
55 of 96 tasks

[Checklist]: Upgrade all parsers with event classes #6011

kruschk opened this issue Oct 15, 2023 · 1 comment

Comments

@kruschk
Copy link
Contributor

kruschk commented Oct 15, 2023

I noticed on the Building a new parser wiki page that several classes have been introduced to ensure parsed data is structured correctly; however, only about a third of all the parsers have been updated to use them. As promised in my comment on #5986, I've compiled the following list to keep track of which parsers have been upgraded and which have not:

To determine which parsers have been upgraded, I used the command below to find the modules using any one of the event classes. This assumes that if the module instantiates any one of those objects, then all of the functions in that parser have been upgraded accordingly.

grep -El '(Exchange|Price|ProductionBreakdown|TotalConsumption|TotalProduction)(List)?\(' parsers/*.py

Let me know if I've missed anything!

kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 15, 2023
- Upgrade the parser to use the ProductionBreakdown, ProductionMix, and
  TotalConsumption, and ZoneKey classes.
- Conform to Black's 88-column default line length limit.
- Factor out duplicate code.

Refs: electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 15, 2023
Upgrade the parser to use the ProductionBreakdown, ProductionMix, and
TotalConsumption, and ZoneKey classes. This should yield no functional
change to the parser. Note that this does not resolve the current issue
with the parser's fetch_consumption function. Additionally:

- Conform to Black's 88-column default line length limit.
- Factor out duplicate code.

Refs: electricitymaps#5986, electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 15, 2023
Upgrade the parser to use the ProductionBreakdown, ProductionMix,
TotalConsumption, and ZoneKey classes. This should yield no functional
change. Note that this does not resolve the current issue with the
fetch_consumption function. Additionally:

- Conform to Black's 88-column default line length limit.
- Factor out duplicate code.

Refs: electricitymaps#5986, electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 15, 2023
Upgrade the parser to use the ProductionBreakdown, ProductionMix,
TotalConsumption, and ZoneKey classes. This should yield no functional
change. Note that this does not resolve the current issue with the
fetch_consumption function. Additionally:

- Conform to Black's 88-column default line length limit.
- Factor out duplicate code.

Refs: electricitymaps#5986, electricitymaps#6011
@kruschk kruschk changed the title Upgrade all parsers with data-validating classes Upgrade all parsers with event classes Oct 16, 2023
@VIKTORVAV99
Copy link
Member

@unitrium FYI

@VIKTORVAV99 VIKTORVAV99 pinned this issue Oct 19, 2023
@VIKTORVAV99 VIKTORVAV99 changed the title Upgrade all parsers with event classes [Checklist]: Upgrade all parsers with event classes Oct 19, 2023
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
Upgrade the parser to use the ProductionBreakdown, ProductionMix,
TotalConsumption, and ZoneKey classes. This should yield no functional
change. Note that this does not resolve the current issue with the
fetch_consumption function. Additionally:

- Comply with Black's 88-column default line length limit.
- Factor out duplicate code.

Refs: electricitymaps#5986, electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
- Be more specific about the return type of the _request function.
- Import the Any type directly.
- Swap out pytz in exchange for zoneinfo.
- Use the ProductionMix.add_value method instead of a dictionary
  comprehension.

Refs: electricitymaps#5986, electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
Swap out TotalConsumption for TotalConsumptionList, as the former is
considered an implementation detail while the latter is part of the
public API.

Refs: electricitymaps#5986, electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
Upgrade the parser to use the ProductionBreakdown, ProductionMix,
TotalConsumption, and ZoneKey classes. This should yield no functional
change. Note that this does not resolve the current issue with the
fetch_consumption function. Additionally:

- Comply with Black's 88-column default line length limit.
- Factor out duplicate code.

Refs: electricitymaps#5986, electricitymaps#6011, electricitymaps#6013
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
- Be more specific about the return type of the _request function.
- Import the Any type directly.
- Swap out pytz in exchange for zoneinfo.
- Use the ProductionMix.add_value method instead of a dictionary
  comprehension.

Refs: electricitymaps#5986, electricitymaps#6011, electricitymaps#6013
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
Swap out TotalConsumption for TotalConsumptionList, as the former is
considered an implementation detail while the latter is part of the
public API.

Refs: electricitymaps#5986, electricitymaps#6011, electricitymaps#6013
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 24, 2023
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 25, 2023
Upgrade the parser to use the ExchangeList, ProductionBreakdownList,
ProductionMix, and ZoneKey classes. This should yield no functional
change. Additionally:

- Comply with Black's 88-column default line length limit.
- Define global constants to replace a number of local variables and
  literals.
- Try to use more consistent names throughout.

Refs: electricitymaps#6011, electricitymaps#6050
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 25, 2023
Upgrade the parser to use the ExchangeList, ProductionBreakdownList,
ProductionMix, and ZoneKey classes. This should yield no functional
change. Additionally:

- Comply with Black's 88-column default line length limit.
- Define global constants to replace a number of local variables and
  literals.
- Try to use more consistent names throughout.

Refs: electricitymaps#6011, electricitymaps#6050
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 25, 2023
The JSON arrays a and b returned by the two endpoints appear to be
parallel in the sense that element a[i] corresponds with element b[i]
for all i of interest. Zip these arrays together and iterate over the
resulting pairs instead of iterating over one and performing a linear
search to find the corresponding element in the other. Additionally:

- Check whether we've been bitten by a race condition while requesting
  the above array data and bail out if so.
- Skip the first element of each array because the reported base load is
  always 0 MW.

Refs: electricitymaps#6011, electricitymaps#6050
VIKTORVAV99 added a commit that referenced this issue Oct 25, 2023
* refactor: upgrade CA-SK with event classes

Upgrade the parser to use the ProductionBreakdown, ProductionMix,
TotalConsumption, and ZoneKey classes. This should yield no functional
change. Note that this does not resolve the current issue with the
fetch_consumption function. Additionally:

- Comply with Black's 88-column default line length limit.
- Factor out duplicate code.

Refs: #5986, #6011, #6013

* refactor: address review comments

- Be more specific about the return type of the _request function.
- Import the Any type directly.
- Swap out pytz in exchange for zoneinfo.
- Use the ProductionMix.add_value method instead of a dictionary
  comprehension.

Refs: #5986, #6011, #6013

* refactor: switch to TotalConsumptionList

Swap out TotalConsumption for TotalConsumptionList, as the former is
considered an implementation detail while the latter is part of the
public API.

Refs: #5986, #6011, #6013

* refactor: narrow down payload types

Refs: #5986, #6011, #6013

---------

Co-authored-by: Viktor Andersson <30777521+VIKTORVAV99@users.noreply.github.com>
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 26, 2023
- When a pair of requests have failed, retry them until they succeed or
  the maximum number of attempts is exceeded.
- Simplify the validation logic by making better use of the event
  classes instead of introducing extraneous data structures.

Refs: electricitymaps#6011, electricitymaps#6050
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 28, 2023
Upgrade the parser to use the ProductionBreakdownList, ProductionMix,
StorageMix, and ZoneKey classes. This should yield no functional change.
Additionally:

- Comply with Black's 88-column default line length limit.
- Define global constants to replace magic values.
- Eliminate a few unnecessary variables.

Refs: electricitymaps#6011, electricitymaps#6062
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Oct 29, 2023
Upgrade the parser to use the ExchangeList, ProductionBreakdownList,
ProductionMix, and ZoneKey classes. This should yield no functional
change. Additionally:

- Comply with Black's 88-column default line length limit.
- Define global constants to replace local variables and literals.
- Simplify the logic that retrieves event data from the source by
  transforming the response payload into a more convenient data
  structure.

Refs: electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Nov 2, 2023
Upgrade the parser to use the ProductionBreakdownList, ProductionMix,
StorageMix, and ZoneKey classes. This should yield no functional change.
Additionally:

- Comply with Black's 88-column default line length limit.
- Define global constants to replace magic values.
- Eliminate a few unnecessary variables.

Refs: electricitymaps#6011, electricitymaps#6062
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Nov 2, 2023
Pass data to the ProductionMix object using the add_value method instead
of during object instantiaton.

Refs: electricitymaps#6011, electricitymaps#6062
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Nov 2, 2023
Upgrade the parser to use the ExchangeList, ProductionBreakdownList,
ProductionMix, and ZoneKey classes. This should yield no functional
change. Additionally:

- Comply with Black's 88-column default line length limit.
- Define global constants to replace local variables and literals.
- Simplify the logic that retrieves event data from the source by
  transforming the response payload into a more convenient data
  structure.

Refs: electricitymaps#6011
kruschk added a commit to kruschk/electricitymap-contrib that referenced this issue Feb 6, 2024
AlisCode added a commit to AlisCode/electricitymaps-contrib that referenced this issue Mar 4, 2024
AlisCode added a commit to AlisCode/electricitymaps-contrib that referenced this issue Mar 4, 2024
AlisCode added a commit to AlisCode/electricitymaps-contrib that referenced this issue Mar 6, 2024
AlisCode added a commit to AlisCode/electricitymaps-contrib that referenced this issue Mar 10, 2024
AlisCode added a commit to AlisCode/electricitymaps-contrib that referenced this issue Mar 10, 2024
VIKTORVAV99 pushed a commit that referenced this issue Mar 10, 2024
* (#6011) Refactor AX parser to use electricitymaps event classes

* (#6011) Fix type errors for zone_key
AlisCode added a commit to AlisCode/electricitymaps-contrib that referenced this issue Mar 18, 2024
AlisCode added a commit to AlisCode/electricitymaps-contrib that referenced this issue Mar 19, 2024
VIKTORVAV99 added a commit that referenced this issue Mar 20, 2024
* (#6011) Update CZ parser

* (#6011) Use .add_value() instead of indexing values

---------

Co-authored-by: Viktor Andersson <30777521+VIKTORVAV99@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants