Idiom for partial failures

2020-02-20 Thread David Wihl

(first post)

I'm working on the Python client library [0]for the Google Ads API [1]. In some 
cases, we can start a request with a partial failure [2] flag = True. This 
means that the request may contain say 1000 operations. If any of the 
operations fail, the request will return with a success status without an 
exception. Then the developer has to iterate through the list of operation 
return statuses to determine which specific ones failed (example [3]).

I believe that it would be more idiomatic in Python (and other languages like 
Ruby) to throw an exception when one of these partial errors occur. That way 
there would be the same control flow if a major or minor error occurred. 

The team is asking me for other examples or justification of this being 
idiomatic of Python. Can you recommend any examples or related best practices?

[0] https://github.com/googleads/google-ads-python

[1] https://developers.google.com/google-ads/api/docs/start

[2] 
https://developers.google.com/google-ads/api/docs/best-practices/partial-failures

[3] 
https://github.com/googleads/google-ads-python/blob/master/examples/error_handling/handle_partial_failure.py

Thanks!
-David
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Idiom for partial failures

2020-02-21 Thread David Wihl
Yes, the API has to support partial failures across all six supported
languages. Not all operations need to be atomic and there is considerable
efficiency in having multiple operations sent in a single request. Thanks,
-David

On Thu, Feb 20, 2020 at 6:07 PM Rob Gaddi 
wrote:

> On 2/20/20 9:30 AM, David Wihl wrote:
> > 
> > (first post)
> >
> > I'm working on the Python client library [0]for the Google Ads API [1].
> In some cases, we can start a request with a partial failure [2] flag =
> True. This means that the request may contain say 1000 operations. If any
> of the operations fail, the request will return with a success status
> without an exception. Then the developer has to iterate through the list of
> operation return statuses to determine which specific ones failed (example
> [3]).
> >
> > I believe that it would be more idiomatic in Python (and other languages
> like Ruby) to throw an exception when one of these partial errors occur.
> That way there would be the same control flow if a major or minor error
> occurred.
> >
> > The team is asking me for other examples or justification of this being
> idiomatic of Python. Can you recommend any examples or related best
> practices?
> >
> > [0] https://github.com/googleads/google-ads-python
> >
> > [1] https://developers.google.com/google-ads/api/docs/start
> >
> > [2]
> https://developers.google.com/google-ads/api/docs/best-practices/partial-failures
> >
> > [3]
> https://github.com/googleads/google-ads-python/blob/master/examples/error_handling/handle_partial_failure.py
> >
> > Thanks!
> > -David
> >
>
> Potentially stupid question, does your library to the API have to support
> partial failures?  Sure Google Ads does, but does it really add value to
> do so?
> And then you've got to decide what to DO with those partially failed
> results.
>
> You could, as a library, just say "No, this library never sets the
> partial_failure field.  We only support atomic transactions that fully
> succeed
> or fully fail and raise an exception."  Makes your life a lot easier; so
> unless
> it makes your customer's lives a lot harder...
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list