-
Notifications
You must be signed in to change notification settings - Fork 87
Redis obj #1228
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
base: main
Are you sure you want to change the base?
Redis obj #1228
Conversation
Co-authored-by: Letizia Sammut <[email protected]> Co-authored-by: Stephen Mudie <[email protected]>
Conflict was on imports in __init__.py, removed (optional) import of redis signal for now.
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.
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- setup.cfg: Language not supported
| # 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 {} |
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.
| # 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.
| else: | ||
| return {} | ||
|
|
||
| def subscribe(self, *args, **kwargs): |
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 should probably only work on SUB_VALUE ?
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 also needs to thread the user's callback through so the users code gets called when the values update.
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.