Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

samples.snippets.create_document_test: test_create_document failed #256

Closed
flaky-bot bot opened this issue Feb 27, 2021 · 8 comments
Closed

samples.snippets.create_document_test: test_create_document failed #256

flaky-bot bot opened this issue Feb 27, 2021 · 8 comments
Assignees
Labels
flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@flaky-bot
Copy link

flaky-bot bot commented Feb 27, 2021

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: 230bb4e
buildURL: Build Status, Sponge
status: failed

Test output
capsys = <_pytest.capture.CaptureFixture object at 0x7f5b1220ab38>
@pytest.mark.flaky(max_runs=3, min_passes=1)
def test_create_document(capsys):
    document_management.create_document(
        PROJECT_ID, pytest.KNOWLEDGE_BASE_ID, DOCUMENT_DISPLAY_NAME,
      'text/html', 'FAQ', 'https://cloud.google.com/storage/docs/faq')

create_document_test.py:57:


document_management.py:59: in create_document
getattr(dialogflow.Document.KnowledgeType, knowledge_type)
/usr/local/lib/python3.6/_collections_abc.py:971: in append
self.insert(len(self), value)
.nox/py-3-6/lib/python3.6/site-packages/proto/marshal/collections/repeated.py:177: in insert
pb_value = self._marshal.to_proto(self._pb_type, value, strict=True)


self = <proto.marshal.marshal.Marshal object at 0x7f5b14c5ce48>
proto_type = <enum 'KnowledgeType'>, value = <KnowledgeType.FAQ: 1>

def to_proto(self, proto_type, value, *, strict: bool = False):
    # The protos in google/protobuf/struct.proto are exceptional cases,
    # because they can and should represent themselves as lists and dicts.
    # These cases are handled in their rule classes.
    if proto_type not in (
        struct_pb2.Value,
        struct_pb2.ListValue,
        struct_pb2.Struct,
    ):
        # For our repeated and map view objects, simply return the
        # underlying pb.
        if isinstance(value, (Repeated, MapComposite)):
            return value.pb

        # Convert lists and tuples recursively.
        if isinstance(value, (list, tuple)):
            return type(value)(self.to_proto(proto_type, i) for i in value)

    # Convert dictionaries recursively when the proto type is a map.
    # This is slightly more complicated than converting a list or tuple
    # because we have to step through the magic that protocol buffers does.
    #
    # Essentially, a type of map<string, Foo> will show up here as
    # a FoosEntry with a `key` field, `value` field, and a `map_entry`
    # annotation. We need to do the conversion based on the `value`
    # field's type.
    if isinstance(value, dict) and (
        proto_type.DESCRIPTOR.has_options
        and proto_type.DESCRIPTOR.GetOptions().map_entry
    ):
        recursive_type = type(proto_type().value)
        return {k: self.to_proto(recursive_type, v) for k, v in value.items()}

    # Convert ordinary values.
    rule = self._rules.get(proto_type, self._noop)
    pb_value = rule.to_proto(value)

    # Sanity check: If we are in strict mode, did we get the value we want?
    if strict and not isinstance(pb_value, proto_type):
        raise TypeError(
            "Parameter must be instance of the same class; "
            "expected {expected}, got {got}".format(
              expected=proto_type.__name__, got=pb_value.__class__.__name__,
            ),
        )

E TypeError: Parameter must be instance of the same class; expected KnowledgeType, got int

.nox/py-3-6/lib/python3.6/site-packages/proto/marshal/marshal.py:215: TypeError

@flaky-bot flaky-bot bot added flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 27, 2021
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Feb 27, 2021
@flaky-bot
Copy link
Author

flaky-bot bot commented Mar 2, 2021

commit: a2b7db9
buildURL: Build Status, Sponge
status: failed

