Skip to content
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

NameError: name 'operation' is not defined #610

Closed
busunkim96 opened this issue Sep 22, 2020 · 6 comments
Closed

NameError: name 'operation' is not defined #610

busunkim96 opened this issue Sep 22, 2020 · 6 comments
Assignees
Labels
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.

Comments

@busunkim96
Copy link
Contributor

I'm seeing generated test fails on 0.33.4 for a new library google/cloud/aiplatform

The problem seems to be that google.api_core.operation is imported as ga_operation but the client references it as operation later on.

The API appears to have it's own operation type (from google.cloud.aiplatform_v1beta1.types import operation as gca_operation) which may be causing the conflict.

from collections import OrderedDict
from distutils import util
import os
import re
from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core import client_options as client_options_lib  # type: ignore
from google.api_core import exceptions                            # type: ignore
from google.api_core import gapic_v1                              # type: ignore
from google.api_core import retry as retries                      # type: ignore
from google.auth import credentials                               # type: ignore
from google.auth.transport import mtls                            # type: ignore
from google.auth.transport.grpc import SslCredentials             # type: ignore
from google.auth.exceptions import MutualTLSChannelError          # type: ignore
from google.oauth2 import service_account                         # type: ignore

from google.api_core import operation as ga_operation  # type: ignore
from google.api_core import operation_async  # type: ignore
from google.cloud.aiplatform_v1beta1.services.specialist_pool_service import pagers
from google.cloud.aiplatform_v1beta1.types import operation as gca_operation
from google.cloud.aiplatform_v1beta1.types import specialist_pool
from google.cloud.aiplatform_v1beta1.types import specialist_pool as gca_specialist_pool
from google.cloud.aiplatform_v1beta1.types import specialist_pool_service
from google.protobuf import empty_pb2 as empty  # type: ignore
from google.protobuf import field_mask_pb2 as field_mask  # type: ignore

from .transports.base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import SpecialistPoolServiceGrpcTransport
from .transports.grpc_asyncio import SpecialistPoolServiceGrpcAsyncIOTransport
        # Wrap the response in an operation future.
>       response = operation.from_gapic(
            response,
            self._transport.operations_client,
            gca_specialist_pool.SpecialistPool,
            metadata_type=specialist_pool_service.UpdateSpecialistPoolOperationMetadata,
        )
E       NameError: name 'operation' is not defined

google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py:745: NameError
@busunkim96 busunkim96 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 22, 2020
@danoscarmike danoscarmike added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 22, 2020
@danoscarmike
Copy link
Contributor

Bumping priority due to impact to product launch

@hkdevandla
Copy link
Member

Dov, can you please take a look? Thanks!

@software-dov
Copy link
Contributor

On it.

@busunkim96
Copy link
Contributor Author

👋 I had a chat with @dizcology and AI Platform will likely have to use an older version of this generator for the time being b/c of other concerns. It it is alright to drop the priority on this since they already have a synth replace fix they wrote for the alpha.

@software-dov
Copy link
Contributor

I've got a fix I'm just about to post review, but it looks like there are other unit tests that are failing too.

software-dov added a commit to software-dov/gapic-generator-python that referenced this issue Sep 22, 2020
Some APIs define their own module named 'operation' that naively
clashes with google.api_core.operation.
Both modules are imported with a disambiguating alias, but the alias
was not always referenced for the api_core submodule.

This change fixes that issue. Fix for googleapis#610
software-dov added a commit that referenced this issue Sep 22, 2020
Some APIs define their own module named 'operation' that naively
clashes with google.api_core.operation.
Both modules are imported with a disambiguating alias, but the alias
was not always referenced for the api_core submodule.

This change fixes that issue. Fix for #610
@software-dov
Copy link
Contributor

Fixed by #615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

4 participants