fmtr.tools 1.3.50__py3-none-any.whl → 1.3.52__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.

@@ -1,7 +1,7 @@
1
1
  from fmtr.tools.import_tools import MissingExtraMockModule
2
2
 
3
3
  try:
4
- from fmtr.tools.interface_tools.interface_tools import Interface, update, progress
4
+ from fmtr.tools.interface_tools.interface_tools import Base, update, progress
5
5
  from fmtr.tools.interface_tools import controls
6
6
  from fmtr.tools.interface_tools.context import Context
7
7
  except ModuleNotFoundError as exception:
@@ -1,8 +1,9 @@
1
+ from typing import TypeVar, Generic, Type
2
+
1
3
  import flet as ft
4
+ from flet.core.control_event import ControlEvent
2
5
  from flet.core.types import AppView
3
6
  from flet.core.view import View
4
- from functools import cached_property
5
- from typing import TypeVar, Generic, Type, Self
6
7
 
7
8
  from fmtr.tools import environment_tools
8
9
  from fmtr.tools.constants import Constants
@@ -18,7 +19,7 @@ class update(MethodDecorator):
18
19
 
19
20
  """
20
21
 
21
- def stop(self, instance):
22
+ def stop(self, instance, *args, **kwargs):
22
23
  instance.page.update()
23
24
 
24
25
 
@@ -37,7 +38,7 @@ class progress(update):
37
38
  """
38
39
  return instance.context
39
40
 
40
- def start(self, instance):
41
+ def start(self, instance, *args, **kwargs):
41
42
  """
42
43
 
43
44
  Make progress visible and update.
@@ -46,7 +47,7 @@ class progress(update):
46
47
  instance.progress.visible = True
47
48
  instance.page.update()
48
49
 
49
- def stop(self, instance):
50
+ def stop(self, instance, *args, **kwargs):
50
51
  """
51
52
 
52
53
  Make progress not visible and update.
@@ -59,7 +60,7 @@ class progress(update):
59
60
  T = TypeVar('T', bound=Context)
60
61
 
61
62
 
62
- class Interface(Generic[T], ft.Column):
63
+ class Base(Generic[T], ft.Column):
63
64
  """
64
65
 
65
66
  Simple interface base class.
@@ -76,58 +77,31 @@ class Interface(Generic[T], ft.Column):
76
77
 
77
78
  TypeContext: Type[T] = Context
78
79
 
79
- def __init__(self, context: T, *args, **kwargs):
80
- """
81
-
82
- Instantiate and apply interface config
83
-
84
- """
85
- self.context = context
86
- super().__init__(*args, **kwargs, scroll=self.SCROLL)
87
-
88
80
  @classmethod
89
- async def render(cls, page: ft.Page):
90
- """
91
-
92
- Interface entry point. Set relevant callbacks, and add instantiated self to page views
93
-
81
+ async def new(cls, page: ft.Page):
94
82
  """
95
- if not page.on_route_change:
96
- page.title = cls.TITLE
97
- page.theme = cls.get_theme()
98
- page.views.clear()
99
- context = cls.TypeContext(page=page)
100
-
101
- self = await cls.create(context)
102
83
 
103
- view = self.view
104
- if not view:
105
- view = self
106
- page.views.append(view)
107
- page.on_route_change = cls.route
108
- page.on_view_pop = cls.pop
84
+ Interface entry point/async constructor. Set relevant callbacks, and add instantiated self to page views.
109
85
 
110
- page.go(cls.ROUTE_ROOT)
86
+ Override this to work with `Context`, do async setup. Otherwise, override __init__ (which is regular Column __init__) for a simple interface.
111
87
 
112
- @classmethod
113
- async def create(cls, context: T) -> Self:
114
88
  """
89
+ page.scroll = cls.SCROLL
90
+ page.title = cls.TITLE
91
+ page.on_connect = cls.on_connect
92
+ page.on_disconnect = cls.on_disconnect
93
+ page.on_route_change = cls.route
94
+ page.on_view_pop = cls.pop
95
+ page.theme = cls.get_theme()
115
96
 
116
- Overridable async interface constructor.
117
-
118
- """
119
- self = cls(context)
120
- return self
121
-
122
-
123
- @cached_property
124
- def view(self):
125
- """
97
+ context = cls.TypeContext(page=page)
98
+ self = cls()
99
+ self.context = context
126
100
 
127
- Overridable view definition.
101
+ page.controls.append(self)
102
+ page.update()
128
103
 
