fmtr.tools 1.3.26__py3-none-any.whl → 1.3.28__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/__init__.py CHANGED
@@ -6,6 +6,7 @@ import fmtr.tools.environment_tools as environment
6
6
  import fmtr.tools.function_tools as function
7
7
  import fmtr.tools.hash_tools as hash
8
8
  import fmtr.tools.import_tools as import_
9
+ import fmtr.tools.inherit_tools as inherit
9
10
  import fmtr.tools.iterator_tools as iterator
10
11
  import fmtr.tools.json_tools as json
11
12
  import fmtr.tools.logging_tools as logging
fmtr/tools/constants.py CHANGED
@@ -49,3 +49,5 @@ class Constants:
49
49
  PRODUCTION = "production"
50
50
 
51
51
  INFRA = 'infra'
52
+
53
+ PROMPT_NOT_SPECIFIED = '[None Specified]'
@@ -0,0 +1,27 @@
1
+ from typing import TypeVar, Generic
2
+
3
+ T = TypeVar("T")
4
+
5
+
6
+ class Inherit(Generic[T]):
7
+ """
8
+
9
+ Runtime inheritance. Acts like a wrapper around an instantiated base class of type T, and allows overriding methods in subclasses like regular inheritance.
10
+
11
+ """
12
+
13
+ def __init__(self, parent: T):
14
+ """
15
+
16
+ Set parent
17
+
18
+ """
19
+ object.__setattr__(self, "_parent", parent)
20
+
21
+ def __getattr__(self, name):
22
+ """
23
+
24
+ Since regular attribute access checks own methods first, we don't need to do anything fancy to fall back to the parent when not implemented.
25
+
26
+ """
27
+ return getattr(self._parent, name)
@@ -1,35 +1,32 @@
1
+ import inspect
2
+
1
3
  import flet as ft
2
4
 
3
5
 
4
- class ContextRing(ft.ProgressRing):
6
+ class ContextBase:
5
7
  """
6
8
 
7
- Context manager progress ring.
9
+ A mixin base that can be used as both a synchronous and asynchronous context manager,
10
+ or as a decorator to wrap synchronous or asynchronous functions.
11
+ The control becomes visible when entering the context or invoking the wrapped function,
12
+ and is hidden again when exiting.
8
13
 
9
14
  """
10
15
 
11
- def __init__(self, *args, **kwargs):
12
- """
13
-
14
- Start out not visible.
15
-
16
- """
17
- super().__init__(*args, **kwargs, visible=False)
18
-
19
16
  def start(self):
20
17
  """
21
18
 
22
- Update to visible when in context.
23
-
19
+ Show the control and update the page.
24
20
  """
21
+
25
22
  self.visible = True
26
23
  self.page.update()
27
24
 
28
25
  def stop(self):
29
26
  """
30
27
 
31
- Update to not visible when exiting context.
32
-
28
+ Hide the control and update the page.
29
+
33
30
  """
34
31
  self.visible = False
35
32
  self.page.update()
@@ -37,38 +34,92 @@ class ContextRing(ft.ProgressRing):
37
34
  def context(self, func):
38
35
  """
39
36
 
40
- Context manager decorator.
37
+ Decorator that wraps a synchronous or asynchronous function.
38
+ While the function runs, the control is visible.
41
39
 
42
40
  """
41
+ if inspect.iscoroutinefunction(func):
42
+ async def async_wrapped(*args, **kwargs):
43
+ async with self:
44
+ return await func(*args, **kwargs)
43
45
 
44
- def wrapped(*args, **kwargs):
45
- with self:
46
- func(*args, **kwargs)
46
+ return async_wrapped
47
+ else:
48
+ def sync_wrapped(*args, **kwargs):
49
+ with self:
50
+ return func(*args, **kwargs)
47
51
 
48
- return wrapped
52
+ return sync_wrapped
49
53
 
50
54
  def __enter__(self):
55
+ """
56
+
57
+ Enter the control context (sync).
58
+
59
+ """
51
60
  self.start()
52
61
  return self
53
62
 
54
63
  def __exit__(self, exc_type, exc_val, exc_tb):
64
+ """
65
+
66
+ Exit the control context (sync).
67
+
68
+ """
55
69
  self.stop()
56
70
 
71
+ async def __aenter__(self):
72
+ """
73
+
74
+ Enter the control context (async).
75
+ """
76
+
77
+ result = self.start()
78
+ if inspect.isawaitable(result):
79
+ await result
80
+ return self
81
+
82
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
83
+ """
84
+
85
+ Exit the control context (async).
86
+ """
87
+
88
+ result = self.stop()
89
+ if inspect.isawaitable(result):
90
+ await result
91
+
92
+
93
+ class ContextRing(ft.ProgressRing, ContextBase):
94
+ """
95
+
96
+ A progress ring as a context manager.
97
+
98
+ """
99
+
100
+ def __init__(self, *args, **kwargs):
101
+ """
102
+
103
+ Initialize the progress ring as hidden by default.
104
+
105
+ """
106
+ super().__init__(*args, **kwargs, visible=False)
57
107
 
58
108
  class ProgressButton(ft.Button):
59
109
  """
60
110
 
61
- Button with progress ring.
111
+ Button containing a progress ring.
62
112
 
63
113
  """
64
114
 
65
- def __init__(self, *args, on_click=None, **kwargs):
115
+ def __init__(self, *args, on_click=None, ring: ContextRing = None, **kwargs):
66
116
  """
67
117
 
68
118
  Run on_click in run context manager
69
119
 
70
120
  """
71
- self.ring = ContextRing()
121
+ self.ring = ring or ContextRing()
122
+
72
123
  super().__init__(*args, content=self.ring, on_click=self.ring.context(on_click), **kwargs)
73
124
  self.context = self.ring.context
74
125
 
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.3.26
1
+ 1.3.28
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.3.26
3
+ Version: 1.3.28
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: logfire[httpx]; extra == "all"
130
- Requires-Dist: dask[bag]; extra == "all"
131
- Requires-Dist: logfire[fastapi]; extra == "all"
132
- Requires-Dist: httpx; extra == "all"
133
- Requires-Dist: google-auth; extra == "all"
134
- Requires-Dist: tabulate; extra == "all"
135
- Requires-Dist: diskcache; extra == "all"
136
- Requires-Dist: sre_yield; extra == "all"
137
- Requires-Dist: yamlscript; extra == "all"
138
- Requires-Dist: sentence_transformers; extra == "all"
139
- Requires-Dist: uvicorn[standard]; 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"
140
134
  Requires-Dist: cachetools; extra == "all"
141
- Requires-Dist: httpx_retries; extra == "all"
142
- Requires-Dist: docker; extra == "all"
143
- Requires-Dist: pymupdf; extra == "all"
144
- Requires-Dist: distributed; extra == "all"
145
- Requires-Dist: peft; extra == "all"
146
- Requires-Dist: fastapi; extra == "all"
147
- Requires-Dist: flet-video; extra == "all"
148
135
  Requires-Dist: tokenizers; extra == "all"
149
- Requires-Dist: pytest-cov; extra == "all"
150
- Requires-Dist: faker; extra == "all"
151
- Requires-Dist: contexttimer; extra == "all"
152
136
  Requires-Dist: google-auth-oauthlib; extra == "all"
153
- Requires-Dist: huggingface_hub; extra == "all"
154
- Requires-Dist: logfire; extra == "all"
155
- Requires-Dist: deepmerge; extra == "all"
156
- Requires-Dist: tinynetrc; extra == "all"
157
- Requires-Dist: bokeh; extra == "all"
158
- Requires-Dist: torchaudio; extra == "all"
159
- Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
160
- Requires-Dist: html2text; extra == "all"
161
- Requires-Dist: flet[all]; extra == "all"
162
- Requires-Dist: google-auth-httplib2; extra == "all"
163
- Requires-Dist: regex; extra == "all"
164
- Requires-Dist: appdirs; extra == "all"
165
- Requires-Dist: pydantic-settings; extra == "all"
166
- Requires-Dist: pandas; extra == "all"
167
- Requires-Dist: pydantic; extra == "all"
168
137
  Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
169
- Requires-Dist: Unidecode; extra == "all"
138
+ 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"
170
145
  Requires-Dist: openai; extra == "all"
171
146
  Requires-Dist: google-api-python-client; extra == "all"
172
- Requires-Dist: dnspython[doh]; extra == "all"
173
- Requires-Dist: pymupdf4llm; extra == "all"
174
- Requires-Dist: setuptools; extra == "all"
175
- Requires-Dist: filetype; extra == "all"
176
- Requires-Dist: transformers[sentencepiece]; 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
+ Requires-Dist: google-auth; extra == "all"
153
+ Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
177
154
  Requires-Dist: flet-webview; extra == "all"
