MeUtils 2024.11.29.20.47.50__py3-none-any.whl → 2024.11.29.21.20.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MeUtils
3
- Version: 2024.11.29.20.47.50
3
+ Version: 2024.11.29.21.20.15
4
4
  Summary: description
5
5
  Home-page: https://github.com/yuanjie-ai/MeUtils
6
6
  Author: yuanjie
@@ -62,41 +62,41 @@ Requires-Dist: openai ; extra == 'ai'
62
62
  Requires-Dist: langchain ; extra == 'ai'
63
63
  Provides-Extra: all
64
64
  Requires-Dist: pandas-summary ; extra == 'all'
65
- Requires-Dist: streamlit ; extra == 'all'
66
- Requires-Dist: pymongo ; extra == 'all'
67
- Requires-Dist: langchain ; extra == 'all'
68
- Requires-Dist: pymupd ; extra == 'all'
69
- Requires-Dist: jinja2 ; extra == 'all'
70
65
  Requires-Dist: fastapi[all] ; extra == 'all'
71
- Requires-Dist: schedule ; extra == 'all'
72
66
  Requires-Dist: polars ; extra == 'all'
73
- Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
74
- Requires-Dist: sse-starlette ; extra == 'all'
75
- Requires-Dist: iteration-utilities ; extra == 'all'
76
- Requires-Dist: pyarrow ; extra == 'all'
77
- Requires-Dist: thriftpy2 ; extra == 'all'
78
- Requires-Dist: faiss-cpu ; extra == 'all'
79
- Requires-Dist: asyncmy ; extra == 'all'
67
+ Requires-Dist: schedule ; extra == 'all'
68
+ Requires-Dist: langchain ; extra == 'all'
69
+ Requires-Dist: pretty-errors ; extra == 'all'
80
70
  Requires-Dist: pymilvus ; extra == 'all'
81
- Requires-Dist: geopy ; extra == 'all'
82
- Requires-Dist: filetype ; extra == 'all'
83
71
  Requires-Dist: redis-py-cluster ; extra == 'all'
84
- Requires-Dist: sqlalchemy ; extra == 'all'
85
- Requires-Dist: thefuck ; extra == 'all'
86
- Requires-Dist: uvicorn ; extra == 'all'
87
- Requires-Dist: pymysql ; extra == 'all'
88
- Requires-Dist: dataframe-image ; extra == 'all'
89
- Requires-Dist: cachetools ; extra == 'all'
90
- Requires-Dist: fastapi ; extra == 'all'
91
- Requires-Dist: pretty-errors ; extra == 'all'
92
- Requires-Dist: openai ; extra == 'all'
72
+ Requires-Dist: pymongo ; extra == 'all'
73
+ Requires-Dist: jinja2 ; extra == 'all'
93
74
  Requires-Dist: missingno ; extra == 'all'
94
- Requires-Dist: gunicorn ; extra == 'all'
95
75
  Requires-Dist: seaborn ; extra == 'all'
76
+ Requires-Dist: iteration-utilities ; extra == 'all'
96
77
  Requires-Dist: reportlab ; extra == 'all'
78
+ Requires-Dist: fastapi ; extra == 'all'
79
+ Requires-Dist: uvicorn ; extra == 'all'
80
+ Requires-Dist: asyncmy ; extra == 'all'
81
+ Requires-Dist: pymysql ; extra == 'all'
97
82
  Requires-Dist: simplejson ; extra == 'all'
98
- Requires-Dist: jmespath ; extra == 'all'
83
+ Requires-Dist: geopy ; extra == 'all'
84
+ Requires-Dist: thefuck ; extra == 'all'
85
+ Requires-Dist: openai ; extra == 'all'
86
+ Requires-Dist: cachetools ; extra == 'all'
87
+ Requires-Dist: gunicorn ; extra == 'all'
88
+ Requires-Dist: thriftpy2 ; extra == 'all'
99
89
  Requires-Dist: jieba ; extra == 'all'
90
+ Requires-Dist: filetype ; extra == 'all'
91
+ Requires-Dist: streamlit ; extra == 'all'
92
+ Requires-Dist: sqlalchemy ; extra == 'all'
93
+ Requires-Dist: sse-starlette ; extra == 'all'
94
+ Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
95
+ Requires-Dist: faiss-cpu ; extra == 'all'
96
+ Requires-Dist: pyarrow ; extra == 'all'
97
+ Requires-Dist: pymupd ; extra == 'all'
98
+ Requires-Dist: dataframe-image ; extra == 'all'
99
+ Requires-Dist: jmespath ; extra == 'all'
100
100
  Provides-Extra: ann
101
101
  Requires-Dist: pymilvus ; extra == 'ann'
102
102
  Requires-Dist: faiss-cpu ; extra == 'ann'
