Skip to content

JSON serialization: namespaces for cirq_type #4377

Open
@mpharrigan

Description

@mpharrigan

Right now in cirq and all modules in the main cirq repo, the cirq_type field used in json serialization is the unqualified object name. This has not caused any naming collisions yet.

I had always imagined that different packages would have a namespaced cirq_type. For example: cirq_google.PhysicalZTag or cirq.google.PhysicalZTag instead of PhysicalZTag.

In fact, cirq.obj_to_dict_helper has an optional namespace argument. I tried to use this for a new cirq_google object, but the testing procedure uses the unqualified object name to assert that a data file should exist.

While playing around with #4375 I think it would be more robust to decouple the "object generation" from any semantic meaning. Instead, we generate all the example objects and keep track of the types we've successfully round-tripped. Afterwards we can check if there are public objects that weren't round-tripped.

Metadata

Metadata

Labels

area/jsonarea/serializationgood part-time projectA meaty non-urgent issue with a substantial amount of work to be done.kind/healthFor CI/testing/release process/refactoring/technical debt itemsno QC knowledge neededWant to contribute to Cirq, but don't know quantum computing? This issue is for you.priority/p2Next release should contain ittriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions