1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
6 This module provides the entire Python SDK for Arvados. The most useful modules
9 * arvados.api - After you `import arvados`, you can call `arvados.api` as a
10 shortcut to the client constructor function `arvados.api.api`.
12 * arvados.collection - The `arvados.collection.Collection` class provides a
13 high-level interface to read and write collections. It coordinates sending
14 data to and from Keep, and synchronizing updates with the collection object.
16 * arvados.util - Utility functions to use mostly in conjunction with the API
17 client object and the results it returns.
19 Other submodules provide lower-level functionality.
22 import logging as stdliblog
27 from collections import UserDict
29 from . import api, errors, util
30 from .api import api_from_config, http_cache
31 from .collection import CollectionReader
32 from arvados.keep import *
33 from .logging import log_format, log_date_format, log_handler
34 from .retry import RetryLoop
36 # Backwards compatibility shims: these modules used to get pulled in after
37 # `import arvados` with previous versions of the SDK. We must keep the names
38 # accessible even though there's no longer any functional need for them.
42 # Previous versions of the PySDK used to say `from .api import api`. This
43 # made it convenient to call the API client constructor, but difficult to
44 # access the rest of the `arvados.api` module. The magic below fixes that
45 # bug while retaining backwards compatibility: `arvados.api` is now the
46 # module and you can import it normally, but we make that module callable so
47 # all the existing code that says `arvados.api('v1', ...)` still works.
48 class _CallableAPIModule(api.__class__):
49 __call__ = staticmethod(api.api)
50 api.__class__ = _CallableAPIModule
52 # Override logging module pulled in via `from ... import *`
53 # so users can `import arvados.logging`.
54 logging = sys.modules['arvados.logging']
56 # Set up Arvados logging based on the user's configuration.
57 # All Arvados code should log under the arvados hierarchy.
58 logger = stdliblog.getLogger('arvados')
59 logger.addHandler(log_handler)
60 logger.setLevel(stdliblog.DEBUG if config.get('ARVADOS_DEBUG')
61 else stdliblog.WARNING)