Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed Oct 11, 2024
1 parent 8b20747 commit 11f735c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
13 changes: 6 additions & 7 deletions cloud_storage_handler/api/elixircloud/csh/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""MinIO client class and convenience functions."""

import logging
from typing import Type

from connexion import FlaskApp
from minio import Minio
Expand All @@ -28,7 +27,7 @@ def __init__(self, config: MinioConfig) -> None:
config: MinIO configuration.
"""
self.config: MinioConfig = config
self.client: Type[Minio] = Minio(
self.client: Minio = Minio(
endpoint=f"{config.hostname}:{config.port}",
access_key=config.access_key,
secret_key=config.secret_key,
Expand All @@ -48,14 +47,14 @@ def register_minio_client(app: FlaskApp) -> FlaskApp:
"""Register MinIO client and create bucket.
Args:
app: FOCA app instance.
app: Connexion Flask app instance.
Returns:
FOCA app instance with MinIO client instance added to config.
Connexion Flask app instance with a MinIO client instance added to
its config.
"""
minio_config = app.app.config.foca.custom.minio
minio_client = MinioClient(config=minio_config)
minio_client = MinioClient(config=app.app.config.foca.custom.minio)
minio_client.create_bucket()
minio_config.client = minio_client
app.app.config.foca.custom.minio.client = minio_client
logger.info("MinIO client registered.")
return app
9 changes: 7 additions & 2 deletions cloud_storage_handler/api/elixircloud/csh/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Model for MinIO Configuration."""

from typing import Annotated, Optional, Type
from typing import Annotated, Optional

from minio import Minio
from pydantic import BaseModel, conint, constr
Expand Down Expand Up @@ -37,4 +37,9 @@ class MinioConfig(BaseModel):
secret_key: str = "minioadmin"
bucket_name: Annotated[str, constr(min_length=1)] = "files"
secure: bool = False
client: Optional[Type[Minio]] = None
client: Optional[Minio] = None

class Config:
"""Model configuration."""

arbitrary_types_allowed = True
2 changes: 1 addition & 1 deletion cloud_storage_handler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def init_app() -> FlaskApp:
the default path if not.
Returns:
A Connexion application instance.
A Connexion Flask application instance.
"""
config_path = Path(
os.getenv(
Expand Down

0 comments on commit 11f735c

Please sign in to comment.