@@ -419,11 +419,11 @@ meutils/async_task/__init__.py,sha256=45cUr-GWvQ1JFYGOYPOIkHLyTR3JbfP_PEYrmktpML
419
419
  meutils/async_task/celery_config.py,sha256=-p8-uGQq0HFFifZWZY6duCxEDcPJpWA4A_Rnz-WNysU,3430
420
420
  meutils/async_task/common.py,sha256=ZJ4e0CsEJf1ppPmGSwPCwhZBAkUL5xsi_t1ny-bJuko,845
421
421
  meutils/async_task/demo_create_tasks.py,sha256=p2CntKKd9tSrlfyx63uGu57SHQlu2x6XBi1u7y6LTYo,2577
422
- meutils/async_task/utils.py,sha256=IAcGmXUn-L7oJ-i66p-KJCtpNFMQY7lBXGe2ausNljg,3957
422
+ meutils/async_task/utils.py,sha256=pUatJfzU9Ir-QnMljeeOLAb52bil1siHy_k6rXjU53M,4506
423
423
  meutils/async_task/通用设计.py,sha256=kGdrJHJu9VoOkyGHREn0KUtBTibAaLIcG0O6hEJNhLA,3232
424
424
  meutils/async_task/tasks/__init__.py,sha256=flHRXJMdts_9az9T9V1c5l3Y-gaDD88COWrARr4WAKU,246
425
425
  meutils/async_task/tasks/_all.py,sha256=Vz63k9yvgj-IBGjekm0u2t571TTT0nMRMqcPvPqJAbY,533
426
- meutils/async_task/tasks/kling.py,sha256=4n898Xxv_TgohxqCbsfKt0Jkm6VL3nWY_QkHLckXEx8,925
426
+ meutils/async_task/tasks/kling.py,sha256=mqGQ4qtvQOyg7kmhk4AyZBfnFOQOoAFSuzYX5F6MyHo,1037
427
427
  meutils/async_task/tasks/replicateai.py,sha256=wbxx6kB7GQZPnKRE6J6r1mEv3wO8X7XaGaNMC5rBVoE,716
428
428
  meutils/async_task/tasks/test.py,sha256=-nCQhwEP6hQEnmk3ucDbjbnxbeyOHrg0HXCJmWL0KBU,2675
429
429
  meutils/async_task/tasks/vidu.py,sha256=obBG4_bf1oPIlLxeca1s1dGOnlyam2xYRy-8TrH3ZTk,620
@@ -460,7 +460,7 @@ meutils/config_utils/lark_utils/demo.py,sha256=3g0Fs7oLaeW75T60gYWMLgyNg1OnfOjfH
460
460
  meutils/config_utils/lark_utils/x.py,sha256=MlMQGhehP9xMEgetxVCX68XFaosfKoW1JA5cZ3JqN2w,1857
461
461
  meutils/crawlers/__init__.py,sha256=TBU4xA-IOsHV-0yIkW7YXxn_QT7TT8NncqxO7IykEfs,271
462
462
  meutils/data/SimHei.ttf,sha256=-XEnekS5yHP_URkT4XBI2w22ylV-KxudhkeIYFbrILA,10062565
463
- meutils/data/VERSION,sha256=aGC8mRV_oQWAoVWDqKoUJuo88h6T4MIMY59L-wrgihQ,19
463
+ meutils/data/VERSION,sha256=XKBonRtYezOE5KKAm-3wYxpPlf9vfguPCRly42EHiQc,19
464
464
  meutils/data/_FLAG,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
465
465
  meutils/data/_SUCCESS,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
466
466
  meutils/data/__init__.py,sha256=Hfwkkxs4zHqKhxht0YrhS566a9P5axtmgNvM5wF8ceQ,243
@@ -793,9 +793,9 @@ meutils/tools/seize.py,sha256=nOKAS63w-Lbi48I0m2MPhdsokUTwxco0laPxYVmW4Mw,1064
793
793
  meutils/tools/service_monitor.py,sha256=ibsLtBN2g2DL7ZnLJ8vhiZOiOcqTAyx711djDdBK-3M,1255
794
794
  meutils/tools/sys_monitor.py,sha256=6MoyzrItqDUOSjfHcMJmMofQkEPTW36CT_aKui0rg84,429
795
795
  meutils/tools/token_monitor.py,sha256=Np-YK-R4P4IPAXyZvMxwvXI4sFmNJQAQK1lSegNaYpA,997