129
- """
130
- return None
104
+ return self
131
105
 
132
106
  @classmethod
133
107
  def route(cls, event: ft.RouteChangeEvent):
@@ -148,20 +122,25 @@ class Interface(Generic[T], ft.Column):
148
122
  logger.debug(f'View popped: {page.route=} {len(page.views)=} {view=}')
149
123
 
150
124
  @classmethod
151
- def launch(cls):
125
+ def on_connect(cls, event: ControlEvent):
152
126
  """
153
127
 
154
- Launch via render method
128
+ Log connections
155
129
 
156
130
  """
131
+ page = event.control
132
+ logger.warning(f'Connect: {page.client_user_agent=} {page.platform.name=}')
157
133
 
158
- if cls.URL:
159
- url = cls.URL
160
- else:
161
- url = f'http://{cls.HOST}:{cls.PORT}'
134
+ @classmethod
135
+ def on_disconnect(cls, event: ControlEvent):
136
+ """
137
+
138
+ Log disconnections
139
+
140
+ """
141
+ page = event.control
142
+ logger.warning(f'Disconnect {page.client_user_agent=} {page.platform.name=}')
162
143
 
163
- logger.info(f"Launching {cls.TITLE} at {url}")
164
- ft.app(cls.render, view=cls.APPVIEW, host=cls.HOST, port=cls.PORT, assets_dir=cls.PATH_ASSETS)
165
144
 
166
145
  @classmethod
167
146
  def get_theme(self):
@@ -176,8 +155,24 @@ class Interface(Generic[T], ft.Column):
176
155
  )
177
156
  return theme
178
157
 
158
+ @classmethod
159
+ def launch(cls):
160
+ """
161
+
162
+ Launch via async constructor method
163
+
164
+ """
165
+
166
+ if cls.URL:
167
+ url = cls.URL
168
+ else:
169
+ url = f'http://{cls.HOST}:{cls.PORT}'
170
+
171
+ logger.info(f"Launching {cls.TITLE} at {url}")
172
+ ft.app(cls.new, view=cls.APPVIEW, host=cls.HOST, port=cls.PORT, assets_dir=cls.PATH_ASSETS, )
173
+
179
174
 
180
- class Test(Interface[Context]):
175
+ class Test(Base[Context]):
181
176
  """
182
177
 
183
178
  Simple test interface, showing typing example.
@@ -187,9 +182,9 @@ class Test(Interface[Context]):
187
182
 
188
183
  TITLE = 'Test Interface'
189
184
 
190
- def __init__(self, context: Context):
185
+ def __init__(self):
191
186
  controls = [ft.Text(self.TITLE)]
192
- super().__init__(context=context, controls=controls)
187
+ super().__init__(controls=controls)
193
188
 
194
189
  if __name__ == "__main__":
195
190
  Test.launch()
