-
Notifications
You must be signed in to change notification settings - Fork 1.1k
verbosify cirq_type deprecation #5339
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
Conversation
"its _json_namespace_ method. Starting in v0.15, custom 'cirq_type' values " | ||
"will trigger an error." | ||
"\n\n" | ||
"To fix this, remove 'cirq_type' from the class _json_dict_ method. Classes " |
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.
Should we also mention that serialized objects will continue to be the same as previously serialized objects? I think cirq_type will persist as a field in JSON-serialized objects
was not a 100% clear.
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.
Emphasized this in the preceding paragraph. FWIW, this only preserves serialization format if a class follows the [namespace.]classname
convention, but we've been exceedingly consistent about applying that convention in Cirq. Hopefully that translates to external users doing the same.
@Strilanc, I'd still like your confirmation on this before merging, since you were the one affected by the previous wording here. |
Shouldn't 'how to fix this' vary depending on whether the manually assigned value agrees with the automatically assigned value or not? If I was using a custom cirq_type value, how would I override the automatic behavior? How would I guarantee cross-compatibility across versions with/without this deprecation? |
Okay, I think I hit the points raised above.
You can't - the point of this change was to enforce consistency in
As described in #5337, you'd need to include both LMK if there's anything else you'd like to see covered here. |
"define _json_namespace_ for the class." | ||
"\n\n" | ||
"For backwards compatibility, classes whose old 'cirq_type' does not match the " | ||
"new value must appear in `json_resolver_cache.py::_class_resolver_dictionary()` " |
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 don't understand this instruction. My project does not have a json_resolver_cache.py
file. Is this a file within cirq? Say it is within cirq, and give the full file path not the name.
Also, this seems rather extreme to require someone who wrote a different library to make a change in cirq to maintaing compatibility across versions? It sounds like this is saying I can't maintain compatibility.
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.
Sorry, I misunderstood how Cirq handles third-party JSON resolvers. The appropriate thing to update for this is whatever custom resolver you are using, as described here. I'll update the instructions to match.
Fixes quantumlib#5337. More specifically, this message is intended to make it very clear that: 1. `cirq_type` will persist as a field in JSON-serialized objects 2. `cirq_type` is now auto-generated 3. Users should remove `cirq_type` from their `_json_dict_` methods 4. Classes outside Cirq should define `_json_namespace_` to avoid collisions
Fixes quantumlib#5337. More specifically, this message is intended to make it very clear that: 1. `cirq_type` will persist as a field in JSON-serialized objects 2. `cirq_type` is now auto-generated 3. Users should remove `cirq_type` from their `_json_dict_` methods 4. Classes outside Cirq should define `_json_namespace_` to avoid collisions
Fixes #5337.
More specifically, this message is intended to make it very clear that:
cirq_type
will persist as a field in JSON-serialized objectscirq_type
is now auto-generatedcirq_type
from their_json_dict_
methods_json_namespace_
to avoid collisions