Skip to content

Commit

Permalink
Update Azure infrastructure.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed May 3, 2024
1 parent fa2afe8 commit 6a2a6be
Show file tree
Hide file tree
Showing 13 changed files with 620 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 6a2a6be

Please sign in to comment.