Test output
capsys = <_pytest.capture.CaptureFixture object at 0x7fa34003bb38>
@pytest.mark.flaky(max_runs=3, min_passes=1)
def test_create_document(capsys):
    document_management.create_document(
        PROJECT_ID, pytest.KNOWLEDGE_BASE_ID, DOCUMENT_DISPLAY_NAME,
      'text/html', 'FAQ', 'https://cloud.google.com/storage/docs/faq')

create_document_test.py:57:


document_management.py:59: in create_document
getattr(dialogflow.Document.KnowledgeType, knowledge_type)
/usr/local/lib/python3.6/_collections_abc.py:971: in append
self.insert(len(self), value)
.nox/py-3-6/lib/python3.6/site-packages/proto/marshal/collections/repeated.py:177: in insert
pb_value = self._marshal.to_proto(self._pb_type, value, strict=True)


self = <proto.marshal.marshal.Marshal object at 0x7fa34245ee48>
proto_type = <enum 'KnowledgeType'>, value = <KnowledgeType.FAQ: 1>

def to_proto(self, proto_type, value, *, strict: bool = False):
    # The protos in google/protobuf/struct.proto are exceptional cases,
    # because they can and should represent themselves as lists and dicts.
    # These cases are handled in their rule classes.
    if proto_type not in (
        struct_pb2.Value,
        struct_pb2.ListValue,
        struct_pb2.Struct,
    ):
        # For our repeated and map view objects, simply return the
        # underlying pb.
        if isinstance(value, (Repeated, MapComposite)):
            return value.pb

        # Convert lists and tuples recursively.
        if isinstance(value, (list, tuple)):
            return type(value)(self.to_proto(proto_type, i) for i in value)

    # Convert dictionaries recursively when the proto type is a map.
    # This is slightly more complicated than converting a list or tuple
    # because we have to step through the magic that protocol buffers does.
    #
    # Essentially, a type of map<string, Foo> will show up here as
    # a FoosEntry with a `key` field, `value` field, and a `map_entry`
    # annotation. We need to do the conversion based on the `value`
    # field's type.
    if isinstance(value, dict) and (
        proto_type.DESCRIPTOR.has_options
        and proto_type.DESCRIPTOR.GetOptions().map_entry
    ):
        recursive_type = type(proto_type().value)
        return {k: self.to_proto(recursive_type, v) for k, v in value.items()}

    # Convert ordinary values.
    rule = self._rules.get(proto_type, self._noop)
    pb_value = rule.to_proto(value)

    # Sanity check: If we are in strict mode, did we get the value we want?
    if strict and not isinstance(pb_value, proto_type):
        raise TypeError(
            "Parameter must be instance of the same class; "
            "expected {expected}, got {got}".format(
              expected=proto_type.__name__, got=pb_value.__class__.__name__,
            ),
        )

E TypeError: Parameter must be instance of the same class; expected KnowledgeType, got int

.nox/py-3-6/lib/python3.6/site-packages/proto/marshal/marshal.py:215: TypeError

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Mar 6, 2021
@tmatsuo
Copy link
Contributor

tmatsuo commented Mar 9, 2021

The error is:
TypeError: Parameter must be instance of the same class; expected KnowledgeType, got int

I suspect it happens when flaky retries the test.

@tmatsuo tmatsuo self-assigned this Mar 9, 2021
@tmatsuo
Copy link
Contributor

tmatsuo commented Mar 10, 2021

I was wrong. The test is constantly failing.

@busunkim96 Do you know anything about this?
The failing code is:

    from google.cloud import dialogflow_v2beta1 as dialogflow
    document = dialogflow.Document(
        display_name=display_name, mime_type=mime_type, content_uri=content_uri
    )

    document.knowledge_types.append(
        getattr(dialogflow.Document.KnowledgeType, knowledge_type)
    )

@tmatsuo
Copy link
Contributor

tmatsuo commented Mar 10, 2021

It started to fail Feb 27

@busunkim96
Copy link
Contributor

