-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[cirqflow] Provide concrete ExecutableSpec #4559
Conversation
- writing serialization tests - could be usefull
@@ -197,7 +232,7 @@ def __str__(self) -> str: | |||
if len(self.executables) > 2: | |||
exe_str += ', ...' | |||
|
|||
return f'QuantumExecutable(executables=[{exe_str}])' |
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 was an unrelated bug I found while updating the tests
Lint failure is in an unrelated file |
@MichaelBroughton ptal |
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.
LGTM with a few minor nits.
with pytest.raises(TypeError, match='unhashable.*'): | ||
hash(KeyValueExecutableSpec(executable_family='', key_value_pairs=[('name', 'test')])) |
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.
Nit: Why have this check ?
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 want all these dataclasses to be immutable as possible. We use hashability as a proxy. If you pass a list of key value pairs instead of a tuple of key value pairs, it should raise an exception.
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.
hashing a list will always raise an exception. To me this feels like we're breaking the API requirements and then testing for the failures that emerge because of that, which doesn't seem like a great practice, but there's only one such instance so I'm easy either way.
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.
we do that all the time to hit our coverage requirements
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.
It's also not "hashing a list". It's hashing a class whose constructor has been provided a list. If we had a check like this for ParamResolver
we wouldn't have #4327 :)
@MichaelBroughton ; pushed fixes. PTAL if you want. Otherwise I'll merge this afternoon |
`ExecutableSpec` is a newly-introduced abstract class. The design was each application would subclass it for application-dependent data attributes. 1. Writing all the serialization tests is a nightmare without a full-fledged lives-in-Cirq concrete implementation of this 2. You could imagine users might want a lower-touch way to put together an executable using an untyped, implicit-schema version of the spec. Ergo: this PR introduces `KeyValueExecutableSpec` to address these two concerns.
ExecutableSpec
is a newly-introduced abstract class. The design was each application would subclass it for application-dependent data attributes.Ergo: this PR introduces
KeyValueExecutableSpec
to address these two concerns.