electricitymaps / electricitymaps-contrib

A real-time visualisation of the CO2 emissions of electricity consumption
https://app.electricitymaps.com
GNU Affero General Public License v3.0
3.48k stars 925 forks source link

More specification for behaviour of target_datetime #1203

Closed jarek closed 6 years ago

jarek commented 6 years ago

Hi,

I was thinking about implementing target_datetime in some of the parsers, and came up with the following questions. If you let me know what you prefer, I can update comments in example parser and README to match :+1:

maxbellec commented 6 years ago

Thanks a lot jarek for your question, we haven't finished the specifications, but maybe your input could help. And your questions definitely help. I'm currently changing the ENTSOE.py code so that's not a reference.

In general, since there are many parsers and only one function to launch them all (let's call it launch_parser), the logic should be as much as possible in launch_parser so that the parser get be as simple as possible.

Ideally, the parser should return as many values as possible (but keeping it simple, only one query) starting from the target_datetime. If with a single query the parser can get data for a whole day (three days / 5 hours ...), it should return the data for the whole day (three days / 5 hours ...). If the parser only fetches a single datapoint, it should return a single datapoint. We will keep a hard-coded record of the timespan each parser can fetch. The idea is that if we're missing a week, we'll launch the parser once for every day if it can return for a whole day, or once for every hour if it can handle only a single datapoint.

If the parser cannot fetch for the required datetime (whatever the reason), it should return None.

So regarding more specifically your questions :

This may not be super clear, don't hesitate if something's not clear or if you feel we can do something easier / better.

maxbellec commented 6 years ago

@corradio I believe it's what we talked about, don't hesitate to react if it's not or if something wasn't clear

corradio commented 6 years ago

I think that pretty much sums it up. Thanks @maxbellec ! I might add that in this iteration we're trying to stay as agile as possible and so we're optimising for simplicity rather than future scalability. With that in mind, we might want to add more information to parsers themselves in the future to optimise things further - but for now, we're keeping it simple.

jarek commented 6 years ago

Okay, thanks!

To try to summarize:

I think that makes sense - certainly it does for now.

maxbellec commented 6 years ago

We talked about it again with @corradio. @jarek I'll steal your summary and add:

I'll adapt example.py as a consequence

jarek commented 6 years ago

This looks fine now after #1237, I'll close it. Thanks!