@tmatsuo Yes, it's a bug in proto-plus: googleapis/proto-plus-python#201. It was fixed and technically released in 1.14.3 https://github.com/googleapis/proto-plus-python/blob/master/CHANGELOG.md#1143-2021-03-04, but the publishing CI on that repo is broken. I pinged @software-dov earlier today about pushing the release to PyPI.

@tmatsuo
Copy link
Contributor

tmatsuo commented Mar 10, 2021

@busunkim96 Thanks! Then there's no action item on this repo. Downgrading.

@tmatsuo tmatsuo added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed 🚨 This issue needs some love. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Mar 10, 2021
@flaky-bot
Copy link
Author

flaky-bot bot commented Mar 10, 2021

commit: 311615f
buildURL: Build Status, Sponge
status: failed

Test output
capsys = <_pytest.capture.CaptureFixture object at 0x7fb980740128>
@pytest.mark.flaky(max_runs=3, min_passes=1)
def test_create_document(capsys):
    document_management.create_document(
        PROJECT_ID, pytest.KNOWLEDGE_BASE_ID, DOCUMENT_DISPLAY_NAME,
      'text/html', 'FAQ', 'https://cloud.google.com/storage/docs/faq')

create_document_test.py:57:


document_management.py:59: in create_document
getattr(dialogflow.Document.KnowledgeType, knowledge_type)
/usr/local/lib/python3.6/_collections_abc.py:971: in append
self.insert(len(self), value)
.nox/py-3-6/lib/python3.6/site-packages/proto/marshal/collections/repeated.py:177: in insert
pb_value = self._marshal.to_proto(self._pb_type, value, strict=True)


self = <proto.marshal.marshal.Marshal object at 0x7fb981b5f198>
proto_type = <enum 'KnowledgeType'>, value = <KnowledgeType.FAQ: 1>

def to_proto(self, proto_type, value, *, strict: bool = False):
    # The protos in google/protobuf/struct.proto are exceptional cases,
    # because they can and should represent themselves as lists and dicts.
    # These cases are handled in their rule classes.
    if proto_type not in (
        struct_pb2.Value,
        struct_pb2.ListValue,
        struct_pb2.Struct,
    ):
        # For our repeated and map view objects, simply return the
        # underlying pb.
        if isinstance(value, (Repeated, MapComposite)):
            return value.pb

        # Convert lists and tuples recursively.
        if isinstance(value, (list, tuple)):
            return type(value)(self.to_proto(proto_type, i) for i in value)

    # Convert dictionaries recursively when the proto type is a map.
    # This is slightly more complicated than converting a list or tuple
    # because we have to step through the magic that protocol buffers does.
    #
    # Essentially, a type of map<string, Foo> will show up here as
    # a FoosEntry with a `key` field, `value` field, and a `map_entry`
    # annotation. We need to do the conversion based on the `value`
    # field's type.
    if isinstance(value, dict) and (
        proto_type.DESCRIPTOR.has_options
        and proto_type.DESCRIPTOR.GetOptions().map_entry
    ):
        recursive_type = type(proto_type().value)
        return {k: self.to_proto(recursive_type, v) for k, v in value.items()}

    # Convert ordinary values.
    rule = self._rules.get(proto_type, self._noop)
    pb_value = rule.to_proto(value)

    # Sanity check: If we are in strict mode, did we get the value we want?
    if strict and not isinstance(pb_value, proto_type):
        raise TypeError(
            "Parameter must be instance of the same class; "
            "expected {expected}, got {got}".format(
              expected=proto_type.__name__, got=pb_value.__class__.__name__,
            ),
        )

E TypeError: Parameter must be instance of the same class; expected KnowledgeType, got int

.nox/py-3-6/lib/python3.6/site-packages/proto/marshal/marshal.py:215: TypeError

@flaky-bot
Copy link
Author

flaky-bot bot commented Mar 11, 2021

Test passed for commit 4717cb2 (Build Status, Sponge)! Closing this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
flakybot: issue An issue filed by the Flaky Bot. Should not be added manually. priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants