-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable storage provider #1937
Comments
Can I work on this issue?? |
@sainak Will you provide test secrets and credentials to work on this issue? |
@balaji-sivasakthi you will have to use local development tools like localstack and azureite |
@sainak Is these tools FOSS? |
For our use case, yes |
|
ApproachTo decouple the storage provider from specific use cases like patient and facility, we can introduce more flexibility by allowing the specification of bucket types and access controls through parameters. We'll utilize enums for access control and provide the bucket name as a parameter. class ClientConfig(TypedDict):
region_name: str
aws_access_key_id: str
aws_secret_access_key: str
endpoint_url: str
class CSProvider(enum.Enum):
AWS = "AWS"
GCP = "GCP"
AZURE = 'AZURE'
DOCKER = "DOCKER" # localstack in docker
LOCAL = "LOCAL" # localstack on host
class AccessControl(enum.Enum):
PUBLIC = "PUBLIC"
PRIVATE = "PRIVATE"
class BucketType(enum.Enum):
PATIENT = "PATIENT"
FACILITY = "FACILITY" Then we will create a factory method for storages based on the I will add a class method named from_provider inside the ConfigurableStorageProvider class. This method acts as a factory method to create instances of ConfigurableStorageProvider based on the specified CSProvider. When calling the from_provider method, you provide the desired CSProvider, account_url, and credential. It internally creates a ClientConfig object and initialises the ConfigurableStorageProvider instance accordingly. This approach makes it easier to instantiate the ConfigurableStorageProvider class by encapsulating the logic of creating the ClientConfig object based on the specified provider LLDdef __init__(self, provider: CSProvider, client_config: ClientConfig): def from_provider(cls, provider: CSProvider, account_url: str, credential: str) -> 'ConfigurableStorageProvider': def get_signed_url(self, bucket_name: BucketName, object_key: str, expiration: int, access_control: AccessControl) -> str: def check_mime_type(self, file_path: str, expected_mime_type: str) -> bool: |
@sainak Please share your feedback for the below approach Implementation PlanTo make the storage provider configuration more flexible and support multiple types (AWS S3, Azure Blob Storage, Local Storage), this would be my approach: 1. Define Abstract Base Class for Storage ProvidersCreate an abstract base class BaseStorageProvider that will define the common interface for all storage providers, ensuring consistency. 2. Implement Concrete Storage Provider ClassesImplement concrete storage provider classes for AWS S3, Azure Blob Storage, and Local Storage, each inheriting from the BaseStorageProvider class. 3. Centralize Configuration ManagementUpdate the config.py to handle configuration for all supported storage providers and bucket types (e.g., Patient, Facility). This will include settings for AWS S3, Azure Blob Storage, and Local Storage. 4. Create Utility Functions for Storage Provider InitializationCreate utility functions in storage_utils.py to initialize and return the appropriate storage provider based on the configuration. 5. Integrate MIME Type ChecksCentralize MIME type checks in a utility module mime_type_utils.py to avoid duplication and ensure consistency across different storage providers. base_storage_provider.py
config.py
storage_utils.py
mime_type_utils.py
|
Currently, we only support s3 compatible storage providers for storing and retrieving files, we need to make the storage provider more configurable
we have 2 buckets currently:
The solution is to create a configurable storage provider class that can support s3/azure blob storage/local storage to serve files.
requirements:
Share your implementation plan before working on this issue
The text was updated successfully, but these errors were encountered: