# Path: gbdxtools/auth.py
# def Auth(**kwargs):
#     global auth
#     if auth is None or len(kwargs) > 0:
#         auth = _Auth(**kwargs)
#     return auth


from time import sleep
from io import BytesIO
from functools import lru_cache
from gbdxtools.auth import Auth
import numpy as np
import imageio
import tifffile

conn = Auth().gbdx_connection

# cache tile fetches so we don't re-request tiles from RDA
@lru_cache(maxsize=128)
def load_url(url):
    # try 5 times to get a tile from RDA
    # but sleep an exponentially increasing amount
    # so that RDA autoscaling can catch up
    for i in range(5):
        try:
            r = conn.get(url)
            r.raise_for_status()
            memfile = BytesIO(r.content)

# Path: gbdxtools/auth.py
# def Auth(**kwargs):
#     global auth
#     if auth is None or len(kwargs) > 0:
#         auth = _Auth(**kwargs)
#     return auth


# Path: gbdxtools/rda/fetch.py
from time import sleep
from io import BytesIO
from functools import lru_cache
from gbdxtools.auth import Auth
import numpy as np
import imageio
import tifffile


conn = Auth().gbdx_connection

# cache tile fetches so we don't re-request tiles from RDA
@lru_cache(maxsize=128)
def load_url(url):
    # try 5 times to get a tile from RDA
    # but sleep an exponentially increasing amount
    # so that RDA autoscaling can catch up
    for i in range(5):
        try:
            r = conn.get(url)
            r.raise_for_status()
            memfile = BytesIO(r.content)

            if r.headers['Content-Type'] == 'image/tiff':