Update PushLogQuantity and add value setter for user-defined logging scalars#74
Update PushLogQuantity and add value setter for user-defined logging scalars#74thomasgibson wants to merge 15 commits into
PushLogQuantity and add value setter for user-defined logging scalars#74Conversation
…ogging pull. Co-authored-by: Andreas Klöckner <inform@tiker.net>
inducer
left a comment
There was a problem hiding this comment.
Thanks for working on this! I think we're converging on an interface that makes sense. Some thoughts on that below.
| def set_value(self, value: Any) -> None: | ||
| """Set the logged quantity value.""" | ||
| raise NotImplementedError( | ||
| f"set_value not implemented for log quantity {self.name}." | ||
| ) |
There was a problem hiding this comment.
Is it avoidable to have set_value in the LogQuantity interface instead of only in PushLogQuantity? Having it breeds an expectation that every LogQuantity support it, which isn't right.
| """ | ||
|
|
||
| def add_internal(name, unit, description, def_agg): | ||
| def add_internal(name, unit, description, def_agg, set_value=None): |
There was a problem hiding this comment.
Now that we're standardizing set_value in PushLogQuantity, I'm no longer sold on the value of passing in set_value.
|
|
||
|
|
||
| class PushLogQuantity(LogQuantity): | ||
| """A loggable scalar whose value can be updated. |
There was a problem hiding this comment.
This should comment a bit on how the LogQuantity interface is a "pull" model generically, and how this offers "push" capability over it. What happens to redundant "set" attempts? What if nothing is pushed in a cycle?
|
|
||
|
|
||
| def set_quantity_value(mgr: LogManager, name: str, value: Any) -> None: | ||
| """Set a the value of a named LogQuantity. |
There was a problem hiding this comment.
Should narrow this to erroring if that quantity is not a push quantity.
|
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
This PR is a direct continuation of #69.
Examples have been updated to use the built-in
PushLogQuantityobject, and a simple value setter function (set_quantity_value) is importable which allows for explicit updating.