Skip to content

Commit

Permalink
Merge pull request #18087 from jmchilton/rev_azure
Browse files Browse the repository at this point in the history
Overhaul Azure storage infrastructure.
  • Loading branch information
mvdbeek authored May 6, 2024
2 parents 77240b7 + e03d162 commit 4f68dd2
Show file tree
Hide file tree
Showing 13 changed files with 621 additions and 82 deletions.
3 changes: 2 additions & 1 deletion lib/galaxy/dependencies/conditional-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sentry-sdk[fastapi]
pbs_python
drmaa
statsd
azure-storage==0.32.0
azure-storage-blob==12.19.1
python-irodsclient==2.0.0
python-ldap==3.4.0
ldap3==2.9.1
Expand All @@ -26,6 +26,7 @@ fs-gcsfs # type: googlecloudstorage
google-cloud-storage>=2.8.0 # type: googlecloudstorage
fs.onedatarestfs # type: onedata
fs-basespace # type: basespace
fs-azureblob # type: azure

# Vault backend
hvac
Expand Down
43 changes: 43 additions & 0 deletions lib/galaxy/files/sources/azure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from typing import Union

try:
from fs.azblob import (
BlobFS,
BlobFSV2,
)
except ImportError:
BlobFS = None

from typing import Optional

from . import (
FilesSourceOptions,
FilesSourceProperties,
)
from ._pyfilesystem2 import PyFilesystem2FilesSource


class AzureFileSource(PyFilesystem2FilesSource):
plugin_type = "azure"
required_module = BlobFS
required_package = "fs-azureblob"

def _open_fs(self, user_context=None, opts: Optional[FilesSourceOptions] = None):
props = self._serialization_props(user_context)
extra_props: Union[FilesSourceProperties, dict] = opts.extra_props or {} if opts else {}
all_props = {**props, **extra_props}
namespace_type = all_props.get("namespace_type", "hierarchical")
if namespace_type not in ["hierarchical", "flat"]:
raise Exception("Misconfigured azure file source")
account_name = all_props["account_name"]
account_key = all_props["account_key"]
container = all_props["container_name"]
if namespace_type == "flat":
handle = BlobFS(account_name, container, account_key)
else:
handle = BlobFSV2(account_name, container, account_key)

return handle


__all__ = ("AzureFileSource",)
Loading

0 comments on commit 4f68dd2

Please sign in to comment.