-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: Improve the metric set implementation. #77
Conversation
This now includes nested aggregation, hooking up the metric sets to the model and use by the CSV recorder. There's still some WIP but a general review would be good at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this a good read through. I like the aggregation approach and it looks like it works correctly.
pywr-core/src/model.rs
Outdated
mut states, | ||
mut parameter_internal_states, | ||
mut metric_set_internal_states, | ||
mut recorder_internal_states, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might simplify things to combine the states into a single object, if this is feasible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is something that needs doing. I was planning to tidy it up after this PR
@@ -42,14 +42,10 @@ impl AggregationPeriod { | |||
while current_date < end_date { | |||
// This should be safe to unwrap as it will always create a valid date unless | |||
// we are at the limit of dates that are representable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the time crate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is old and should be moved to the start_of_next_period
function.
/// Compute the final aggregation value from the current state. | ||
/// | ||
/// This will also compute the final aggregation value from the child aggregators if any exists. | ||
/// This includes aggregation calculations over partial or unfinished periods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a user setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it could be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add this as a new issue for the sake of getting this PR done.
/// | ||
/// A metric set can optionally have an aggregator, which will apply an aggregation function | ||
/// over metrics set. If the aggregator has a defined frequency then the aggregation will result | ||
/// in multiple values (i.e. per each period implied by the frequency). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to have a doc text model here that shows how the nest aggregation works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this would be better as an extended section in the proposed book? I am tempted to leave it for now, but then also need to ensure we write that documentation.
I've fixed the out-of-date comment. This could be merged now, or we can address wider documentation issue first (at the expense of delaying the merge). |
This now includes nested aggregation, hooking up the metric sets to the model and use by the CSV recorder.
There's still some WIP but a general review would be good at this point.