Skip to content

Update PushLogQuantity and add value setter for user-defined logging scalars#74

Open
thomasgibson wants to merge 15 commits into
illinois-ceesd:mainfrom
thomasgibson:update-push-quantities
Open

Update PushLogQuantity and add value setter for user-defined logging scalars#74
thomasgibson wants to merge 15 commits into
illinois-ceesd:mainfrom
thomasgibson:update-push-quantities

Conversation

@thomasgibson

Copy link
Copy Markdown

This PR is a direct continuation of #69.

Examples have been updated to use the built-in PushLogQuantity object, and a simple value setter function (set_quantity_value) is importable which allows for explicit updating.

@thomasgibson

Copy link
Copy Markdown
Author

@inducer This PR addresses all your comments in #69 --- so that PR is safe to close. I had issues with local forks so I just felt it easier to reopen with a new branch. I think everything in here should be (hopefully) straightforward :)

@inducer inducer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I think we're converging on an interface that makes sense. Some thoughts on that below.

Comment thread logpyle/__init__.py
Comment on lines +144 to +148
def set_value(self, value: Any) -> None:
"""Set the logged quantity value."""
raise NotImplementedError(
f"set_value not implemented for log quantity {self.name}."
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread logpyle/__init__.py
"""

def add_internal(name, unit, description, def_agg):
def add_internal(name, unit, description, def_agg, set_value=None):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we're standardizing set_value in PushLogQuantity, I'm no longer sold on the value of passing in set_value.

Comment thread logpyle/__init__.py


class PushLogQuantity(LogQuantity):
"""A loggable scalar whose value can be updated.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread logpyle/__init__.py


def set_quantity_value(mgr: LogManager, name: str, value: Any) -> None:
"""Set a the value of a named LogQuantity.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should narrow this to erroring if that quantity is not a push quantity.

@inducer

inducer commented Sep 26, 2021

Copy link
Copy Markdown
Collaborator

Unsubscribing... @-mention or request review once it's ready for a look or needs attention.

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

Successfully merging this pull request may close these issues.

3 participants