@@ -14,6 +14,14 @@ IS_DEBUG = environment_tools.get(Constants.FMTR_LOG_LEVEL_KEY, None, converter=s
14
14
  LEVEL_DEFAULT = logging.DEBUG if IS_DEBUG else logging.INFO
15
15
 
16
16
 
17
+ def null_scrubber(match):
18
+ """
19
+
20
+ Effectively disable scrubbing
21
+
22
+ """
23
+ return match.value
24
+
17
25
  def get_logger(name, version=None, host=Constants.FMTR_OBS_HOST, key=None, org=Constants.ORG_NAME,
18
26
  stream=STREAM_DEFAULT, environment=ENVIRONMENT_DEFAULT, level=LEVEL_DEFAULT):
19
27
  """
@@ -64,7 +72,8 @@ def get_logger(name, version=None, host=Constants.FMTR_OBS_HOST, key=None, org=C
64
72
  service_version=version,
65
73
  environment=environment,
66
74
  send_to_logfire=False,
67
- console=console_opts
75
+ console=console_opts,
76
+ scrubbing=logfire.ScrubbingOptions(callback=null_scrubber)
68
77
  )
69
78
 
70
79
  if key is None:
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.3.50
1
+ 1.3.52
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.3.50
3
+ Version: 1.3.52
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
@@ -154,68 +154,68 @@ Provides-Extra: db-document
154
154
  Requires-Dist: beanie[odm]; extra == "db-document"
155
155
  Requires-Dist: motor; extra == "db-document"
156
156
  Provides-Extra: all
157
- Requires-Dist: semver; extra == "all"
157
+ Requires-Dist: tinynetrc; extra == "all"
158
+ Requires-Dist: peft; extra == "all"
159
+ Requires-Dist: flet-webview; extra == "all"
160
+ Requires-Dist: beanie[odm]; extra == "all"
161
+ Requires-Dist: torchaudio; extra == "all"
162
+ Requires-Dist: pymupdf; extra == "all"
163
+ Requires-Dist: pymupdf4llm; extra == "all"
164
+ Requires-Dist: regex; extra == "all"
165
+ Requires-Dist: pycountry; extra == "all"
166
+ Requires-Dist: logfire[fastapi]; extra == "all"
167
+ Requires-Dist: faker; extra == "all"
168
+ Requires-Dist: sre_yield; extra == "all"
169
+ Requires-Dist: contexttimer; extra == "all"
158
170
  Requires-Dist: openpyxl; extra == "all"
159
171
  Requires-Dist: filetype; extra == "all"
160
172
  Requires-Dist: logfire; extra == "all"
173
+ Requires-Dist: logfire[httpx]; extra == "all"
174
+ Requires-Dist: playwright; extra == "all"
175
+ Requires-Dist: semver; extra == "all"
161
176
  Requires-Dist: yamlscript; extra == "all"
162
- Requires-Dist: pycountry; extra == "all"
163
- Requires-Dist: openai; extra == "all"
164
- Requires-Dist: torchvision; extra == "all"
165
- Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
166
- Requires-Dist: html2text; extra == "all"
167
- Requires-Dist: google-auth-httplib2; extra == "all"
168
- Requires-Dist: cachetools; extra == "all"
169
- Requires-Dist: pydantic-settings; extra == "all"
170
- Requires-Dist: beanie[odm]; extra == "all"
171
- Requires-Dist: flet[all]; extra == "all"
172
- Requires-Dist: google-api-python-client; extra == "all"
173
- Requires-Dist: appdirs; extra == "all"
174
- Requires-Dist: faker; extra == "all"
177
+ Requires-Dist: flet-video; extra == "all"
178
+ Requires-Dist: google-auth; extra == "all"
179
+ Requires-Dist: fastapi; extra == "all"
180
+ Requires-Dist: dask[bag]; extra == "all"
181
+ Requires-Dist: docker; extra == "all"
175
182
  Requires-Dist: huggingface_hub; extra == "all"
176
- Requires-Dist: tokenizers; extra == "all"
177
- Requires-Dist: uvicorn[standard]; extra == "all"
178
- Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
179
- Requires-Dist: pandas; extra == "all"
180
183
  Requires-Dist: dnspython[doh]; extra == "all"
181
- Requires-Dist: bokeh; extra == "all"
182
- Requires-Dist: dask[bag]; extra == "all"
183
184
  Requires-Dist: pytest-cov; extra == "all"
184
- Requires-Dist: regex; extra == "all"
185
- Requires-Dist: pymupdf; extra == "all"
186
- Requires-Dist: httpx_retries; extra == "all"
187
- Requires-Dist: deepdiff; extra == "all"
188
- Requires-Dist: tabulate; extra == "all"
189
185
  Requires-Dist: deepmerge; extra == "all"
190
- Requires-Dist: playwright; extra == "all"
191
- Requires-Dist: google-auth-oauthlib; extra == "all"
192
- Requires-Dist: contexttimer; extra == "all"
193
- Requires-Dist: torchaudio; extra == "all"
194
- Requires-Dist: pydantic-extra-types; extra == "all"
195
- Requires-Dist: Unidecode; extra == "all"
196
- Requires-Dist: logfire[httpx]; extra == "all"
197
- Requires-Dist: google-auth; extra == "all"
198
- Requires-Dist: odfpy; extra == "all"
186
+ Requires-Dist: appdirs; extra == "all"
187
+ Requires-Dist: pandas; extra == "all"
188
+ Requires-Dist: html2text; extra == "all"
189
+ Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
199
190
  Requires-Dist: ollama; extra == "all"
200
- Requires-Dist: distributed; extra == "all"
201
- Requires-Dist: pymupdf4llm; extra == "all"
191
+ Requires-Dist: tabulate; extra == "all"
192
+ Requires-Dist: cachetools; extra == "all"
202
193
  Requires-Dist: pyyaml; extra == "all"
203
- Requires-Dist: sre_yield; extra == "all"
204
- Requires-Dist: pydantic; extra == "all"
205
194
  Requires-Dist: httpx; extra == "all"
206
- Requires-Dist: peft; extra == "all"
207
- Requires-Dist: tinynetrc; extra == "all"
195
+ Requires-Dist: sentence_transformers; extra == "all"
208
196
  Requires-Dist: json_repair; extra == "all"
209
- Requires-Dist: fastapi; extra == "all"
210
197
  Requires-Dist: diskcache; extra == "all"
211
- Requires-Dist: motor; extra == "all"
212
- Requires-Dist: flet-webview; extra == "all"
213
- Requires-Dist: docker; extra == "all"
214
- Requires-Dist: logfire[fastapi]; extra == "all"
215
- Requires-Dist: sentence_transformers; extra == "all"
216
- Requires-Dist: flet-video; extra == "all"
217
- Requires-Dist: transformers[sentencepiece]; extra == "all"
198
+ Requires-Dist: pydantic; extra == "all"
199
+ Requires-Dist: openai; extra == "all"
200
+ Requires-Dist: httpx_retries; extra == "all"
201
+ Requires-Dist: flet[all]; extra == "all"
202
+ Requires-Dist: bokeh; extra == "all"
218
203
  Requires-Dist: setuptools; extra == "all"
204
+ Requires-Dist: pydantic-settings; extra == "all"
205
+ Requires-Dist: google-auth-httplib2; extra == "all"
206
+ Requires-Dist: transformers[sentencepiece]; extra == "all"
207
+ Requires-Dist: Unidecode; extra == "all"
208
+ Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
209
+ Requires-Dist: torchvision; extra == "all"
210
+ Requires-Dist: google-auth-oauthlib; extra == "all"
211
+ Requires-Dist: distributed; extra == "all"
212
+ Requires-Dist: google-api-python-client; extra == "all"
213
+ Requires-Dist: tokenizers; extra == "all"
214
+ Requires-Dist: pydantic-extra-types; extra == "all"
215
+ Requires-Dist: uvicorn[standard]; extra == "all"
216
+ Requires-Dist: odfpy; extra == "all"
217
+ Requires-Dist: motor; extra == "all"
218
+ Requires-Dist: deepdiff; extra == "all"
219
219
  Dynamic: author
220
220
  Dynamic: author-email
221
221
  Dynamic: description
@@ -24,7 +24,7 @@ fmtr/tools/inspection_tools.py,sha256=tLTRvzy9XVomQPi0dfnF_cgwc7KiDVZAr7gPTk4S_b
24
24
  fmtr/tools/iterator_tools.py,sha256=ymxo2U9MrPhouIhWCVvh1TrP1bXJPm_p0Lqwgi5Jr6w,1628
25
25
  fmtr/tools/json_fix_tools.py,sha256=vNSlswVQnujPmKEqDjFJcO901mjMyv59q3awsT7mlhs,477
26
26
  fmtr/tools/json_tools.py,sha256=WkFc5q7oqMtcFejhN1K5zQFULa9TdLOup83Fr0saDRY,348
27
- fmtr/tools/logging_tools.py,sha256=M7I5igs_tX5SIRv4f-jfb75LOODclSdmEg5ziAAMSPE,2503
27
+ fmtr/tools/logging_tools.py,sha256=jZFKnL-7HHOaPkn7F3fT9DyffIgwY-g7SEQ0p1RhzBo,2673
28
28
  fmtr/tools/merging_tools.py,sha256=KDxCEFJEQJEwGw1qGKAgR55uUE2X2S5NWLKcfHRmX_k,227
29
29
  fmtr/tools/metric_tools.py,sha256=Lvia5CGFRIfrDFA8s37btIfTU5zHbo04cPJdAMtbndQ,272
30
30
  fmtr/tools/name_tools.py,sha256=5CB_phqhHjl66iI8oLxOGPF2odC1apdul-M8Fv2xBhs,5514
@@ -46,7 +46,7 @@ fmtr/tools/tabular_tools.py,sha256=mw6vOij1Ch-pVAyHMPtm5zj__ULZN_TKeBYOfj33wFM,1
46
46
  fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
47
47
  fmtr/tools/tools.py,sha256=CAsApa1YwVdNE6H66Vjivs_mXYvOas3rh7fPELAnTpk,795
48
48
  fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
49
- fmtr/tools/version,sha256=pIwgw6x6cpMRuvIX3K9LJTDMOR9_BeC8rJjjlbxqDUY,6
49
+ fmtr/tools/version,sha256=6mg-f0Dob6XPK21vB0XIalETo4iilcVpjzUomZIQS3Y,6
50
50
  fmtr/tools/webhook_tools.py,sha256=q3pVJ1NCem2SrMuFcLxiWd7DibFs7Q-uGtojfXd3Qcg,380
51
51
  fmtr/tools/yaml_tools.py,sha256=Bhhyd6GQVKO72Lp8ky7bAUjIB_65Hdh0Q45SKIEe6S8,1901
52
52
  fmtr/tools/ai_tools/__init__.py,sha256=O8VRlPnnQCncg2ZZ2l_VdWLJf4jkKH6dkZFVbv6o7IM,388
@@ -65,10 +65,10 @@ fmtr/tools/entrypoints/ep_test.py,sha256=B8HfWISfSgw_xVX475CbJGh_QnpOe9MH65H8qGj
65
65
  fmtr/tools/entrypoints/install_yamlscript.py,sha256=D9-QET4uPkwMvOBQJAgzn1fYb7Z7VAgZzFdHSAXc3Qc,116
66
66
  fmtr/tools/entrypoints/remote_debug_test.py,sha256=wmKg9o2pQq7eqeHmaO8oviujNgtnsCVEXOdXLIcQWs4,123
67
67
  fmtr/tools/entrypoints/shell_debug.py,sha256=0No3tAg9Ri4_vvSlQCUtAY-11HR0nE45i0VVtiAViwY,106
68
- fmtr/tools/interface_tools/__init__.py,sha256=qTN0Hd4A65aWQ4wza48xTNiI2aXBZVEyObdQIsMR2Uk,398
68
+ fmtr/tools/interface_tools/__init__.py,sha256=_bgZRTqmygtYM75o6_zyQRhT_XZnDERZEHmsYVrzyxw,393
69
69
  fmtr/tools/interface_tools/context.py,sha256=VpoR_ZCndDbwS0AzIPKi1hB2QckwJU5dJqAJavF3mqk,151
70
70
  fmtr/tools/interface_tools/controls.py,sha256=oOl0_sZB8fkvYB-9A5yjArfQmFQLMCsVGgRNrJAFJm4,332
71
- fmtr/tools/interface_tools/interface_tools.py,sha256=i1TqP_67pVGiRZotKdVxyH0b5OFwaTZ_5Tf60gip0ts,4214
71
+ fmtr/tools/interface_tools/interface_tools.py,sha256=GXnBkSO_Y-F7E5sErJdyyEkO3PyTz97yQBXlTEw_Ufw,4295
72
72
  fmtr/tools/path_tools/__init__.py,sha256=XrJXt7Zzo90tYUVksMlDfKkWt775zJ9OSi2NbhnqMDI,459
73
73
  fmtr/tools/path_tools/app_path_tools.py,sha256=JrJvtTDd_gkCKcZtBCDTMktsM77PZwGV_hzQX0g5GU8,1722
74
74
  fmtr/tools/path_tools/path_tools.py,sha256=s3RTXsjnr2Ah7vXQGjpGs-4DlWaVGvChu0aTFXX3gsE,8867
@@ -85,9 +85,9 @@ fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g
85
85
  fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
86
86
  fmtr/tools/version_tools/__init__.py,sha256=cjE6nO6AoVOUp3RwgTbqL9wiw8J1l2pHJOz6Gn6bxjA,326
87
87
  fmtr/tools/version_tools/version_tools.py,sha256=Hcc6yferZS1hHbugRTdiHhSNmXEEG0hjCiTTXKna-YY,1127
88
- fmtr_tools-1.3.50.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
- fmtr_tools-1.3.50.dist-info/METADATA,sha256=-42D0Ay9KhMXpGowQtlII6Xx4QGu7XKbfuoGWMR_Ej0,17429
90
- fmtr_tools-1.3.50.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
- fmtr_tools-1.3.50.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
- fmtr_tools-1.3.50.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
- fmtr_tools-1.3.50.dist-info/RECORD,,
88
+ fmtr_tools-1.3.52.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
+ fmtr_tools-1.3.52.dist-info/METADATA,sha256=beQhHRoQiWwSuBgp-9GIoWywNE6bI3BnoASw75lPYhM,17429
90
+ fmtr_tools-1.3.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
+ fmtr_tools-1.3.52.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
+ fmtr_tools-1.3.52.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
+ fmtr_tools-1.3.52.dist-info/RECORD,,