-
Notifications
You must be signed in to change notification settings - Fork 82
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
Search attributes #43
Conversation
# Conflicts: # tests/worker/test_workflow.py
# Conflicts: # .github/workflows/ci.yml # README.md # temporalio/worker/workflow.py # temporalio/workflow.py # tests/worker/test_workflow.py
) -> None: | ||
"""Encode search attributes as bridge payloads.""" | ||
for k, vals in attrs.items(): | ||
payloads[k].CopyFrom( |
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.
Does this create the key k
if it doesn't exist?
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.
Or do you always make sure it exists before sending to this method?
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 is a Protobuf oddity. They lazily create everything on first scalar (i.e. non-message) update. See https://developers.google.com/protocol-buffers/docs/reference/python-generated#map-fields. If I tried to do payloads[k] = some_message
, I'd get an error because no Python Protobuf code allows assignment to a message.
raise TypeError("Search attribute values must be lists") | ||
# Convert dates to strings | ||
safe_vals = [] | ||
for v in vals: |
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.
You should assert that vals is a homogenous list
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.
Could also limit this at the type level.
We should have done the same in TS @lorensr (still not too late).
type SearchAttributeValueArray = string[] | number[] | boolean[] | Date[];
type SearchAttributes = Record<string, SearchAttributeVAlueArray>;
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.
Sounds good, will do.
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.
Makes sense, will do
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.
I am afraid that Union[List[str], List[int], List[float], List[bool], List[datetime]]
doesn't work as we'd like. You can't assign an empty list to it for example (this is a known MyPy and Python typing issue, see issue 3283 in https://github.com/python/mypy). We're gonna have to keep the types as is and only do runtime checks.
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.
You should decode the SAs in the wrapped describe
response, I didn't see that.
@bergundy - I think we need more details on what should be in the describe response. Right now I don't surface anything but the status and the raw gRPC message (so they can decode if they want). Why did TypeScript make |
Don't really see a reason why not same for |
What was changed
Checklist