Skip to content

Commit

Permalink
few changes based on review
Browse files Browse the repository at this point in the history
Signed-off-by: Pratiksha Sankhe <[email protected]>
  • Loading branch information
psankhe28 committed Oct 10, 2024
1 parent a6a674a commit 99df8cc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
20 changes: 10 additions & 10 deletions cloud_storage_handler/api/elixircloud/csh/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class MinioConfig(BaseModel):
"""Configuration for MinIO.
Attributes:
hostname : The hostname where the MinIO server is running.
Defaults to 'localhost'.
port (int): The port on which the MinIO server is running.
Must be between 1 and 65535. Defaults to 9000.
access_key (str): The access key used for authentication with MinIO.
Defaults to 'minioadmin'.
secret_key (str): The secret key used for authentication with MinIO.
Defaults to 'minioadmin'.
bucket_name (str): The name of the bucket where files are stored.
Must be at least 1 character long. Defaults to 'files'.
hostname: The hostname where the MinIO server is running.
Defaults to 'localhost'.
port: The port on which the MinIO server is running.
Must be between 1 and 65535. Defaults to 9000.
access_key: The access key used for authentication with MinIO.
Defaults to 'minioadmin'.
secret_key: The secret key used for authentication with MinIO.
Defaults to 'minioadmin'.
bucket_name: The name of the bucket where files are stored.
Must be at least 1 character long. Defaults to 'files'.
Examples:
MinioConfig(
Expand Down
1 change: 0 additions & 1 deletion cloud_storage_handler/custom_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CustomConfig(BaseModel):
"""Custom configuration model for the FOCA app.
Attributes:
minio (MinioConfig): Configuration for MinIO, including bucket details
and access credentials.
"""

Expand Down
21 changes: 15 additions & 6 deletions cloud_storage_handler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import logging
import os
import sys
from pathlib import Path

from connexion import FlaskApp
from foca import Foca
from minio import Minio
from pydantic import ValidationError

from cloud_storage_handler.api.elixircloud.csh.models import MinioConfig
from cloud_storage_handler.custom_config import CustomConfig

logger = logging.getLogger(__name__)

Expand All @@ -32,21 +35,27 @@ def init_app() -> tuple[FlaskApp, MinioConfig]:
custom_config_model="cloud_storage_handler.custom_config.CustomConfig",
)
foca_config = foca.conf
minio_config = foca_config.custom.minio
logger.info(minio_config)
try:
custom_config_data = foca_config.custom.dict()
custom_config = CustomConfig(**custom_config_data)
except ValidationError as e:
logger.error(f"Error parsing custom configuration: {e}")
raise
minio_config = custom_config.minio

# Create the Connexion FlaskApp instance
return foca.create_app(), minio_config


def main() -> None:
"""Run FOCA application."""
app, minio_config = init_app()
try:
app, minio_config = init_app()
except Exception as e:
logger.error(f"Unexpected error during initialization: {e}")
sys.exit(1)
foca_app = app.app

if minio_config is None:
raise KeyError("Custom configuration for MinIO not found in Flask app config.")

# Initialize MinIO client
try:
minio_client = Minio(
Expand Down

0 comments on commit 99df8cc

Please sign in to comment.