Skip to content

Commit

Permalink
Merge branch 'master' into decrease_test_step
Browse files Browse the repository at this point in the history
  • Loading branch information
ccssu authored Dec 16, 2024
2 parents 718a010 + 2147d28 commit 1b50738
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 284 deletions.
14 changes: 2 additions & 12 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,7 @@ def update_mappings(module):
update_mappings(mzkolors)
update_mappings(segment_anything)

# bizy_server
bizyair_adv_is_not_installed = False
try:
import crcmod
import oss2
except ImportError:
bizyair_adv_is_not_installed = True
print(
"\n\n\033[91m[BizyAir]\033[0m Please run"
" 'pip install -r requirements.txt' to install depencies for model host feature.\n\n"
)

if not bizyair_adv_is_not_installed:
import bizy_server
except Exception as e:
print("\n\n\033[91m[BizyAir]\033[0m Fail to import 'bizy_server':" f" {e}\n\n")
5 changes: 0 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
oss2
crcmod
requests
aiofiles
aliyun-python-sdk-core
aliyun-python-sdk-kms
210 changes: 0 additions & 210 deletions src/bizy_server/oss.py

This file was deleted.

59 changes: 2 additions & 57 deletions src/bizy_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from .api_client import APIClient
from .errno import ErrorNo, errnos
from .error_handler import ErrorHandler
from .oss import AliOssStorageClient
from .resp import ErrResponse, OKResponse
from .utils import base_model_types, check_str_param, check_type, is_string_valid, types

Expand Down Expand Up @@ -114,7 +113,7 @@ async def commit_file(request):
commit_data, err = await self.api_client.commit_file(
signature=sha256sum, object_key=object_key, md5_hash=md5_hash
)
print("commit_data", commit_data)
# print("commit_data", commit_data)
if err is not None:
return ErrResponse(err)

Expand Down Expand Up @@ -174,7 +173,7 @@ async def commit_bizy_model(request):
if err:
return ErrResponse(err)

print("resp------------------------------->", json_data, resp)
# print("resp------------------------------->", json_data, resp)
# 开启线程检查同步状态
threading.Thread(
target=self.check_sync_status,
Expand Down Expand Up @@ -380,60 +379,6 @@ async def like_model_version(request):
)
return ErrResponse(errnos.TOGGLE_USER_LIKE)

@self.prompt_server.routes.post(f"/{COMMUNITY_API}/files/upload")
async def upload_file(request):
try:
# 获取上传的文件
reader = await request.multipart()
field = await reader.next()
if not field or field.name != "file":
return ErrResponse(errnos.NO_FILE_UPLOAD)

filename = field.filename
if not filename:
return ErrResponse(errnos.NO_FILE_UPLOAD)

# 读取文件内容
file_content = await field.read(decode=False)

filename = urllib.parse.quote(filename)
# 获取上传凭证
ret, err = await self.api_client.get_upload_token(filename=filename)
if err:
return ErrResponse(err)

# 解析返回的凭证信息
file_info = ret["file"]
storage_info = ret["storage"]

def updateProgress(consume_bytes, total_bytes):
# do nothing
pass

oss_client = AliOssStorageClient(
endpoint=storage_info.get("endpoint"),
bucket_name=storage_info.get("bucket"),
access_key=file_info.get("access_key_id"),
secret_key=file_info.get("access_key_secret"),
security_token=file_info.get("security_token"),
onUploading=updateProgress,
onInterrupted=None,
)
await oss_client.upload_file_content(
file_content=file_content,
file_name=filename,
object_name=file_info.get("object_key"),
)
return OKResponse(
{
"url": f'https://{storage_info.get("bucket")}.{storage_info.get("endpoint")}/{file_info.get("object_key")}'
}
)

except Exception as e:
print(f"\033[31m[BizyAir]\033[0m Fail to upload file: {str(e)}")
return ErrResponse(errnos.UPLOAD)

@self.prompt_server.routes.get(
f"/{COMMUNITY_API}/models/versions/{{model_version_id}}/workflow_json/{{sign}}"
)
Expand Down

0 comments on commit 1b50738

Please sign in to comment.