fmtr.tools 1.3.28__py3-none-any.whl → 1.3.29__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 fmtr.tools might be problematic. Click here for more details.
- fmtr/tools/context_tools.py +23 -0
- fmtr/tools/function_tools.py +58 -0
- fmtr/tools/version +1 -1
- {fmtr_tools-1.3.28.dist-info → fmtr_tools-1.3.29.dist-info}/METADATA +46 -46
- {fmtr_tools-1.3.28.dist-info → fmtr_tools-1.3.29.dist-info}/RECORD +9 -8
- {fmtr_tools-1.3.28.dist-info → fmtr_tools-1.3.29.dist-info}/WHEEL +0 -0
- {fmtr_tools-1.3.28.dist-info → fmtr_tools-1.3.29.dist-info}/entry_points.txt +0 -0
- {fmtr_tools-1.3.28.dist-info → fmtr_tools-1.3.29.dist-info}/licenses/LICENSE +0 -0
- {fmtr_tools-1.3.28.dist-info → fmtr_tools-1.3.29.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from contextlib import contextmanager, ExitStack
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@contextmanager
|
|
5
|
+
def null():
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
Null context manager.
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
yield
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@contextmanager
|
|
15
|
+
def contexts(*contexts):
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
Tee context managers.
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
with ExitStack() as stack:
|
|
22
|
+
resources = [stack.enter_context(context) for context in contexts]
|
|
23
|
+
yield resources
|
fmtr/tools/function_tools.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import inspect
|
|
1
3
|
from typing import Tuple
|
|
2
4
|
|
|
5
|
+
from fmtr.tools import context_tools
|
|
6
|
+
|
|
3
7
|
|
|
4
8
|
def combine_args_kwargs(args: dict=None, kwargs: dict=None) -> dict:
|
|
5
9
|
"""
|
|
@@ -31,3 +35,57 @@ def split_args_kwargs(args_kwargs: dict) -> Tuple[list, dict]:
|
|
|
31
35
|
return args, kwargs
|
|
32
36
|
|
|
33
37
|
|
|
38
|
+
class BoundDecorator:
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
Bound method decorator with overridable start/stop and context manager
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, func):
|
|
46
|
+
self.func = func
|
|
47
|
+
self.context_null = context_tools.null()
|
|
48
|
+
functools.update_wrapper(self, func)
|
|
49
|
+
|
|
50
|
+
def get_context(self, instance):
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
By default use a null context.
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
return self.context_null
|
|
57
|
+
|
|
58
|
+
def __get__(self, instance, owner):
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
Wrap at runtime, call start/stop within context.
|
|
62
|
+
|
|
63
|
+
"""
|
|
64
|
+
if instance is None:
|
|
65
|
+
return self.func
|
|
66
|
+
|
|
67
|
+
if inspect.iscoroutinefunction(self.func):
|
|
68
|
+
async def async_wrapper(*args, **kwargs):
|
|
69
|
+
with self.get_context(instance):
|
|
70
|
+
self.start(instance)
|
|
71
|
+
result = await self.func(instance, *args, **kwargs)
|
|
72
|
+
self.stop(instance)
|
|
73
|
+
return result
|
|
74
|
+
|
|
75
|
+
return functools.update_wrapper(async_wrapper, self.func)
|
|
76
|
+
|
|
77
|
+
else:
|
|
78
|
+
def sync_wrapper(*args, **kwargs):
|
|
79
|
+
with self.get_context(instance):
|
|
80
|
+
self.start(instance)
|
|
81
|
+
result = self.func(instance, *args, **kwargs)
|
|
82
|
+
self.stop(instance)
|
|
83
|
+
return result
|
|
84
|
+
|
|
85
|
+
return functools.update_wrapper(sync_wrapper, self.func)
|
|
86
|
+
|
|
87
|
+
def start(self, instance):
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
def stop(self, instance):
|
|
91
|
+
pass
|
fmtr/tools/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.3.
|
|
1
|
+
1.3.29
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmtr.tools
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.29
|
|
4
4
|
Summary: Collection of high-level tools to simplify everyday development tasks, with a focus on AI/ML
|
|
5
5
|
Home-page: https://github.com/fmtr/fmtr.tools
|
|
6
6
|
Author: Frontmatter
|
|
@@ -126,61 +126,61 @@ Requires-Dist: logfire[httpx]; extra == "http"
|
|
|
126
126
|
Provides-Extra: setup
|
|
127
127
|
Requires-Dist: setuptools; extra == "setup"
|
|
128
128
|
Provides-Extra: all
|
|
129
|
-
Requires-Dist: pandas; extra == "all"
|
|
130
|
-
Requires-Dist: transformers[sentencepiece]; extra == "all"
|
|
131
|
-
Requires-Dist: regex; extra == "all"
|
|
132
|
-
Requires-Dist: pytest-cov; extra == "all"
|
|
133
|
-
Requires-Dist: json_repair; extra == "all"
|
|
134
|
-
Requires-Dist: cachetools; extra == "all"
|
|
135
|
-
Requires-Dist: tokenizers; extra == "all"
|
|
136
|
-
Requires-Dist: google-auth-oauthlib; extra == "all"
|
|
137
|
-
Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
|
|
138
129
|
Requires-Dist: httpx_retries; extra == "all"
|
|
139
|
-
Requires-Dist: docker; extra == "all"
|
|
140
|
-
Requires-Dist: pydantic; extra == "all"
|
|
141
|
-
Requires-Dist: setuptools; extra == "all"
|
|
142
|
-
Requires-Dist: deepmerge; extra == "all"
|
|
143
|
-
Requires-Dist: fastapi; extra == "all"
|
|
144
|
-
Requires-Dist: httpx; extra == "all"
|
|
145
|
-
Requires-Dist: openai; extra == "all"
|
|
146
|
-
Requires-Dist: google-api-python-client; extra == "all"
|
|
147
|
-
Requires-Dist: logfire; extra == "all"
|
|
148
|
-
Requires-Dist: pyyaml; extra == "all"
|
|
149
|
-
Requires-Dist: sre_yield; extra == "all"
|
|
150
|
-
Requires-Dist: flet[all]; extra == "all"
|
|
151
|
-
Requires-Dist: dask[bag]; extra == "all"
|
|
152
130
|
Requires-Dist: google-auth; extra == "all"
|
|
153
|
-
Requires-Dist:
|
|
154
|
-
Requires-Dist:
|
|
155
|
-
Requires-Dist:
|
|
131
|
+
Requires-Dist: openai; extra == "all"
|
|
132
|
+
Requires-Dist: google-auth-oauthlib; extra == "all"
|
|
133
|
+
Requires-Dist: transformers[sentencepiece]; extra == "all"
|
|
134
|
+
Requires-Dist: pymupdf; extra == "all"
|
|
135
|
+
Requires-Dist: faker; extra == "all"
|
|
136
|
+
Requires-Dist: cachetools; extra == "all"
|
|
137
|
+
Requires-Dist: tabulate; extra == "all"
|
|
138
|
+
Requires-Dist: huggingface_hub; extra == "all"
|
|
156
139
|
Requires-Dist: diskcache; extra == "all"
|
|
140
|
+
Requires-Dist: pydantic-settings; extra == "all"
|
|
141
|
+
Requires-Dist: filetype; extra == "all"
|
|
142
|
+
Requires-Dist: logfire[fastapi]; extra == "all"
|
|
143
|
+
Requires-Dist: pydantic; extra == "all"
|
|
144
|
+
Requires-Dist: torchaudio; extra == "all"
|
|
145
|
+
Requires-Dist: pandas; extra == "all"
|
|
146
|
+
Requires-Dist: distributed; extra == "all"
|
|
157
147
|
Requires-Dist: dnspython[doh]; extra == "all"
|
|
158
|
-
Requires-Dist:
|
|
148
|
+
Requires-Dist: regex; extra == "all"
|
|
149
|
+
Requires-Dist: sentence_transformers; extra == "all"
|
|
150
|
+
Requires-Dist: contexttimer; extra == "all"
|
|
159
151
|
Requires-Dist: google-auth-httplib2; extra == "all"
|
|
160
|
-
Requires-Dist:
|
|
161
|
-
Requires-Dist: pymupdf; extra == "all"
|
|
152
|
+
Requires-Dist: tinynetrc; extra == "all"
|
|
162
153
|
Requires-Dist: ollama; extra == "all"
|
|
163
|
-
Requires-Dist:
|
|
164
|
-
Requires-Dist:
|
|
154
|
+
Requires-Dist: docker; extra == "all"
|
|
155
|
+
Requires-Dist: logfire[httpx]; extra == "all"
|
|
156
|
+
Requires-Dist: dask[bag]; extra == "all"
|
|
157
|
+
Requires-Dist: yamlscript; extra == "all"
|
|
158
|
+
Requires-Dist: flet[all]; extra == "all"
|
|
159
|
+
Requires-Dist: peft; extra == "all"
|
|
160
|
+
Requires-Dist: pytest-cov; extra == "all"
|
|
161
|
+
Requires-Dist: fastapi; extra == "all"
|
|
162
|
+
Requires-Dist: deepmerge; extra == "all"
|
|
163
|
+
Requires-Dist: torchvision; extra == "all"
|
|
164
|
+
Requires-Dist: sre_yield; extra == "all"
|
|
165
|
+
Requires-Dist: tokenizers; extra == "all"
|
|
165
166
|
Requires-Dist: html2text; extra == "all"
|
|
166
|
-
Requires-Dist:
|
|
167
|
+
Requires-Dist: flet-webview; extra == "all"
|
|
168
|
+
Requires-Dist: appdirs; extra == "all"
|
|
169
|
+
Requires-Dist: json_repair; extra == "all"
|
|
170
|
+
Requires-Dist: google-api-python-client; extra == "all"
|
|
171
|
+
Requires-Dist: pyyaml; extra == "all"
|
|
172
|
+
Requires-Dist: logfire; extra == "all"
|
|
173
|
+
Requires-Dist: Unidecode; extra == "all"
|
|
174
|
+
Requires-Dist: semver; extra == "all"
|
|
175
|
+
Requires-Dist: setuptools; extra == "all"
|
|
176
|
+
Requires-Dist: bokeh; extra == "all"
|
|
177
|
+
Requires-Dist: openpyxl; extra == "all"
|
|
167
178
|
Requires-Dist: flet-video; extra == "all"
|
|
168
179
|
Requires-Dist: pymupdf4llm; extra == "all"
|
|
169
|
-
Requires-Dist:
|
|
170
|
-
Requires-Dist:
|
|
171
|
-
Requires-Dist: tinynetrc; extra == "all"
|
|
172
|
-
Requires-Dist: torchaudio; extra == "all"
|
|
180
|
+
Requires-Dist: httpx; extra == "all"
|
|
181
|
+
Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
|
|
173
182
|
Requires-Dist: uvicorn[standard]; extra == "all"
|
|
174
|
-
Requires-Dist:
|
|
175
|
-
Requires-Dist: yamlscript; extra == "all"
|
|
176
|
-
Requires-Dist: appdirs; extra == "all"
|
|
177
|
-
Requires-Dist: sentence_transformers; extra == "all"
|
|
178
|
-
Requires-Dist: pydantic-settings; extra == "all"
|
|
179
|
-
Requires-Dist: logfire[httpx]; extra == "all"
|
|
180
|
-
Requires-Dist: tabulate; extra == "all"
|
|
181
|
-
Requires-Dist: logfire[fastapi]; extra == "all"
|
|
182
|
-
Requires-Dist: contexttimer; extra == "all"
|
|
183
|
-
Requires-Dist: faker; extra == "all"
|
|
183
|
+
Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
|
|
184
184
|
Dynamic: author
|
|
185
185
|
Dynamic: author-email
|
|
186
186
|
Dynamic: description
|
|
@@ -4,13 +4,14 @@ fmtr/tools/async_tools.py,sha256=ewz757WcveQJd-G5SVr2JDOQVbdLGecCgl-tsBGVZz4,284
|
|
|
4
4
|
fmtr/tools/augmentation_tools.py,sha256=-6ESbO4CDlKqVOV1J1V6qBeoBMzbFIinkDHRHnCBej0,55
|
|
5
5
|
fmtr/tools/caching_tools.py,sha256=74p7m2GLFfeP41LX69wxgfkilxEAoWkMIfFMjKsYpyg,4976
|
|
6
6
|
fmtr/tools/constants.py,sha256=5pZ8TOrOwM2vmag6Db4CDCGxs6kAbzjhTi28NBii5eI,1590
|
|
7
|
+
fmtr/tools/context_tools.py,sha256=4UvIHYgLqAh7dXMX9EBrLEpYp81qfzhSVrkffOSAoGA,350
|
|
7
8
|
fmtr/tools/data_modelling_tools.py,sha256=0BFm-F_cYzVTxftWQwORkPd0FM2BTLVh9-s0-rTTFoo,1744
|
|
8
9
|
fmtr/tools/dataclass_tools.py,sha256=0Gt6KeLhtPgubo_2tYkIVqB8oQ91Qzag8OAGZDdjvMU,1209
|
|
9
10
|
fmtr/tools/datatype_tools.py,sha256=3P4AWIFGkJ-UqvXlj0Jc9IvkIIgTOE9jRrOk3NVbpH8,1508
|
|
10
11
|
fmtr/tools/debugging_tools.py,sha256=_xzqS0V5BpL8d06j-jVQjGgI7T020QsqVXKAKMz7Du8,2082
|
|
11
12
|
fmtr/tools/docker_tools.py,sha256=rdaZje2xhlmnfQqZnR7IHgRdWncTLjrJcViUTt5oEwk,617
|
|
12
13
|
fmtr/tools/environment_tools.py,sha256=jlx6LYFVv9tyNBT_pVD-tDhyR3ccNC7w6ENVlnoxCLM,1823
|
|
13
|
-
fmtr/tools/function_tools.py,sha256=
|
|
14
|
+
fmtr/tools/function_tools.py,sha256=fbOCk2_o9RB1Eps7lrduf7nm93a1H62w9Z49x2FvAWA,2375
|
|
14
15
|
fmtr/tools/google_api_tools.py,sha256=owWE0GlnJjmVbXus8ENxT2PH7Fnd3m_r-14xyR7lAnA,1107
|
|
15
16
|
fmtr/tools/hash_tools.py,sha256=tr4HXpeT6rRrDk6TvMlRPUSrLRRaov96y128OI2tzsc,729
|
|
16
17
|
fmtr/tools/hfh_tools.py,sha256=DCDIWuWlhtmIGCtp9cLcOTTEw_4yN_NocLX8w5NZsbk,2384
|
|
@@ -44,7 +45,7 @@ fmtr/tools/tabular_tools.py,sha256=tpIpZzYku1HcJrHZJL6BC39LmN3WUWVhFbK2N7nDVmE,1
|
|
|
44
45
|
fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
|
|
45
46
|
fmtr/tools/tools.py,sha256=CAsApa1YwVdNE6H66Vjivs_mXYvOas3rh7fPELAnTpk,795
|
|
46
47
|
fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
|
|
47
|
-
fmtr/tools/version,sha256=
|
|
48
|
+
fmtr/tools/version,sha256=NUTl8Yr_rYvLMHb0tH-4fCfEhIlAfyA63OegFPMrwgc,6
|
|
48
49
|
fmtr/tools/yaml_tools.py,sha256=Bhhyd6GQVKO72Lp8ky7bAUjIB_65Hdh0Q45SKIEe6S8,1901
|
|
49
50
|
fmtr/tools/ai_tools/__init__.py,sha256=JZrLuOFNV1A3wvJgonxOgz_4WS-7MfCuowGWA5uYCjs,372
|
|
50
51
|
fmtr/tools/ai_tools/agentic_tools.py,sha256=acSEPFS-aguDXanWGs3fAAlRyJSYPZW7L-Kb2qDLm-I,4300
|
|
@@ -79,9 +80,9 @@ fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g
|
|
|
79
80
|
fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
|
|
80
81
|
fmtr/tools/version_tools/__init__.py,sha256=pg4iLtmIr5HtyEW_j0fMFoIdzqi_w9xH8-grQaXLB28,318
|
|
81
82
|
fmtr/tools/version_tools/version_tools.py,sha256=Hcc6yferZS1hHbugRTdiHhSNmXEEG0hjCiTTXKna-YY,1127
|
|
82
|
-
fmtr_tools-1.3.
|
|
83
|
-
fmtr_tools-1.3.
|
|
84
|
-
fmtr_tools-1.3.
|
|
85
|
-
fmtr_tools-1.3.
|
|
86
|
-
fmtr_tools-1.3.
|
|
87
|
-
fmtr_tools-1.3.
|
|
83
|
+
fmtr_tools-1.3.29.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
|
|
84
|
+
fmtr_tools-1.3.29.dist-info/METADATA,sha256=6HSn_2iCjQC37aDMtMZ_Ebm8c9Bw1WrEaDUODBRpfn0,15938
|
|
85
|
+
fmtr_tools-1.3.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
86
|
+
fmtr_tools-1.3.29.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
|
|
87
|
+
fmtr_tools-1.3.29.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
|
|
88
|
+
fmtr_tools-1.3.29.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|