796
- MeUtils-2024.11.29.20.47.50.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
797
- MeUtils-2024.11.29.20.47.50.dist-info/METADATA,sha256=kyZ8oVHhqv8yLAkY6_av_OSCXRm_GTP9KLPyZ8N11YE,6144
798
- MeUtils-2024.11.29.20.47.50.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
799
- MeUtils-2024.11.29.20.47.50.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
800
- MeUtils-2024.11.29.20.47.50.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
801
- MeUtils-2024.11.29.20.47.50.dist-info/RECORD,,
796
+ MeUtils-2024.11.29.21.20.15.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
797
+ MeUtils-2024.11.29.21.20.15.dist-info/METADATA,sha256=cgTfiiDYrdOixNxGiZ0Hy4Cn-IiTqRU1q8_q8u2hNK8,6144
798
+ MeUtils-2024.11.29.21.20.15.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
799
+ MeUtils-2024.11.29.21.20.15.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
800
+ MeUtils-2024.11.29.21.20.15.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
801
+ MeUtils-2024.11.29.21.20.15.dist-info/RECORD,,
@@ -19,8 +19,11 @@ from meutils.apis.kling import kolors_virtual_try_on
19
19
  @shared_task(pydantic=True, retry_kwargs={'max_retries': 5, 'countdown': 10})
20
20
  @async_to_sync_pro
21
21
  async def create_task(request: kolors_virtual_try_on.TryOnRequest, **kwargs):
22
+ if isinstance(request, dict):
23
+ request = kolors_virtual_try_on.TryOnRequest(**request)
24
+
22
25
  response = await kolors_virtual_try_on.create_task(request)
23
- return response
26
+ return response.model_dump()
24
27
 
25
28
 
26
29
  # celery_task
@@ -16,6 +16,11 @@ from meutils.schemas.task_types import TaskResponse
16
16
  from meutils.db.orm import update_or_insert
17
17
  from meutils.schemas.db.oneapi_types import OneapiTask
18
18
 
19
+ # 或者方案2:使用 BackgroundTasks
20
+ from fastapi import BackgroundTasks
21
+
22
+ background_tasks = BackgroundTasks()
23
+
19
24
 
20
25
  async def create_task(async_task, request: Union[BaseModel, dict]):
21
26
  if not isinstance(request, dict):
@@ -23,6 +28,7 @@ async def create_task(async_task, request: Union[BaseModel, dict]):
23
28
 
24
29
  result = async_task.apply_async(kwargs={"request": request})
25
30
  task_id = result.id
31
+
26
32
  return TaskResponse(task_id=task_id, request_id=task_id)
27
33
 
28
34
 
@@ -61,11 +67,17 @@ async def get_task(
61
67
 
62
68
  if result.ready():
63
69
  if result.successful():
64
- data = result.get() # TaskResponse
65
- token = data.pop("system_fingerprint", None) # 远程任务 token/apikey
70
+ data = result.get() # 创建任务时:remote task的返回结果
71
+
72
+ remote_task_id = (
73
+ data.get("task_id") # 远程任务 写在最外层
74
+ or data.get("id")
75
+ or data.get("request_id")
76
+ or data.get("data", {}).get("id")
77
+ or data.get("data", {}).get("task_id")
78
+ )
66
79
 
67
- # data.get('platform')
68
- # data.get('action')
80
+ token = data.pop("system_fingerprint", None) # 远程任务 token/apikey
69
81
 
70
82
  response = TaskResponse(
71
83
  task_id=task_id,
@@ -75,13 +87,13 @@ async def get_task(
75
87
  data=data
76
88
  )
77
89
 
78
- if remote_get_task: # 获取远程任务
79
- response: TaskResponse = await remote_get_task(task_id,
80
- token) # todo: 缓存一份,todo: user_id、platform/action
90
+ if remote_get_task: # 获取远程任务, todo: 判断函数类型
91
+ # todo: 缓存一份,todo: user_id、platform/action
92
+ remote_task_response = await remote_get_task(remote_task_id, token)
93
+ if not isinstance(remote_task_response, dict):
94
+ remote_task_response = remote_task_response.model_dump()
81
95
 
82
- if not isinstance(data, dict):
83
- data = data.model_dump()
84
- response.__dict__.update(data)
96
+ response.__dict__.update(remote_task_response) # 更新 response
85
97
 
86
98
  else:
87
99
  response = TaskResponse(
@@ -103,6 +115,8 @@ async def get_task(
103
115
  update_fn = partial(update_oneapi_from_response, task_response=response)
104
116
  asyncio.create_task(update_or_insert(OneapiTask, filter_kwargs, update_fn)) # 测试是否会执行
105
117
 
118
+ background_tasks.add_task(update_or_insert, OneapiTask, filter_kwargs, update_fn)
119
+
106
120
  return response
107
121
 
108
122
 
meutils/data/VERSION CHANGED
@@ -1 +1 @@
1
- 2024.11.29.20.47.50
1
+ 2024.11.29.21.20.15