Skip to content

Conversation

@tacaswell
Copy link
Contributor

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.

@jennmald jennmald requested a review from Copilot April 4, 2025 19:15
Copy link

Copilot AI left a 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

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 {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

else:
return {}

def subscribe(self, *args, **kwargs):
Copy link
Contributor Author

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 ?

Copy link
Contributor Author

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.

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