ソースを参照

Fix elasticsearch status display (#3487)

### What problem does this PR solve?

_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: jinhai <haijin.chn@gmail.com>
tags/v0.14.0
Jin Hai 11ヶ月前
コミット
883fafde72
コミッターのメールアドレスに関連付けられたアカウントが存在しません
2個のファイルの変更16行の追加14行の削除
  1. 3
    1
      rag/utils/es_conn.py
  2. 13
    13
      rag/utils/minio_conn.py

+ 3
- 1
rag/utils/es_conn.py ファイルの表示

@@ -63,7 +63,9 @@ class ESConnection(DocStoreConnection):
return "elasticsearch"

def health(self) -> dict:
return dict(self.es.cluster.health()) + {"type": "elasticsearch"}
health_dict = dict(self.es.cluster.health())
health_dict["type"] = "elasticsearch"
return health_dict

"""
Table operations

+ 13
- 13
rag/utils/minio_conn.py ファイルの表示

@@ -55,7 +55,7 @@ class RAGFlowMinio(object):
)
return r
except Exception:
logging.exception(f"Fail put {bucket}/{fnm}:")
logging.exception(f"Fail to put {bucket}/{fnm}:")
self.__open__()
time.sleep(1)

@@ -63,37 +63,37 @@ class RAGFlowMinio(object):
try:
self.conn.remove_object(bucket, fnm)
except Exception:
logging.exception(f"Fail put {bucket}/{fnm}:")
logging.exception(f"Fail to remove {bucket}/{fnm}:")

def get(self, bucket, fnm):
def get(self, bucket, filename):
for _ in range(1):
try:
r = self.conn.get_object(bucket, fnm)
r = self.conn.get_object(bucket, filename)
return r.read()
except Exception:
logging.exception(f"Fail put {bucket}/{fnm}:")
logging.exception(f"Fail to get {bucket}/{filename}")
self.__open__()
time.sleep(1)
return

def obj_exist(self, bucket, fnm):
def obj_exist(self, bucket, filename):
try:
if not self.conn.bucket_exists(bucket):
return False
if self.conn.stat_object(bucket, fnm):
if self.conn.stat_object(bucket, filename):
return True
return False
else:
return False
except Exception:
logging.exception(f"RAGFlowMinio.obj_exist {bucket}/{fnm} got exception:")
return False

logging.exception(f"Not found: {bucket}/{filename}")
return False

def get_presigned_url(self, bucket, fnm, expires):
for _ in range(10):
try:
return self.conn.get_presigned_url("GET", bucket, fnm, expires)
except Exception:
logging.exception(f"Fail put {bucket}/{fnm}:")
logging.exception(f"Fail to get_presigned {bucket}/{fnm}:")
self.__open__()
time.sleep(1)
return
@@ -101,11 +101,11 @@ class RAGFlowMinio(object):

MINIO = RAGFlowMinio()


if __name__ == "__main__":
conn = RAGFlowMinio()
fnm = "/opt/home/kevinhu/docgpt/upload/13/11-408.jpg"
from PIL import Image

img = Image.open(fnm)
buff = BytesIO()
img.save(buff, format='JPEG')

読み込み中…
キャンセル
保存