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

AutoML: add a get_operation_status method to clients #7

Closed
crwilcox opened this issue Jul 19, 2018 · 3 comments
Closed

AutoML: add a get_operation_status method to clients #7

crwilcox opened this issue Jul 19, 2018 · 3 comments
Labels
api: automl Issues related to the googleapis/python-automl API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@crwilcox
Copy link
Contributor

in GoogleCloudPlatform/python-docs-samples#1575 (comment) I noticed one of our samples is relying on an internal method client.transport._operations_client.get_operation(.

@sirtorry said it is common for training jobs to take long periods of time and having a way of checking on the status is useful.

I believe we should consider exposing a method, perhaps one of the following.

response = client.create_model(project_location, my_model)
response.get_status()

or

operation_name = response.operation.name
client.get_operation_status(operation_name)

It also seems operation.refresh() will do the same thing. Perhaps there is a way to do this currently without adding this functionality?


class Operation(polling.PollingFuture):
    """A Future for interacting with a Google API Long-Running Operation.

    Args:
        operation (google.longrunning.operations_pb2.Operation): The
            initial operation.
        refresh (Callable[[], ~.api_core.operation.Operation]): A callable that
            returns the latest state of the operation.
        cancel (Callable[[], None]): A callable that tries to cancel
            the operation.
        result_type (func:`type`): The protobuf type for the operation's
            result.
        metadata_type (func:`type`): The protobuf type for the operation's
            metadata.
        retry (google.api_core.retry.Retry): The retry configuration used
            when polling. This can be used to control how often :meth:`done`
            is polled. Regardless of the retry's ``deadline``, it will be
            overridden by the ``timeout`` argument to :meth:`result`.
    """
@crwilcox
Copy link
Contributor Author

cc @sirtorry

@crwilcox
Copy link
Contributor Author

Currently you have to do the following. If we add a method for get_operation this simplifies greatly. It enables getting status and cancelling operations.

import google.api_core.operation
import google.api_core.operations_v1
from google.longrunning import operations_pb2

operations_client = operations_v1.OperationsClient(
    channel=automl_client.channel)

operation = google.api_core.operation.Operation(
    operations_pb2.Operation(name=operation_id),
    operations_client,
    google.cloud.automl.types.Model)

operation.cancel()

@busunkim96 busunkim96 transferred this issue from googleapis/google-cloud-python Jan 31, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Jan 31, 2020
@busunkim96 busunkim96 added api: automl Issues related to the googleapis/python-automl API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Jan 31, 2020
@sirtorry sirtorry self-assigned this Feb 4, 2020
@sirtorry sirtorry removed their assignment Feb 19, 2020
@paul1319 paul1319 removed their assignment Oct 17, 2020
@munkhuushmgl
Copy link
Contributor

Feel free to reopen this,
Doesn't the following operation fulfill this requesT?

response = client._transport.operations_client.get_operation(operation_full_id)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: automl Issues related to the googleapis/python-automl API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

6 participants