question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Packaging Cirq 0.7 for Nix: serialization failures

See original GitHub issue

Hi all, #2727 is higher priority.

For https://github.com/NixOS/nixpkgs/pull/78779 I tried building Cirq tag 0.7.0, and got several test failures. Are these in the main tree or local to me? And any tips on resolving them? (note: this is after disabling the failures from #2727, which also appear here).

Failure 2 looks like same issue as #2727.

________________________ test_serialize_sympy_constants ________________________

    def test_serialize_sympy_constants():
        proto = _arg_to_proto(sympy.pi, arg_function_language='')
        packed = json_format.MessageToDict(proto,
                                           including_default_value_fields=True,
                                           preserving_proto_field_name=True,
                                           use_integers_for_enums=True)
>       assert packed == {'arg_value': {'float_value': float(np.float32(sympy.pi))}}
E       AssertionError: assert {'arg_value':...592653589793}} == {'arg_value':...927410125732}}
E         Differing items:
E         {'arg_value': {'float_value': 3.141592653589793}} != {'arg_value': {'float_value': 3.1415927410125732}}
E         Use -v to get the full diff

cirq/google/arg_func_langs_test.py:108: AssertionError
___________________ test_serialize_conversion[value1-proto1] ___________________

value = array([ True, False])
proto = {'arg_value': {'bool_values': {'values': [True, False]}}}

    @pytest.mark.parametrize('value,proto', [
        ((True, False), {
            'arg_value': {
                'bool_values': {
                    'values': [True, False]
                }
            }
        }),
        (np.array([True, False], dtype=np.bool), {
            'arg_value': {
                'bool_values': {
                    'values': [True, False]
                }
            }
        }),
    ])
    def test_serialize_conversion(value: ARG_LIKE, proto: v2.program_pb2.Arg):
        msg = v2.program_pb2.Arg()
        json_format.ParseDict(proto, msg)
        packed = json_format.MessageToDict(_arg_to_proto(value,
>                                                        arg_function_language=''),
                                           including_default_value_fields=True,
                                           preserving_proto_field_name=True,
                                           use_integers_for_enums=True)

cirq/google/arg_func_langs_test.py:138: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cirq/google/arg_func_langs.py:131: in _arg_to_proto
    msg.arg_value.bool_values.values.extend(value)
/nix/store/gajvrh1azp0vh6q531b695qrcak24zmq-python3.7-protobuf-3.7.1/lib/python3.7/site-packages/google/protobuf/internal/containers.py:279: in extend
    new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
/nix/store/gajvrh1azp0vh6q531b695qrcak24zmq-python3.7-protobuf-3.7.1/lib/python3.7/site-packages/google/protobuf/internal/containers.py:279: in <listcomp>
    new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <google.protobuf.internal.type_checkers.TypeCheckerWithDefault object at 0x7fffd76f45d0>
proposed_value = True

    def CheckValue(self, proposed_value):
      """Type check the provided value and return it.
    
      The returned value might have been normalized to another type.
      """
      if not isinstance(proposed_value, self._acceptable_types):
        message = ('%.1024r has type %s, but expected one of: %s' %
                   (proposed_value, type(proposed_value), self._acceptable_types))
>       raise TypeError(message)
E       TypeError: True has type <class 'numpy.bool_'>, but expected one of: ((<class 'bool'>, <class 'numbers.Integral'>),)

/nix/store/gajvrh1azp0vh6q531b695qrcak24zmq-python3.7-protobuf-3.7.1/lib/python3.7/site-packages/google/protobuf/internal/type_checkers.py:109: TypeError

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mpharrigancommented, Feb 11, 2020

I think they’re talking about protobuf 3.8

0reactions
drewrisingercommented, Sep 1, 2020

Yes, it looks like it’s been resolved. Likely due to Nixpkgs updating their protobuf version.

Relevant test config:

  • python 3.8
  • cirq==0.8.2
  • protobuf==3.13.0
  • numpy==1.19.1
  • networkx 2.4
Read more comments on GitHub >

github_iconTop Results From Across the Web

Serialization guidelines | Cirq - Google Quantum AI
This developer document explains how Cirq serializes objects into (and out of) JSON. It also explains how to add a new serializable object, ......
Read more >
Google Cirq Gate Throws Serialization Error #200 - GitHub
We wanted to be able to serialize and deserialize circuits to protocol buffer representations when passing them between our ops (C++ protocol ...
Read more >
Compare Packages Between Distributions - DistroWatch.com
Complete summaries of the openSUSE and CentOS projects are available. Note: In case where multiple versions of a package are shipped with a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found