feat : 代码梳理 移除所有敏感密钥 通过环境变量方式配置
All checks were successful
git commit AiDA python develop 分支构建部署 / scheduled_deploy (push) Has been skipped
All checks were successful
git commit AiDA python develop 分支构建部署 / scheduled_deploy (push) Has been skipped
This commit is contained in:
@@ -5,21 +5,26 @@ import time
|
||||
import cv2
|
||||
import minio.error
|
||||
import numpy as np
|
||||
import pika
|
||||
import redis
|
||||
import torch
|
||||
import tritonclient.grpc as grpcclient
|
||||
from minio import Minio
|
||||
|
||||
from app.core.config import *
|
||||
from app.core.config import settings, SR_TRITON_URL, SR_RABBITMQ_QUEUES, SR_MODEL_NAME
|
||||
from app.core.rabbit_mq_config import RABBITMQ_PARAMS
|
||||
from app.schemas.super_resolution import SuperResolutionModel
|
||||
from app.service.utils.oss_client import oss_get_image, oss_upload_image
|
||||
from app.service.utils.new_oss_client import oss_get_image, oss_upload_image
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
minio_client = Minio(settings.MINIO_URL, access_key=settings.MINIO_ACCESS, secret_key=settings.MINIO_SECRET, secure=settings.MINIO_SECURE)
|
||||
|
||||
|
||||
class SuperResolution:
|
||||
def __init__(self, data):
|
||||
self.triton_client = grpcclient.InferenceServerClient(url=SR_TRITON_URL)
|
||||
self.redis_client = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, decode_responses=True)
|
||||
self.redis_client = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, decode_responses=True)
|
||||
self.tasks_id = data.sr_tasks_id
|
||||
self.user_id = self.tasks_id[self.tasks_id.rfind('-') + 1:]
|
||||
self.sr_image_url = data.sr_image_url
|
||||
@@ -97,8 +102,8 @@ class SuperResolution:
|
||||
image_bytes = cv2.imencode('.jpg', image)[1].tobytes()
|
||||
# res = self.minio_client.put_object(f'{SR_MINIO_BUCKET}', f'{self.user_id}/sr/output/{self.tasks_id}.jpg', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png')
|
||||
object_name = f'{self.user_id}/sr/output/{self.tasks_id}.jpg'
|
||||
oss_upload_image(bucket=SR_MINIO_BUCKET, object_name=object_name, image_bytes=image_bytes)
|
||||
image_url = f"{SR_MINIO_BUCKET}/{object_name}"
|
||||
oss_upload_image(oss_client=minio_client, bucket="aida-users", object_name=object_name, image_bytes=image_bytes)
|
||||
image_url = f"aida-users/{object_name}"
|
||||
return image_url
|
||||
except Exception as e:
|
||||
logger.warning(f"upload_png_mask runtime exception : {e}")
|
||||
@@ -122,7 +127,7 @@ class SuperResolution:
|
||||
|
||||
|
||||
def infer_cancel(tasks_id):
|
||||
redis_client = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, decode_responses=True)
|
||||
redis_client = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, decode_responses=True)
|
||||
data = {'tasks': tasks_id, 'status': 'REVOKED', 'message': "revoked", 'data': 'revoked'}
|
||||
sr_data = json.dumps({'status': 'REVOKED', 'message': "revoked", 'data': 'revoked'})
|
||||
redis_client.set(tasks_id, sr_data)
|
||||
|
||||
Reference in New Issue
Block a user