Detangle generation data - #428
Conversation
|
|
||
| class Generation(TimeWindowMixin, DropoutMixin): | ||
| """Generation configuration model.""" | ||
| class GenerationWindow(Base): |
There was a problem hiding this comment.
This class is used for both the input and target generation slices. The full config paths are config.generation.[input/target]
This class doesn't have time_resolution_minutes or zarr_path since those are assumed to be shared and they live directly under config.generation
peterdudfield
left a comment
There was a problem hiding this comment.
Looks great ive left a few comments but nothing big
Do you want to add a migrations script in this PR too? Or perhaps that will come along a bit later
Typically we put migration scripts in PVNet when we upgrade it to newer versions of ocf-data-sampler. I think we should do the same. Plus we should keep an eye on how many breaking changes we're introducing. I think we should consider a clean break |
6d91d01 to
2c35348
Compare
| dtype="datetime64[m]", | ||
| ) | ||
| generation_mw = np.arange(4 * 2, dtype=float).reshape(4, 2) | ||
| capacity_mwp = np.ones((4, 2)) |
There was a problem hiding this comment.
I am a bit in two minds about this test; I think it duplicates a lot of things done by tests in tests/select/test_dropout.py, as all this function does is check for keys and call apply_dropout, which is already extensively tested in the dropout section. I guess it can stay to catch if someone accidentally makes the if statements nested or something... But I think it can maybe use _generation_da() instead of re-making generation DataArray?
There was a problem hiding this comment.
Okay actually, I've noticed it's not even testing satellite dropout, so it will not tell you anything useful that apply_dropout wouldn't I think?
There was a problem hiding this comment.
Yeh I see what you mean, and I am a fan of less code.
This test does catch if everything in the configs and datasets are unpacked and repacked correctly. Like did we take the right settings from the config and apply the correct dropout to each data source. The generation settings are under config.generation.input but the satellite setting are shallower under config.satellite. But the tests in test_dataset.py should catch that too, so that seems like a strike against it. This additional test would only guard against us going something silly like using the satellite dropout settings into the generation.
The apply_dropout_to_datasets() function is advertised as an in-place operation, and this test maybe does help lock that in. It could help us catch errors if we ever made (accidentally or otherwise) apply_dropout_to_datasets() out-of-place.
Note: I do plan to come back and make us more consistent with what we return for in-place and out-of-place functions. Sometimes we return an object for an in-place operation and sometimes we don't.
I don't feel strongly either way. What do you think?
There was a problem hiding this comment.
Okay yeah I think it does make sense to check that we've passed the right config along. I think in that case it should check that dropout is applied to satellite (currently satellite has settings that don't result in dropout; I think the result of that is ambiguous - if nothing happened it can mean apply_dropout() wasn't called at all), and also maybe check that nothing happens to generation_target? That feels like something a silly update might end up breaking.
I think the fact that it's in-place is locked in apply_dropout() as that's already in-place? You can't really change that by only changing apply_dropout_to_datasets().
I also still think the _generation_da() from this file can probably be reused here instead of LL 105-113, but maybe I'm missing something?
Also, I do realise I am nitpicking over a test that was already kinda bad before this PR. If you think this is getting silly, go ahead and merge as is, LGTM otherwise!
There was a problem hiding this comment.
Yes it is locked in, because of apply_dropout(), but there is always the chance we might decide to make apply_dropout() out-of-place later and forget to update this function. If we did that we'd be silently not apply dropout anywhere and I think this is the only test that might catch that. But that is an real edge case, we shouldn't be so silly.
So how about this this then. We switch to use _generation_da() as a helper, we add generation_target to the sample and check it isn't touched, we add dropout to the satellite and we merge this? I'm going to do a sweep through the tests in a later PR anyay
Co-authored-by: Alexandra Udaltsova <43303448+AUdaltsova@users.noreply.github.com>
b583cf9 to
cfa6e8e
Compare
Pull Request
Description
Currently when we run models in production we HAVE to provide generation data, even if the model does not use generation data as an input. We've tangled too much additional responsibility into the generation data like also providing the coordinates and t0-spacing.
This PR detangles the generation data inputs from the rest of the code.
The main changes are:
sampling_grid.apply_history_dropout()was designed specifically for the old generation data slice so that the future generation wasn't dropped out but the last data was. We no longer need this since we have split the generation data already. I have modified it intoapply_dropout()so that all values after the randomly sampled dropout time are filled with NaNs. No dropout is allowed for the target generation data.Other changes:
generalandinput_datasections. We have never used thegeneralsection. So I've moved this top level and now the top level is everything which was previously underinput_data. I also renamed the config class toPVNetDataConfigto allow us naming room for any future datasets. Completes move input data up a level in config #60Checklist: