Skip to content

Commit

Permalink
fix match issue of mara_storage.config.storages
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Sep 19, 2023
1 parent f858edc commit 2d761f0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mara_pipelines/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ def default_storage_alias() -> str:
"""The alias of the storage that should be used when not specified otherwise"""
return 'data'

@patch(mara_storage.config.storages)
def storages() -> {str: mara_storage.storages.Storage}:
return {'data': mara_storage.storages.LocalStorage(base_path=pathlib.Path(data_dir()))}
patch(mara_storage.config.storages)(lambda: {'data': mara_storage.storages.LocalStorage(base_path=pathlib.Path(data_dir()))})

# Need to patch this function to fix lru_cache issues. mara_storage.storages.storage.cache_clear() does not fix issues here
@functools.lru_cache(maxsize=None)
@patch(mara_storage.storages.storage)
def storage(alias) -> mara_storage.storages.Storage:
"""Returns a storage configuration by alias"""
storages = mara_storage.config.storages()
if alias not in storages:
raise KeyError(f'storage alias "{alias}" not configured')
return storages[alias]


def default_task_max_retries():
Expand Down

0 comments on commit 2d761f0

Please sign in to comment.