X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/45cc809dfeab1d603e80cec3d44770d7f5a7c8ae..ffd49a86ec939a674e141a4cab8dcb3b6baaf2e6:/sdk/python/arvados/util.py diff --git a/sdk/python/arvados/util.py b/sdk/python/arvados/util.py index 2380e48b73..c383d529e8 100644 --- a/sdk/python/arvados/util.py +++ b/sdk/python/arvados/util.py @@ -392,7 +392,8 @@ def keyset_list_all(fn, order_key="created_at", num_retries=0, ascending=True, * pagesize = 1000 kwargs["limit"] = pagesize kwargs["count"] = 'none' - kwargs["order"] = ["%s %s" % (order_key, "asc" if ascending else "desc"), "uuid asc"] + asc = "asc" if ascending else "desc" + kwargs["order"] = ["%s %s" % (order_key, asc), "uuid %s" % asc] other_filters = kwargs.get("filters", []) if "select" in kwargs and "uuid" not in kwargs["select"]: @@ -436,7 +437,7 @@ def keyset_list_all(fn, order_key="created_at", num_retries=0, ascending=True, * if firstitem[order_key] == lastitem[order_key]: # Got a page where every item has the same order key. # Switch to using uuid for paging. - nextpage = [[order_key, "=", lastitem[order_key]], ["uuid", ">", lastitem["uuid"]]] + nextpage = [[order_key, "=", lastitem[order_key]], ["uuid", ">" if ascending else "<", lastitem["uuid"]]] prev_page_all_same_order_key = True else: # Start from the last order key seen, but skip the last @@ -491,3 +492,11 @@ def get_config_once(svc): if not hasattr(svc, '_cached_config'): svc._cached_config = svc.configs().get().execute() return svc._cached_config + +def get_vocabulary_once(svc): + if not svc._rootDesc.get('resources').get('vocabularies', False): + # Old API server version, no vocabulary export endpoint + return {} + if not hasattr(svc, '_cached_vocabulary'): + svc._cached_vocabulary = svc.vocabularies().get().execute() + return svc._cached_vocabulary