178
- Requires-Dist: openpyxl; extra == "all"
179
- Requires-Dist: json_repair; extra == "all"
180
- Requires-Dist: semver; extra == "all"
181
155
  Requires-Dist: torchvision; extra == "all"
182
- Requires-Dist: pyyaml; extra == "all"
156
+ Requires-Dist: diskcache; extra == "all"
157
+ Requires-Dist: dnspython[doh]; extra == "all"
158
+ Requires-Dist: bokeh; extra == "all"
159
+ Requires-Dist: google-auth-httplib2; extra == "all"
160
+ Requires-Dist: peft; extra == "all"
161
+ Requires-Dist: pymupdf; extra == "all"
183
162
  Requires-Dist: ollama; extra == "all"
163
+ Requires-Dist: semver; extra == "all"
164
+ Requires-Dist: filetype; extra == "all"
165
+ Requires-Dist: html2text; extra == "all"
166
+ Requires-Dist: huggingface_hub; extra == "all"
167
+ Requires-Dist: flet-video; extra == "all"
168
+ Requires-Dist: pymupdf4llm; extra == "all"
169
+ Requires-Dist: Unidecode; extra == "all"
170
+ Requires-Dist: distributed; extra == "all"
171
+ Requires-Dist: tinynetrc; extra == "all"
172
+ Requires-Dist: torchaudio; extra == "all"
173
+ Requires-Dist: uvicorn[standard]; extra == "all"
174
+ Requires-Dist: openpyxl; extra == "all"
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"
184
184
  Dynamic: author
185
185
  Dynamic: author-email
186
186
  Dynamic: description
@@ -1,9 +1,9 @@
1
- fmtr/tools/__init__.py,sha256=9wmfLcYMilcfMS5NfOnaxUn7qxT4YZJ0MFwzOxeh-cQ,5625
1
+ fmtr/tools/__init__.py,sha256=02EgGggVmiHs81W5gXGX49F53DZO956jGwrFUMHmUTo,5668
2
2
  fmtr/tools/api_tools.py,sha256=RyZUlTefSQozfl-8feZGauyUkwcFd-jU0KtKHFxHea4,2272
3
3
  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
- fmtr/tools/constants.py,sha256=6kFaD7ZI7rflaVFfSAtVi0pMrMtNYhWhKNkfV3lBd60,1543
6
+ fmtr/tools/constants.py,sha256=5pZ8TOrOwM2vmag6Db4CDCGxs6kAbzjhTi28NBii5eI,1590
7
7
  fmtr/tools/data_modelling_tools.py,sha256=0BFm-F_cYzVTxftWQwORkPd0FM2BTLVh9-s0-rTTFoo,1744
8
8
  fmtr/tools/dataclass_tools.py,sha256=0Gt6KeLhtPgubo_2tYkIVqB8oQ91Qzag8OAGZDdjvMU,1209
9
9
  fmtr/tools/datatype_tools.py,sha256=3P4AWIFGkJ-UqvXlj0Jc9IvkIIgTOE9jRrOk3NVbpH8,1508
@@ -17,6 +17,7 @@ fmtr/tools/hfh_tools.py,sha256=DCDIWuWlhtmIGCtp9cLcOTTEw_4yN_NocLX8w5NZsbk,2384
17
17
  fmtr/tools/html_tools.py,sha256=0nN8Nz5HtG9bXyApYfHSKEivLlxjsm3Gn6Mg2TK0brI,394
18
18
  fmtr/tools/http_tools.py,sha256=RVwGrBNMyjfbpgAPCSnxEkXfSzXXWARb3ayq981ONQE,464
19
19
  fmtr/tools/import_tools.py,sha256=XJmiWLukRncJAcaGReDn4jIz1_IpVBjfYCQHH1hIg7c,588
20
+ fmtr/tools/inherit_tools.py,sha256=gTGL4mRm5RsbFW76s25AbuAJ2vlymbh1c8Q4Hl2uJGU,646
20
21
  fmtr/tools/inspection_tools.py,sha256=tLTRvzy9XVomQPi0dfnF_cgwc7KiDVZAr7gPTk4S_bQ,278
21
22
  fmtr/tools/iterator_tools.py,sha256=xj5f0c7LgLK53dddRRRJxBoLaBzlZoQS3_GfmpDPMoo,1311
