Skip to content

Commit

Permalink
run everything through isort
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ11teen committed Jul 28, 2021
1 parent bcb462e commit 3a558ef
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 27 deletions.
7 changes: 6 additions & 1 deletion src/cloudmappings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from .wrappers import AzureBlobMapping, AzureTableMapping, GoogleCloudStorageMapping, AWSS3Mapping
from .wrappers import (
AWSS3Mapping,
AzureBlobMapping,
AzureTableMapping,
GoogleCloudStorageMapping,
)

__all__ = [
"AzureBlobMapping",
Expand Down
1 change: 0 additions & 1 deletion src/cloudmappings/storageproviders/awss3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from .storageprovider import StorageProvider


_metadata_etag_key = "cloud-mappings-etag"


Expand Down
10 changes: 7 additions & 3 deletions src/cloudmappings/storageproviders/azureblobstorage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from typing import Dict
import json
from typing import Dict

from azure.core import MatchConditions
from azure.core.exceptions import ResourceExistsError, ResourceModifiedError, ResourceNotFoundError
from azure.storage.blob import ContainerClient
from azure.core.exceptions import (
ResourceExistsError,
ResourceModifiedError,
ResourceNotFoundError,
)
from azure.identity import DefaultAzureCredential
from azure.storage.blob import ContainerClient

from .storageprovider import StorageProvider

Expand Down
8 changes: 6 additions & 2 deletions src/cloudmappings/storageproviders/azuretablestorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from urllib.parse import quote, unquote

from azure.core import MatchConditions
from azure.core.exceptions import ResourceExistsError, HttpResponseError, ResourceNotFoundError
from azure.core.exceptions import (
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
)
from azure.data.tables import TableClient, UpdateMode
from azure.identity import DefaultAzureCredential

Expand All @@ -23,7 +27,7 @@ class AzureTableStorageProvider(StorageProvider):
def __init__(
self,
table_name: str,
endpoint: str = None,
endpoint: str,
credential=DefaultAzureCredential(),
connection_string: str = None,
) -> None:
Expand Down
16 changes: 8 additions & 8 deletions src/cloudmappings/storageproviders/storageprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def logical_name(self) -> str:
"""Returns a human readable string identifying the current implementation, and which
logical cloud resouce it is currently mapping to. Does not include any credential or
secret information.
Returns
-------
str
Expand All @@ -39,7 +39,7 @@ def create_if_not_exists(self) -> bool:
* Azure Blob Storage: A Blob Container
* GCP GCS: A GCS Bucket
* AWS S3: An S3 Bucket
Returns
-------
bool
Expand All @@ -50,21 +50,21 @@ def create_if_not_exists(self) -> bool:
@abstractmethod
def download_data(self, key: str, etag: str) -> bytes:
"""Download data from cloud storage
Downloads the data at the specified key and with the specified etag from cloud storage.
If `None` is passed for etag the latest version in the cloud will be downloaded.
Otherwise the etag will be used to ensure the data downloaded has a matching etag. If
the etag does not match the latest cloud version, a `cloudmappings.errors.KeySyncError`
will be raised.
Parameters
----------
key : str
The key specifying which data to download
etag : str or None
Etag of the expected latest value in the cloud, or `None`
Raises
------
KeySyncError
Expand All @@ -80,7 +80,7 @@ def download_data(self, key: str, etag: str) -> bytes:
@abstractmethod
def upload_data(self, key: str, etag: str, data: bytes) -> str:
"""Upload data to cloud storage
Uploads data at the specified key to cloud storage, only overwriting if the etag matches
Parameters
Expand Down Expand Up @@ -110,7 +110,7 @@ def upload_data(self, key: str, etag: str, data: bytes) -> str:
@abstractmethod
def delete_data(self, key: str, etag: str) -> None:
"""Delete data from cloud storage.
Deletes data at the specified key from cloud storage, only if the etag matches
Parameters
Expand Down
2 changes: 1 addition & 1 deletion tests/cleanup_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@


def cleanup_azure_blob_storage():
from azure.storage.blob import BlobServiceClient
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient

print("Deleting Azure Blob Storage containers:")
client = BlobServiceClient(
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
import os
from uuid import uuid4
import logging

import pytest

from cloudmappings.storageproviders.awss3 import AWSS3Provider
from cloudmappings.storageproviders.azureblobstorage import AzureBlobStorageProvider
from cloudmappings.storageproviders.azuretablestorage import AzureTableStorageProvider
from cloudmappings.storageproviders.googlecloudstorage import GoogleCloudStorageProvider
from cloudmappings.storageproviders.awss3 import AWSS3Provider


def pytest_addoption(parser):
Expand Down
12 changes: 6 additions & 6 deletions tests/tests/4_cloudmappingutilities.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pytest
import pickle
import zlib

import pytest

from cloudmappings.cloudstoragemapping import CloudMapping
from cloudmappings.errors import KeySyncError
from cloudmappings.storageproviders.storageprovider import StorageProvider


class CloudMappingUtilityTests:
def test_with_buffers_includes_extras(self, storage_provider: StorageProvider, test_id: str):
cm = CloudMapping.with_buffers(
def test_with_serialisers_includes_extras(self, storage_provider: StorageProvider, test_id: str):
cm = CloudMapping.with_serialisers(
[lambda i: i],
[lambda i: i],
storage_provider=storage_provider,
Expand All @@ -29,9 +29,9 @@ def test_with_buffers_includes_extras(self, storage_provider: StorageProvider, t
assert cm.get_read_blindly() == True
assert cm.get_read_blindly() == cm.d.get_read_blindly()

def test_with_buffers_fails_with_uneven_buffers(self, storage_provider: StorageProvider):
def test_with_serialisers_fails_with_uneven_buffers(self, storage_provider: StorageProvider):
with pytest.raises(ValueError, match="equal number of input buffers as output buffers"):
CloudMapping.with_buffers(
CloudMapping.with_serialisers(
[lambda i: i, lambda i: i],
[lambda i: i],
storage_provider=storage_provider,
Expand Down
9 changes: 6 additions & 3 deletions tests/tests/5_wrappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest

from cloudmappings import AzureBlobMapping, AzureTableMapping, GoogleCloudStorageMapping, AWSS3Mapping
from cloudmappings import (
AWSS3Mapping,
AzureBlobMapping,
AzureTableMapping,
GoogleCloudStorageMapping,
)


class WrapperTests:
Expand Down

0 comments on commit 3a558ef

Please sign in to comment.