ygo 1.2.1__py3-none-any.whl → 1.2.2__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.
Potentially problematic release.
This version of ygo might be problematic. Click here for more details.
- ygo/__init__.py +2 -10
- ygo/lazy.py +2 -2
- ygo/pool.py +2 -2
- ygo/utils.py +59 -0
- {ygo-1.2.1.dist-info → ygo-1.2.2.dist-info}/METADATA +1 -2
- ygo-1.2.2.dist-info/RECORD +11 -0
- ygo-1.2.1.dist-info/RECORD +0 -11
- {ygo-1.2.1.dist-info → ygo-1.2.2.dist-info}/WHEEL +0 -0
- {ygo-1.2.1.dist-info → ygo-1.2.2.dist-info}/licenses/LICENSE +0 -0
- {ygo-1.2.1.dist-info → ygo-1.2.2.dist-info}/top_level.txt +0 -0
ygo/__init__.py
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
---------------------------------------------
|
|
4
|
-
Created on 2025/4/28 15:25
|
|
5
|
-
@author: ZhangYundi
|
|
6
|
-
@email: yundi.xxii@outlook.com
|
|
7
|
-
---------------------------------------------
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
1
|
from .exceptions import FailTaskError, WarnException
|
|
11
2
|
from .pool import pool
|
|
12
3
|
from .delay import delay
|
|
@@ -18,10 +9,11 @@ from .utils import (
|
|
|
18
9
|
fn_info,
|
|
19
10
|
module_from_str,
|
|
20
11
|
fn_from_str,
|
|
12
|
+
locate,
|
|
21
13
|
)
|
|
22
14
|
from .lazy import lazy_import
|
|
23
15
|
|
|
24
|
-
__version__ = "1.2.
|
|
16
|
+
__version__ = "1.2.2"
|
|
25
17
|
|
|
26
18
|
__all__ = [
|
|
27
19
|
"FailTaskError",
|
ygo/lazy.py
CHANGED
|
@@ -10,7 +10,7 @@ Description:
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
from typing import Any
|
|
13
|
-
from
|
|
13
|
+
from .utils import locate
|
|
14
14
|
|
|
15
15
|
class LazyImport:
|
|
16
16
|
def __init__(self, full_name: str):
|
|
@@ -19,7 +19,7 @@ class LazyImport:
|
|
|
19
19
|
|
|
20
20
|
def _load(self) -> Any:
|
|
21
21
|
if self._obj is None:
|
|
22
|
-
self._obj =
|
|
22
|
+
self._obj = locate(self._full_name)
|
|
23
23
|
return self._obj
|
|
24
24
|
|
|
25
25
|
def __getattr__(self, attr: str) -> Any:
|
ygo/pool.py
CHANGED
|
@@ -12,7 +12,7 @@ import threading
|
|
|
12
12
|
import warnings
|
|
13
13
|
|
|
14
14
|
from joblib import Parallel, delayed
|
|
15
|
-
import
|
|
15
|
+
import logair
|
|
16
16
|
from .exceptions import WarnException, FailTaskError
|
|
17
17
|
from .delay import delay
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ with warnings.catch_warnings():
|
|
|
20
20
|
warnings.simplefilter("ignore")
|
|
21
21
|
from tqdm.auto import tqdm
|
|
22
22
|
|
|
23
|
-
logger =
|
|
23
|
+
logger = logair.get_logger("ygo")
|
|
24
24
|
|
|
25
25
|
def run_job(job, task_id, queue):
|
|
26
26
|
"""执行任务并更新队列"""
|
ygo/utils.py
CHANGED
|
@@ -12,6 +12,8 @@ import os
|
|
|
12
12
|
from functools import wraps
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
import warnings
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
15
17
|
from .delay import delay
|
|
16
18
|
|
|
17
19
|
def deprecated(use_instead: str = None):
|
|
@@ -169,3 +171,60 @@ def module_from_str(s):
|
|
|
169
171
|
m_path = ".".join(s.split('.'))
|
|
170
172
|
mod = importlib.import_module(m_path)
|
|
171
173
|
return mod
|
|
174
|
+
|
|
175
|
+
def locate(path: str) -> Any:
|
|
176
|
+
"""
|
|
177
|
+
Notes
|
|
178
|
+
-----
|
|
179
|
+
Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
|
180
|
+
|
|
181
|
+
Locate an object by name or dotted path, importing as necessary.
|
|
182
|
+
This is similar to the pydoc function `locate`, except that it checks for
|
|
183
|
+
the module from the given path from back to front.
|
|
184
|
+
"""
|
|
185
|
+
if path == "":
|
|
186
|
+
raise ImportError("Empty path")
|
|
187
|
+
from importlib import import_module
|
|
188
|
+
from types import ModuleType
|
|
189
|
+
|
|
190
|
+
parts = [part for part in path.split(".")]
|
|
191
|
+
for part in parts:
|
|
192
|
+
if not len(part):
|
|
193
|
+
raise ValueError(
|
|
194
|
+
f"Error loading '{path}': invalid dotstring."
|
|
195
|
+
+ "\nRelative imports are not supported."
|
|
196
|
+
)
|
|
197
|
+
assert len(parts) > 0
|
|
198
|
+
part0 = parts[0]
|
|
199
|
+
try:
|
|
200
|
+
obj = import_module(part0)
|
|
201
|
+
except Exception as exc_import:
|
|
202
|
+
raise ImportError(
|
|
203
|
+
f"Error loading '{path}':\n{repr(exc_import)}"
|
|
204
|
+
+ f"\nAre you sure that module '{part0}' is installed?"
|
|
205
|
+
) from exc_import
|
|
206
|
+
for m in range(1, len(parts)):
|
|
207
|
+
part = parts[m]
|
|
208
|
+
try:
|
|
209
|
+
obj = getattr(obj, part)
|
|
210
|
+
except AttributeError as exc_attr:
|
|
211
|
+
parent_dotpath = ".".join(parts[:m])
|
|
212
|
+
if isinstance(obj, ModuleType):
|
|
213
|
+
mod = ".".join(parts[: m + 1])
|
|
214
|
+
try:
|
|
215
|
+
obj = import_module(mod)
|
|
216
|
+
continue
|
|
217
|
+
except ModuleNotFoundError as exc_import:
|
|
218
|
+
raise ImportError(
|
|
219
|
+
f"Error loading '{path}':\n{repr(exc_import)}"
|
|
220
|
+
+ f"\nAre you sure that '{part}' is importable from module '{parent_dotpath}'?"
|
|
221
|
+
) from exc_import
|
|
222
|
+
except Exception as exc_import:
|
|
223
|
+
raise ImportError(
|
|
224
|
+
f"Error loading '{path}':\n{repr(exc_import)}"
|
|
225
|
+
) from exc_import
|
|
226
|
+
raise ImportError(
|
|
227
|
+
f"Error loading '{path}':\n{repr(exc_attr)}"
|
|
228
|
+
+ f"\nAre you sure that '{part}' is an attribute of '{parent_dotpath}'?"
|
|
229
|
+
) from exc_attr
|
|
230
|
+
return obj
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ygo
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: 一个轻量级 Python 工具包,支持 并发执行(带进度条)、延迟调用、链式绑定参数、函数信息获取、模块/函数动态加载。并结合 ylog 提供日志记录能力
|
|
5
5
|
Project-URL: homepage, https://github.com/link-yundi/ygo
|
|
6
6
|
Project-URL: repository, https://github.com/link-yundi/ygo
|
|
7
7
|
Requires-Python: >=3.12
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Requires-Dist: hydra-core>=1.3.2
|
|
11
10
|
Requires-Dist: joblib>=1.5.0
|
|
12
11
|
Requires-Dist: logair>=1.0.0
|
|
13
12
|
Requires-Dist: tqdm>=4.67.1
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
ygo/__init__.py,sha256=07iVluTLno91MFhAoKWRlZIxl2ll7huPTvYS5WCsxbw,536
|
|
2
|
+
ygo/delay.py,sha256=66xtPXqyD630FL7LWL5qJKAIZvyGDwZyM4qPfk8Czlg,2206
|
|
3
|
+
ygo/exceptions.py,sha256=0OYDYt_9KKo8mF2XBG5QkCMr3-ASp69VDSPOEwlIsrI,660
|
|
4
|
+
ygo/lazy.py,sha256=NRE38vWKfA19fTRIbgCypdoxXhJulDtHMd7jw6CzhUc,1303
|
|
5
|
+
ygo/pool.py,sha256=fUl_v4GOU310TDqfpUPNJdjovCZwkbBP5xUdqd8jZvk,7095
|
|
6
|
+
ygo/utils.py,sha256=45ZM7FUraDA69jwf1arbBuuS-a0wMVf9sT7ma5bGd4E,6224
|
|
7
|
+
ygo-1.2.2.dist-info/licenses/LICENSE,sha256=6AKUWQ1xe-jwPSFv_H6FMQLNNWb7AYqzuEUTwlP2S8M,1067
|
|
8
|
+
ygo-1.2.2.dist-info/METADATA,sha256=EJ9sZyLDIbET52fq06GTI1MknSUDwnYcDeJQy-7a6kc,4844
|
|
9
|
+
ygo-1.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
ygo-1.2.2.dist-info/top_level.txt,sha256=4E07GOD3KS5--r4rP13upXfTEgk3JGJpQmMkdkJ4t74,4
|
|
11
|
+
ygo-1.2.2.dist-info/RECORD,,
|
ygo-1.2.1.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
ygo/__init__.py,sha256=GTzTj7-07IBBiWq4hUFZ1qWgDjK6DK0DKUaoc5bwZv8,727
|
|
2
|
-
ygo/delay.py,sha256=66xtPXqyD630FL7LWL5qJKAIZvyGDwZyM4qPfk8Czlg,2206
|
|
3
|
-
ygo/exceptions.py,sha256=0OYDYt_9KKo8mF2XBG5QkCMr3-ASp69VDSPOEwlIsrI,660
|
|
4
|
-
ygo/lazy.py,sha256=IwWOv3zYWGGuFefvZwZyP-zokyB4EnQWmySstSk3dJg,1320
|
|
5
|
-
ygo/pool.py,sha256=mnao2KtJUKgjSfqdCSZVVGXPrrz_0W-0OzBUjFKsVjk,7093
|
|
6
|
-
ygo/utils.py,sha256=paeYb8TwonIaDwusE6YV9v_-Y-WzVjGgSa_c1mblw3Y,4040
|
|
7
|
-
ygo-1.2.1.dist-info/licenses/LICENSE,sha256=6AKUWQ1xe-jwPSFv_H6FMQLNNWb7AYqzuEUTwlP2S8M,1067
|
|
8
|
-
ygo-1.2.1.dist-info/METADATA,sha256=RR16W4wEyOYoGD_B-8gw1r8mYsAENSlRsPMYvSXhIQM,4877
|
|
9
|
-
ygo-1.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
ygo-1.2.1.dist-info/top_level.txt,sha256=4E07GOD3KS5--r4rP13upXfTEgk3JGJpQmMkdkJ4t74,4
|
|
11
|
-
ygo-1.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|