diff --git a/lib/galaxy/objectstore/azure_blob.py b/lib/galaxy/objectstore/azure_blob.py index 431d132935a..00e9b9f2e97 100644 --- a/lib/galaxy/objectstore/azure_blob.py +++ b/lib/galaxy/objectstore/azure_blob.py @@ -30,6 +30,7 @@ from . import ConcreteObjectStore from .caching import ( CacheTarget, InProcessCacheMonitor, + parse_caching_config_dict_from_xml, ) NO_BLOBSERVICE_ERROR_MESSAGE = ( @@ -51,18 +52,7 @@ def parse_config_xml(config_xml): container_name = container_xml.get("name") max_chunk_size = int(container_xml.get("max_chunk_size", 250)) # currently unused - cache_els = config_xml.findall("cache") - if len(cache_els) > 0: - c_xml = config_xml.findall("cache")[0] - cache_size = float(c_xml.get("size", -1)) - staging_path = c_xml.get("path", None) - - cache_dict = { - "size": cache_size, - "path": staging_path, - } - else: - cache_dict = {} + cache_dict = parse_caching_config_dict_from_xml(config_xml) tag, attrs = "extra_dir", ("type", "path") extra_dirs = config_xml.findall(tag) diff --git a/lib/galaxy/objectstore/caching.py b/lib/galaxy/objectstore/caching.py index d7fa078341d..36b9dd44748 100644 --- a/lib/galaxy/objectstore/caching.py +++ b/lib/galaxy/objectstore/caching.py @@ -98,6 +98,23 @@ def _get_cache_size_files(cache_path) -> Tuple[int, FileListT]: return cache_size, file_list +def parse_caching_config_dict_from_xml(config_xml): + cache_els = config_xml.findall("cache") + if len(cache_els) > 0: + c_xml = config_xml.findall("cache")[0] + cache_size = float(c_xml.get("size", -1)) + + staging_path = c_xml.get("path", None) + + cache_dict = { + "size": cache_size, + "path": staging_path, + } + else: + cache_dict = {} + return cache_dict + + class InProcessCacheMonitor: def __init__(self, cache_target: CacheTarget, interval: int = 30, initial_sleep: Optional[int] = 2): # This Event object is initialized to False diff --git a/lib/galaxy/objectstore/s3.py b/lib/galaxy/objectstore/s3.py index 6ea2d9c4ef0..2db7fd7e076 100644 --- a/lib/galaxy/objectstore/s3.py +++ b/lib/galaxy/objectstore/s3.py @@ -35,6 +35,7 @@ from . import ConcreteObjectStore from .caching import ( CacheTarget, InProcessCacheMonitor, + parse_caching_config_dict_from_xml, ) from .s3_multipart_upload import multipart_upload @@ -70,19 +71,7 @@ def parse_config_xml(config_xml): is_secure = string_as_bool(cn_xml.get("is_secure", "True")) conn_path = cn_xml.get("conn_path", "/") - cache_els = config_xml.findall("cache") - if len(cache_els) > 0: - c_xml = config_xml.findall("cache")[0] - cache_size = float(c_xml.get("size", -1)) - - staging_path = c_xml.get("path", None) - - cache_dict = { - "size": cache_size, - "path": staging_path, - } - else: - cache_dict = {} + cache_dict = parse_caching_config_dict_from_xml(config_xml) tag, attrs = "extra_dir", ("type", "path") extra_dirs = config_xml.findall(tag)