Skip to content

Commit

Permalink
Change default value to minio for s3 storage
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashbrnrd committed Oct 24, 2023
1 parent cd7dda2 commit 5178793
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ jobs:
AWS_DEFAULT_REGION: gra
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
S3_URL_ENDPOINT: https://s3.gra.io.cloud.ovh.net/
S3_BUCKET_NAME: basegun-s3
steps:
- run: cd /app && python -m unittest

Expand Down
29 changes: 4 additions & 25 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,6 @@
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))


def init_variable(key: str, value: str) -> str:
"""Inits global variable for folder path
Args:
key (str): variable key in environ
value (str): value to give if variable does not exist yet
Returns:
str: final variable value
"""
if key in os.environ:
VAR = os.environ[key]
else:
VAR = value
print("WARNING: The variable " + key + " is not set. Using", VAR)
if os.path.isabs(VAR):
os.makedirs(VAR, exist_ok=True)
return VAR


def setup_logs(log_dir: str) -> logging.Logger:
"""Setups environment for logs
Expand All @@ -58,6 +38,7 @@ def setup_logs(log_dir: str) -> logging.Logger:
"""
print(">>> Reload logs config")
# clear previous logs
os.makedirs(log_dir, exist_ok=True)
for f in os.listdir(log_dir):
os.remove(os.path.join(log_dir, f))
# configure new logs
Expand Down Expand Up @@ -164,9 +145,7 @@ def upload_image(content: bytes, image_key: str):
)

# Logs
PATH_LOGS = init_variable(
"PATH_LOGS", os.path.abspath(os.path.join(CURRENT_DIR, "/tmp/logs"))
)
PATH_LOGS = os.environ.get("PATH_LOGS", "/tmp/logs")
logger = setup_logs(PATH_LOGS)

# Load model
Expand All @@ -178,8 +157,8 @@ def upload_image(content: bytes, image_key: str):
raise RuntimeError("Model not found")

# Object storage
S3_URL_ENDPOINT = init_variable("S3_URL_ENDPOINT", "https://s3.gra.io.cloud.ovh.net/")
S3_BUCKET_NAME = "basegun-s3"
S3_URL_ENDPOINT = os.environ["S3_URL_ENDPOINT"]
S3_BUCKET_NAME = os.environ["S3_BUCKET_NAME"]
S3_PREFIX = os.path.join("uploaded-images/", os.environ["WORKSPACE"])

s3 = boto3.resource("s3", endpoint_url=S3_URL_ENDPOINT, verify=False)
Expand Down
1 change: 0 additions & 1 deletion backend/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys
import unittest

import numpy as np
Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ services:
target: ${BUILD_TARGET:-dev}
container_name: basegun-backend
environment:
- S3_URL_ENDPOINT=${S3_URL_ENDPOINT:-http://minio:9000}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-minioadmin}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-minioadmin}
- S3_URL_ENDPOINT=http://minio:9000
- S3_BUCKET_NAME=basegun-s3
- AWS_ACCESS_KEY_ID=minioadmin
- AWS_SECRET_ACCESS_KEY=minioadmin
- http_proxy
- https_proxy
- UVICORN_LOG_LEVEL=${UVICORN_LOG_LEVEL}
Expand Down
2 changes: 2 additions & 0 deletions infra/kube/helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
data:
WORKSPACE: {{ .Values.backend.config.workspace }}
PATH_LOGS: /tmp/log/basegun/
S3_URL_ENDPOINT: https://basegun-8b03-s3.s3obj.ecs.objstore.r1.pi2.minint.fr
S3_BUCKET_NAME: basegun-s3
---
apiVersion: v1
kind: ConfigMap
Expand Down

0 comments on commit 5178793

Please sign in to comment.