Idea #20613
closedReveal googleapiclient retry logs during client construction
Description
Until we have a totally sorted story for googleapiclient logs (#20521), we at least want users to be able to see retry logs while the client is being created, so if they, e.g., have a typo in their ARVADOS_API_HOST
, they'll see a message about that ASAP.
- Add a
APIClientLogFilter
to the Python SDK that emits retry messages at the info level. (The details of this filter may change later in #20521, but the API will remain the same.) - Update
arvados.api
constructor(s) to make sure these logs go somewhere on at least the first client instantiation.- Exact strategy TBD depending on whether logging objects are thread-safe, etc. It is acceptable if these logs only appear on the very first instantiation, but that limitation is not required either.
- Should at least install the filter and ensure
googleapiclient
logs have some handler, maybe carry one over fromarvados
if not.
- Remove the
googleapiclient
level-setting stuff from a-c-r. - Ensure
googleapiclient
logs appear during a-c-r's client instantiation.- The handler copy idea above might be sufficient. If not, this might need input from Peter about the best strategy.
Updated by Brett Smith over 1 year ago
- Related to Idea #20521: Python tools emit logs from googleapiclient added
Updated by Peter Amstutz over 1 year ago
- Related to Bug #20611: Creating api object hangs when inside crunch container added
Updated by Brett Smith over 1 year ago
20613-googleapiclient-init-logs @ d5749d0806f11da94e8ee3393b5166d4bba87198 - developer-run-tests: #3688
Brett Smith wrote:
- Exact strategy TBD depending on whether logging objects are thread-safe, etc. It is acceptable if these logs only appear on the very first instantiation, but that limitation is not required either.
Logging to them is thread-safe but you need your own locking if you want to manipulate handlers, filters, etc. from threads. Given this, I went with a single-use lock strategy.
- Remove the
googleapiclient
level-setting stuff from a-c-r.
Didn't remove it wholesale because it was doing some more subtle stuff I didn't appreciate but it has at least been updated to use the new tools.
Updated by Brett Smith over 1 year ago
Note 07ae0247ca233cd61d65dc600b8074c67291e3c0 with a brown paper bag fix.
Updated by Peter Amstutz over 1 year ago
- Target version changed from Development 2023-06-07 to Development 2023-06-21 sprint
Updated by Brett Smith over 1 year ago
Added tests and exception handling at 9effb65ce83e308edc404d8541066a456c520dce - developer-run-tests: #3690
Updated by Peter Amstutz over 1 year ago
20613-googleapiclient-init-logs @ 3f23131d66a0467b2bee74006d61ec3e25a153bb
Since import arvados.logging
is a new module and we get to name it whatever we want, would there be a benefit that instead of doing a dance in __init__.py
we just name it something else to avoid deliberately conflicting with the standard library?
if logging.NOTSET < client_level < client_filter.retry_levelno:
Lots (most) programming languages don't do what this means in standard math notation, is Python one of the ones that does?
not client_logger.hasHandlers()
As discussed on matrix, hasHandlers turns out to always be True (so client_logger_unconfigured is never True) because googleapiclient sets up a NullHandler, which is apparently recommended practice.
Updated by Brett Smith over 1 year ago
Peter Amstutz wrote in #note-8:
Since
import arvados.logging
is a new module and we get to name it whatever we want, would there be a benefit that instead of doing a dance in__init__.py
we just name it something else to avoid deliberately conflicting with the standard library?
IMO there is no name conflict between logging
and arvados.logging
. The reason the dance is necessary in __init__.py
is because there's just way too much stuff in there. But doing it is worth it to make a nicer experience for users. Compare the situation with arvados.api
, where it's literally impossible to import the module normally because __init__.py
masks it with a function.
if logging.NOTSET < client_level < client_filter.retry_levelno:
Lots (most) programming languages don't do what this means in standard math notation, is Python one of the ones that does?
unlike C, expressions like
a < b < c
have the interpretation that is conventional in mathematics
not client_logger.hasHandlers()
As discussed on matrix, hasHandlers turns out to always be True (so client_logger_unconfigured is never True) because googleapiclient sets up a NullHandler, which is apparently recommended practice.
Thanks for catching this, I checked a-c-r but didn't think to check googleapiclient itself. Updated the check in 150de14b0b265d86df11a04201320944d04fe3a5 - developer-run-tests: #3691
Updated by Peter Amstutz over 1 year ago
Brett Smith wrote in #note-9:
Thanks for catching this, I checked a-c-r but didn't think to check googleapiclient itself. Updated the check in 150de14b0b265d86df11a04201320944d04fe3a5 - developer-run-tests: #3691
wb1 tests are failing but that's normal (for a deviant definition of normal)
Tested manually and now it does what it is supposed to do.
LGTM.
Updated by Brett Smith over 1 year ago
- % Done changed from 0 to 100
- Status changed from In Progress to Resolved
Applied in changeset arvados|6fcc1aa58cf380604c5e149d41e22e7c3a4678df.