googleapis/python-automl

samples.beta.delete_model_test: test_delete_model failed

flaky-bot opened this issue · 0 comments

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: 788a1b3
buildURL: Build Status, Sponge
status: failed

Test output
args = (name: "projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000"
,)
kwargs = {'metadata': [('x-goog-request-params', 'name=projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]}
@six.wraps(callable_)
def error_remapped_callable(*args, **kwargs):
    try:
      return callable_(*args, **kwargs)

.nox/py-3-8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py:67:


self = <grpc._channel._UnaryUnaryMultiCallable object at 0x7fceebb9d370>
request = name: "projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000"

timeout = None
metadata = [('x-goog-request-params', 'name=projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]
credentials = None, wait_for_ready = None, compression = None

def __call__(self,
             request,
             timeout=None,
             metadata=None,
             credentials=None,
             wait_for_ready=None,
             compression=None):
    state, call, = self._blocking(request, timeout, metadata, credentials,
                                  wait_for_ready, compression)
  return _end_unary_response_blocking(state, call, False, None)

.nox/py-3-8/lib/python3.8/site-packages/grpc/_channel.py:946:


state = <grpc._channel._RPCState object at 0x7fceebb97760>
call = <grpc._cython.cygrpc.SegregatedCall object at 0x7fceebb757c0>
with_call = False, deadline = None

def _end_unary_response_blocking(state, call, with_call, deadline):
    if state.code is grpc.StatusCode.OK:
        if with_call:
            rendezvous = _MultiThreadedRendezvous(state, call, None, deadline)
            return state.response, rendezvous
        else:
            return state.response
    else:
      raise _InactiveRpcError(state)

E grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
E status = StatusCode.UNAUTHENTICATED
E details = "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."
E debug_error_string = "{"created":"@1626174365.099298971","description":"Error received from peer ipv4:74.125.142.95:443","file":"src/core/lib/surface/call.cc","file_line":1066,"grpc_message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","grpc_status":16}"
E >

.nox/py-3-8/lib/python3.8/site-packages/grpc/_channel.py:849: _InactiveRpcError

The above exception was the direct cause of the following exception:

capsys = <_pytest.capture.CaptureFixture object at 0x7fceebda2f40>

def test_delete_model(capsys):
    # As model creation can take many hours, instead try to delete a
    # nonexistent model and confirm that the model was not found, but other
    # elements of the request were valid.
    try:
      delete_model.delete_model(PROJECT_ID, "VCN0000000000000000000")

delete_model_test.py:27:


project_id = 'cdpe-automl-tests', model_id = 'VCN0000000000000000000'

def delete_model(project_id, model_id):
    """Delete a model."""
    # [START automl_delete_model_beta]
    from google.cloud import automl_v1beta1 as automl

    # TODO(developer): Uncomment and set the following variables
    # project_id = "YOUR_PROJECT_ID"
    # model_id = "YOUR_MODEL_ID"

    client = automl.AutoMlClient()
    # Get the full path of the model.
    model_full_id = client.model_path(project_id, "us-central1", model_id)
  response = client.delete_model(name=model_full_id)

delete_model.py:28:


self = <google.cloud.automl_v1beta1.services.auto_ml.client.AutoMlClient object at 0x7fceebcf4c40>
request = name: "projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000"

def delete_model(
    self,
    request: service.DeleteModelRequest = None,
    *,
    name: str = None,
    retry: retries.Retry = gapic_v1.method.DEFAULT,
    timeout: float = None,
    metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
    r"""Deletes a model. Returns ``google.protobuf.Empty`` in the
    [response][google.longrunning.Operation.response] field when it
    completes, and ``delete_details`` in the
    [metadata][google.longrunning.Operation.metadata] field.

    Args:
        request (google.cloud.automl_v1beta1.types.DeleteModelRequest):
            The request object. Request message for
            [AutoMl.DeleteModel][google.cloud.automl.v1beta1.AutoMl.DeleteModel].
        name (str):
            Required. Resource name of the model
            being deleted.

            This corresponds to the ``name`` field
            on the ``request`` instance; if ``request`` is provided, this
            should not be set.
        retry (google.api_core.retry.Retry): Designation of what errors, if any,
            should be retried.
        timeout (float): The timeout for this request.
        metadata (Sequence[Tuple[str, str]]): Strings which should be
            sent along with the request as metadata.

    Returns:
        google.api_core.operation.Operation:
            An object representing a long-running operation.

            The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
               empty messages in your APIs. A typical example is to
               use it as the request or the response type of an API
               method. For instance:

                  service Foo {
                     rpc Bar(google.protobuf.Empty) returns
                     (google.protobuf.Empty);

                  }

               The JSON representation for Empty is empty JSON
               object {}.

    """
    # Create or coerce a protobuf request object.
    # Sanity check: If we got a request object, we should *not* have
    # gotten any keyword arguments that map to the request.
    has_flattened_params = any([name])
    if request is not None and has_flattened_params:
        raise ValueError(
            "If the `request` argument is set, then none of "
            "the individual field arguments should be set."
        )

    # Minor optimization to avoid making a copy if the user passes
    # in a service.DeleteModelRequest.
    # There's no risk of modifying the input as we've already verified
    # there are no flattened fields.
    if not isinstance(request, service.DeleteModelRequest):
        request = service.DeleteModelRequest(request)
        # If we have keyword arguments corresponding to fields on the
        # request, apply these.
        if name is not None:
            request.name = name

    # Wrap the RPC method; this adds retry and timeout information,
    # and friendly error handling.
    rpc = self._transport._wrapped_methods[self._transport.delete_model]

    # Certain fields should be provided within the metadata header;
    # add these here.
    metadata = tuple(metadata) + (
        gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
    )

    # Send the request.
  response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

../../google/cloud/automl_v1beta1/services/auto_ml/client.py:1970:


self = <google.api_core.gapic_v1.method.GapicCallable object at 0x7fceebb9d2b0>
args = (name: "projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000"
,)
kwargs = {'metadata': [('x-goog-request-params', 'name=projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]}
timeout
= None, retry = <google.api_core.retry.Retry object at 0x7fceebb9d310>
wrapped_func = <function _wrap_unary_errors..error_remapped_callable at 0x7fceebb8fca0>
metadata = [('x-goog-request-params', 'name=projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]

def __call__(self, *args, **kwargs):
    """Invoke the low-level RPC with retry, timeout, and metadata."""
    # Note: Due to Python 2 lacking keyword-only arguments we use kwargs to
    # extract the retry and timeout params.
    timeout_ = _determine_timeout(
        self._timeout,
        kwargs.pop("timeout", self._timeout),
        # Use only the invocation-specified retry only for this, as we only
        # want to adjust the timeout deadline if the *user* specified
        # a different retry.
        kwargs.get("retry", None),
    )

    retry = kwargs.pop("retry", self._retry)

    if retry is DEFAULT:
        retry = self._retry

    # Apply all applicable decorators.
    wrapped_func = _apply_decorators(self._target, [retry, timeout_])

    # Add the user agent metadata to the call.
    if self._metadata is not None:
        metadata = kwargs.get("metadata", [])
        # Due to the nature of invocation, None should be treated the same
        # as not specified.
        if metadata is None:
            metadata = []
        metadata = list(metadata)
        metadata.extend(self._metadata)
        kwargs["metadata"] = metadata
  return wrapped_func(*args, **kwargs)

.nox/py-3-8/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py:145:


args = (name: "projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000"
,)
kwargs = {'metadata': [('x-goog-request-params', 'name=projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]}
target = functools.partial(<function _wrap_unary_errors..error_remapped_callable at 0x7fceebb90a60>, name: "projects/cd...central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')])
sleep_generator = <generator object exponential_sleep_generator at 0x7fceebda87b0>

@general_helpers.wraps(func)
def retry_wrapped_func(*args, **kwargs):
    """A wrapper that calls target function with retry."""
    target = functools.partial(func, *args, **kwargs)
    sleep_generator = exponential_sleep_generator(
        self._initial, self._maximum, multiplier=self._multiplier
    )
  return retry_target(
        target,
        self._predicate,
        sleep_generator,
        self._deadline,
        on_error=on_error,
    )

.nox/py-3-8/lib/python3.8/site-packages/google/api_core/retry.py:285:


target = functools.partial(<function _wrap_unary_errors..error_remapped_callable at 0x7fceebb90a60>, name: "projects/cd...central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')])
predicate = <function if_exception_type..if_exception_type_predicate at 0x7fceebb909d0>
sleep_generator = <generator object exponential_sleep_generator at 0x7fceebda87b0>
deadline = 5.0, on_error = None

def retry_target(target, predicate, sleep_generator, deadline, on_error=None):
    """Call a function and retry if it fails.

    This is the lowest-level retry helper. Generally, you'll use the
    higher-level retry helper :class:`Retry`.

    Args:
        target(Callable): The function to call and retry. This must be a
            nullary function - apply arguments with `functools.partial`.
        predicate (Callable[Exception]): A callable used to determine if an
            exception raised by the target should be considered retryable.
            It should return True to retry or False otherwise.
        sleep_generator (Iterable[float]): An infinite iterator that determines
            how long to sleep between retries.
        deadline (float): How long to keep retrying the target. The last sleep
            period is shortened as necessary, so that the last retry runs at
            ``deadline`` (and not considerably beyond it).
        on_error (Callable[Exception]): A function to call while processing a
            retryable exception.  Any error raised by this function will *not*
            be caught.

    Returns:
        Any: the return value of the target function.

    Raises:
        google.api_core.RetryError: If the deadline is exceeded while retrying.
        ValueError: If the sleep generator stops yielding values.
        Exception: If the target raises a method that isn't retryable.
    """
    if deadline is not None:
        deadline_datetime = datetime_helpers.utcnow() + datetime.timedelta(
            seconds=deadline
        )
    else:
        deadline_datetime = None

    last_exc = None

    for sleep in sleep_generator:
        try:
          return target()

.nox/py-3-8/lib/python3.8/site-packages/google/api_core/retry.py:188:


args = (name: "projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000"
,)
kwargs = {'metadata': [('x-goog-request-params', 'name=projects/cdpe-automl-tests/locations/us-central1/models/VCN0000000000000000000'), ('x-goog-api-client', 'gl-python/3.8.8 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]}

@six.wraps(callable_)
def error_remapped_callable(*args, **kwargs):
    try:
        return callable_(*args, **kwargs)
    except grpc.RpcError as exc:
      six.raise_from(exceptions.from_grpc_error(exc), exc)

.nox/py-3-8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py:69:


value = None
from_value = <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAUTHENTICATED
details = "Request had invalid a...entication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","grpc_status":16}"

???
E google.api_core.exceptions.Unauthenticated: 401 Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

:3: Unauthenticated

During handling of the above exception, another exception occurred:

capsys = <_pytest.capture.CaptureFixture object at 0x7fceebda2f40>

def test_delete_model(capsys):
    # As model creation can take many hours, instead try to delete a
    # nonexistent model and confirm that the model was not found, but other
    # elements of the request were valid.
    try:
        delete_model.delete_model(PROJECT_ID, "VCN0000000000000000000")
        out, _ = capsys.readouterr()
        assert "The model does not exist" in out
    except Exception as e:
      assert "The model does not exist" in e.message

E AssertionError: assert 'The model does not exist' in 'Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.'
E + where 'Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.' = Unauthenticated('Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.').message

delete_model_test.py:31: AssertionError