Example #1
0
def store(account_name, account_key, container):
    store = get_store("hazure",
                      account_name=account_name,
                      account_key=account_key,
                      container=container,
                      create_if_missing=True)
    return store
Example #2
0
def test_azure_implementation(azure_store_cfg_factory):
    cfg = azure_store_cfg_factory("ts")
    store = storefact.get_store(**cfg)
    assert _has_azure_bbs(store)
    content = b"foo"
    store.put("key0", content)
    assert (
        base64.b64decode(
            _azure_bbs_content_md5(store.block_blob_service, store.container, "key0")
        ).hex()
        == hashlib.md5(content).hexdigest()
    )
Example #3
0
def test_azure12_implementation(azure_store_cfg_factory):
    cfg = azure_store_cfg_factory("ts")
    store = storefact.get_store(**cfg)
    assert _has_azure_cc(store)
    content = b"foobar"
    store.put("key0", content)
    assert (
        _azure_cc_content_md5(store.blob_container_client, "key0").hex()
        == hashlib.md5(content).hexdigest()
    )
    assert (
        _azure_cc_content_md5(store.blob_container_client, "key_does_not_exist", True)
        is None
    )
Example #4
0
 def store(self):
     account_key = self.account_keys[self.account_name]
     readonly_sas_token = get_sas_token(self.account_name,
                                        account_key,
                                        self.container,
                                        readonly=True)
     store = get_store(
         "hazure",
         account_name=self.account_name,
         account_key=readonly_sas_token,
         container=self.container,
         create_if_missing=False,
         use_sas=True,
     )
     return store
Example #5
0
 def writable_store(self):
     if not self.writable:
         raise Exception("try to write to readonly dataset")
     account_key = self.account_keys[self.account_name]
     writable_sas_token = get_sas_token(self.account_name,
                                        account_key,
                                        self.container,
                                        readonly=False)
     store = get_store(
         "hazure",
         account_name=self.account_name,
         account_key=writable_sas_token,
         container=self.container,
         create_if_missing=False,
         use_sas=True,
     )
     return store
Example #6
0
 def __init__(self, url, account_key=None, globstring=None):
     account_name, container, prefix = parse_dataset(url)
     self.url = url
     self.account_name = account_name
     if account_key is None:
         self.account_key = get_key(account_name)
     self.container = container
     self.prefix = prefix
     self.globstring = globstring
     self.store = get_store(
         **{
             'type': 'hazure',
             'account_name': self.account_name,
             'account_key': self.account_key,
             'container': self.container
         })
     self._cached_keys = None
Example #7
0
def _gen_store(store_type, tmpdir, suffix, azure_store_cfg_factory):
    if store_type == "azure":
        cfg = azure_store_cfg_factory(suffix)
    elif store_type == "fs":
        cfg = {"type": "hfs", "path": tmpdir.join(suffix).strpath}
    elif store_type == "memory":
        cfg = {"type": "hmemory"}
    else:
        raise ValueError("Unknown store type: {}".format(store_type))

    store = storefact.get_store(**cfg)
    for k in store.keys():
        store.delete(k)

    yield store

    for k in store.keys():
        store.delete(k)

    # prevent ResourceWarning
    if hasattr(store, "block_blob_service"):
        store.block_blob_service.request_session.close()
    if hasattr(store, "blob_container_client"):
        store.blob_container_client.close()
Example #8
0
def azurestore(azurestorecfg):
    store = storefact.get_store(**azurestorecfg)
    yield store
    # prevent ResourceWarning
    gc.collect()
    store.block_blob_service.request_session.close()
Example #9
0
def store2(storecfg2):
    return storefact.get_store(**storecfg2)
Example #10
0
def store(storecfg):
    return storefact.get_store(**storecfg)
Example #11
0
def azurestorecfg2(azure_store_cfg_factory):
    cfg = azure_store_cfg_factory("cli2")
    store = storefact.get_store(**cfg)
    for k in list(store.keys()):
        store.delete(k)
    return cfg