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
from_grpc fails with got an unexpected keyword argument 'retry' #87
Comments
Hi @rodis, Thanks for filing an issue.
|
hi @busunkim96
SCOPE = 'https://www.googleapis.com/auth/cloud-platform'
SERVICE_ENDPOINT = 'automl.googleapis.com'
def main():
creds = service_account.Credentials.from_service_account_file(CREDS_FILE)
scoped_credentials = creds.with_scopes([SCOPE])
request = google_auth_transport_requests.Request()
channel = google_auth_transport_grpc.secure_authorized_channel(
scoped_credentials, request, SERVICE_ENDPOINT)
stub = operations_pb2.OperationsStub(channel)
op = from_grpc(
operations_pb2.Operation(name=OPERATION),
stub,
Model
)
if op.done() == True:
sys.exit(0) |
Is there a specific reason you're constructing channels and operations manually? It's possible to use the client library to fetch operations: https://github.com/googleapis/python-automl/blob/v2.0.0/samples/snippets/get_operation_status.py def get_operation_status(operation_full_id):
"""Get operation status."""
# [START automl_get_operation_status]
from google.cloud import automl
# TODO(developer): Uncomment and set the following variables
# operation_full_id = \
# "projects/[projectId]/locations/us-central1/operations/[operationId]"
client = automl.AutoMlClient()
# Get the latest state of a long-running operation.
response = client._transport.operations_client.get_operation(
operation_full_id
)
print("Name: {}".format(response.name))
print("Operation details:")
print(response)
# [END automl_get_operation_status] |
Hi @busunkim96, thanks for your reply. |
That's a fair point. As for |
@busunkim96 Thank you. |
Hi @rodis, The next release of I think your assessment that |
A call to
from_grpc
fails withIt seems like it sets
_refresh_grpc
as self._refresh for the Operation object https://github.com/googleapis/python-api-core/blob/master/google/api_core/operation.py#L299 but when_refresh_and_update
is called bydone
, it gets and passes down to_refresh_grpc
aretry
param https://github.com/googleapis/python-api-core/blob/master/google/api_core/operation.py#L157 that_refresh_grpc
doesn't know how to handle https://github.com/googleapis/python-api-core/blob/master/google/api_core/operation.py#L251 causing the error above.It might be that the
retry
param could be correctly handled when the Operation object is created byfrom_gapic
because in that case self._refresh is set tooperations_client.get_operation
https://github.com/googleapis/python-api-core/blob/master/google/api_core/operation.py#L325 which might be aware of theretry
param but doesn't seem to be the case forfrom_grpc
andfrom_http_json
.The text was updated successfully, but these errors were encountered: