Redis obj#1228
Open
tacaswell wants to merge 9 commits into
Open
Conversation
Co-authored-by: Letizia Sammut <letizias@ansto.gov.au> Co-authored-by: Stephen Mudie <stephenm@ansto.gov.au>
Conflict was on imports in __init__.py, removed (optional) import of redis signal for now.
tacaswell
commented
Sep 4, 2025
Comment on lines
+262
to
+306
| # class StructuredRedisSignal(RedisSignal): | ||
| # def __init__(self, channel, *, schema, **kwargs): | ||
| # super().__init__(channel, **kwargs) | ||
| # # TODO do more with schema! | ||
| # self._allowed_keys = set(schema) | ||
|
|
||
| # def set(self, **kwargs): | ||
| # # TODO also check types etc | ||
| # if set(kwargs) - self._allowed_keys: | ||
| # raise ValueError("not allowed keys") | ||
| # # TODO use a pipeline here so we can use watch! | ||
| # try: | ||
| # reading = self.read() | ||
| # except NoKey: | ||
| # current = {} | ||
| # else: | ||
| # current = {k[len(self.name) + 1 :]: v for k, v in reading.items()} | ||
|
|
||
| # ts = time.time() | ||
|
|
||
| # current.update({k: {"value": v, "timestamp": ts} for k, v in kwargs.items()}) | ||
|
|
||
| # st = Status(self) | ||
| # self._r.set( | ||
| # self._channel, self._serializer({"payload": current}), | ||
| # ) | ||
| # st.set_finished() | ||
| # return st | ||
|
|
||
| # def read(self): | ||
| # v = self._r.get(self._channel) | ||
| # if v is None: | ||
| # raise NoKey | ||
|
|
||
| # return { | ||
| # f"{self.name}_{k}": v for k, v in self._deserializer(v)["payload"].items() | ||
| # } | ||
|
|
||
| # @property | ||
| # def hints(self): | ||
| # # TODO sort out controlling internal kind state | ||
| # if self.kind == Kind.hinted: | ||
| # return {"fields": [f"{self.name}_{k}" for k in self._allowed_keys]} | ||
| # else: | ||
| # return {} |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| # class StructuredRedisSignal(RedisSignal): | |
| # def __init__(self, channel, *, schema, **kwargs): | |
| # super().__init__(channel, **kwargs) | |
| # # TODO do more with schema! | |
| # self._allowed_keys = set(schema) | |
| # def set(self, **kwargs): | |
| # # TODO also check types etc | |
| # if set(kwargs) - self._allowed_keys: | |
| # raise ValueError("not allowed keys") | |
| # # TODO use a pipeline here so we can use watch! | |
| # try: | |
| # reading = self.read() | |
| # except NoKey: | |
| # current = {} | |
| # else: | |
| # current = {k[len(self.name) + 1 :]: v for k, v in reading.items()} | |
| # ts = time.time() | |
| # current.update({k: {"value": v, "timestamp": ts} for k, v in kwargs.items()}) | |
| # st = Status(self) | |
| # self._r.set( | |
| # self._channel, self._serializer({"payload": current}), | |
| # ) | |
| # st.set_finished() | |
| # return st | |
| # def read(self): | |
| # v = self._r.get(self._channel) | |
| # if v is None: | |
| # raise NoKey | |
| # return { | |
| # f"{self.name}_{k}": v for k, v in self._deserializer(v)["payload"].items() | |
| # } | |
| # @property | |
| # def hints(self): | |
| # # TODO sort out controlling internal kind state | |
| # if self.kind == Kind.hinted: | |
| # return {"fields": [f"{self.name}_{k}" for k in self._allowed_keys]} | |
| # else: | |
| # return {} |
If we want to keep this around we should either create an issue with this as a comment or open a (draft) PR. We do not want to ship big blocks of commented out code in the libarry.
tacaswell
commented
Sep 4, 2025
| else: | ||
| return {} | ||
|
|
||
| def subscribe(self, *args, **kwargs): |
Contributor
Author
There was a problem hiding this comment.
This should probably only work on SUB_VALUE ?
Contributor
Author
There was a problem hiding this comment.
This also needs to thread the user's callback through so the users code gets called when the values update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a rebase of #904 but because that was opened from the master branch of the source repo I do not seem to be allowed to push to it.