22
23
  fmtr/tools/json_fix_tools.py,sha256=vNSlswVQnujPmKEqDjFJcO901mjMyv59q3awsT7mlhs,477
@@ -43,7 +44,7 @@ fmtr/tools/tabular_tools.py,sha256=tpIpZzYku1HcJrHZJL6BC39LmN3WUWVhFbK2N7nDVmE,1
43
44
  fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
44
45
  fmtr/tools/tools.py,sha256=CAsApa1YwVdNE6H66Vjivs_mXYvOas3rh7fPELAnTpk,795
45
46
  fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
46
- fmtr/tools/version,sha256=hS5wAr_5edPJvBlKaOvwuUi2O2fdFTHx-Jl3gWrRcC0,6
47
+ fmtr/tools/version,sha256=hB4hPTrMm7kC-t2byIDYHLFsV_U0EwN4tgRl22GNPUI,6
47
48
  fmtr/tools/yaml_tools.py,sha256=Bhhyd6GQVKO72Lp8ky7bAUjIB_65Hdh0Q45SKIEe6S8,1901
48
49
  fmtr/tools/ai_tools/__init__.py,sha256=JZrLuOFNV1A3wvJgonxOgz_4WS-7MfCuowGWA5uYCjs,372
49
50
  fmtr/tools/ai_tools/agentic_tools.py,sha256=acSEPFS-aguDXanWGs3fAAlRyJSYPZW7L-Kb2qDLm-I,4300
@@ -60,7 +61,7 @@ fmtr/tools/entrypoints/install_yamlscript.py,sha256=D9-QET4uPkwMvOBQJAgzn1fYb7Z7
60
61
  fmtr/tools/entrypoints/remote_debug_test.py,sha256=wmKg9o2pQq7eqeHmaO8oviujNgtnsCVEXOdXLIcQWs4,123
61
62
  fmtr/tools/entrypoints/shell_debug.py,sha256=0No3tAg9Ri4_vvSlQCUtAY-11HR0nE45i0VVtiAViwY,106
62
63
  fmtr/tools/interface_tools/__init__.py,sha256=RBg-QC7OO-PdAbFBadzHTzgjASchrKavAqdVbmBq4nM,310
63
- fmtr/tools/interface_tools/controls.py,sha256=C0aE839EnA8tLQN0e2VHRbjCiCp73-3HuW_ceKiK8tQ,1620
64
+ fmtr/tools/interface_tools/controls.py,sha256=W5gVzxLqgiqVp4Ryr3UR4Yrtmoz5IeDpl9hw3Sld2W8,2991
64
65
  fmtr/tools/interface_tools/interface_tools.py,sha256=FBvtWSGFvgieDT-cOSY9KAW6csnObFKyj8O-QnsekE4,2252
65
66
  fmtr/tools/path_tools/__init__.py,sha256=v5CpmzXq5Ii90FtcmxAJKiLxmguZMrPnQ_HdT872Np0,443
66
67
  fmtr/tools/path_tools/app_path_tools.py,sha256=JrJvtTDd_gkCKcZtBCDTMktsM77PZwGV_hzQX0g5GU8,1722
@@ -78,9 +79,9 @@ fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g
78
79
  fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
79
80
  fmtr/tools/version_tools/__init__.py,sha256=pg4iLtmIr5HtyEW_j0fMFoIdzqi_w9xH8-grQaXLB28,318
80
81
  fmtr/tools/version_tools/version_tools.py,sha256=Hcc6yferZS1hHbugRTdiHhSNmXEEG0hjCiTTXKna-YY,1127
81
- fmtr_tools-1.3.26.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
82
- fmtr_tools-1.3.26.dist-info/METADATA,sha256=NPa0iGerC4VdBPNEfmWWUotvqUz0V2ROXbpf5GzB_0o,15938
83
- fmtr_tools-1.3.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
- fmtr_tools-1.3.26.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
85
- fmtr_tools-1.3.26.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
86
- fmtr_tools-1.3.26.dist-info/RECORD,,
82
+ fmtr_tools-1.3.28.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
83
+ fmtr_tools-1.3.28.dist-info/METADATA,sha256=f4cjWEN5Vu2NGLtPGmdzwBZWEiMcyI2m1n0P9Nqm72o,15938
84
+ fmtr_tools-1.3.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
85
+ fmtr_tools-1.3.28.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
86
+ fmtr_tools-1.3.28.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
87
+ fmtr_tools-1.3.28.dist-info/RECORD,,