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

@@ -224,23 +224,30 @@ class Base(BaseModel, MixinFromJson):
224
224
  setattr(cls, name, field)
225
225
  cls.__annotations__[name] = field.annotation
226
226
 
227
- def to_df(self, name_value='value'):
227
+ def to_df(self, **kwargs):
228
228
  """
229
229
 
230
- DataFrame representation with Fields as rows.
230
+ DataFrame representation of Data Model.
231
231
 
232
232
  """
233
+ from fmtr.tools import tabular
233
234
 
234
- objs = []
235
- for name in self.model_fields.keys():
236
- val = getattr(self, name)
237
- objs.append(val)
238
-
239
- df = to_df(*objs, name_value=name_value)
240
- df['id'] = list(self.model_fields.keys())
241
- df = df.set_index('id', drop=True)
235
+ data = self.model_dump(**kwargs)
236
+ df = tabular.pd.json_normalize(data, sep='_')
242
237
  return df
243
238
 
239
+ @classmethod
240
+ def to_df_empty(cls):
241
+ """
242
+
243
+ Empty DataFrame
244
+
245
+ """
246
+ from fmtr.tools import tabular
247
+
248
+ row = {name: None for name in cls.model_fields.keys()}
249
+ df = tabular.pd.DataFrame([row])
250
+ return df
244
251
 
245
252
  class Root(RootModel, MixinFromJson):
246
253
  """
@@ -249,11 +256,21 @@ class Root(RootModel, MixinFromJson):
249
256
 
250
257
  """
251
258
 
252
- def to_df(self):
259
+ def to_df(self, **kwargs):
253
260
  """
254
261
 
255
262
  DataFrame representation with items as rows.
256
263
 
257
264
  """
258
265
 
259
- return to_df(*self.items)
266
+ """
267
+
268
+ DataFrame representation of Data Model.
269
+
270
+ """
271
+ from fmtr.tools import tabular
272
+
273
+ data = [item.model_dump(**kwargs) for item in self.items]
274
+ dfs = [tabular.pd.json_normalize(datum, sep='_') for datum in data]
275
+ df = tabular.pd.concat(dfs, axis=tabular.CONCAT_VERTICALLY)
276
+ return df
@@ -46,7 +46,7 @@ class Cell(ft.DataCell):
46
46
 
47
47
  """
48
48
 
49
- return ft.Text(str(self.value), color=self.color)
49
+ return ft.Text(str(self.value), color=self.color, bgcolor=self.bgcolor)
50
50
 
51
51
  @property
52
52
  def color(self):
@@ -60,6 +60,16 @@ class Cell(ft.DataCell):
60
60
  else:
61
61
  return None
62
62
 
63
+ @property
64
+ def bgcolor(self):
65
+ """
66
+
67
+ Basic conditional formatting
68
+
69
+ """
70
+ return None
71
+
72
+
63
73
  @property
64
74
  def gesture_detector(self):
65
75
  """
@@ -67,7 +77,7 @@ class Cell(ft.DataCell):
67
77
  Make arbitrary content clickable
68
78
 
69
79
  """
70
- return ft.GestureDetector(content=self.text, on_tap=self.click_tap)
80
+ return ft.GestureDetector(content=self.text, on_tap=self.click_tap, on_double_tap=self.click_double_tap)
71
81
 
72
82
  async def click_tap(self, event: TapEvent):
73
83
  """
@@ -87,6 +97,24 @@ class Cell(ft.DataCell):
87
97
  """
88
98
  logger.info(f"Clicked {self.column=} {self.series.id=} {self.value=}")
89
99
 
100
+ async def click_double_tap(self, event: TapEvent):
101
+ """
102
+
103
+ Default cell click behavior — override in subclass if needed
104
+
105
+ """
106
+ value = await self.double_click(event=event)
107
+ event.page.update()
108
+ return value
109
+
110
+ async def double_click(self, event: Optional[TapEvent] = None):
111
+ """
112
+
113
+ Default cell double click behavior — override in subclass if needed
114
+
115
+ """
116
+ logger.info(f"Double-clicked {self.column=} {self.series.id=} {self.value=}")
117
+
90
118
 
91
119
  class Row(ft.DataRow):
92
120
  """
@@ -100,7 +128,16 @@ class Row(ft.DataRow):
100
128
  def __init__(self, series):
101
129
  self.series = series
102
130
  cells = [self.TypeCell(series, col) for col in series.index]
103
- super().__init__(cells)
131
+ super().__init__(cells, color=self.row_color)
132
+
133
+ @property
134
+ def row_color(self):
135
+ """
136
+
137
+ Basic conditional formatting
138
+
139
+ """
140
+ return None
104
141
 
105
142
 
106
143
  class Column(ft.DataColumn):
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.3.71
1
+ 1.3.73
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.3.71
3
+ Version: 1.3.73
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
@@ -168,68 +168,68 @@ Provides-Extra: db-document
168
168
  Requires-Dist: beanie[odm]; extra == "db-document"
169
169
  Requires-Dist: motor; extra == "db-document"
170
170
  Provides-Extra: all
171
- Requires-Dist: playwright; extra == "all"
172
- Requires-Dist: ollama; extra == "all"
173
- Requires-Dist: Unidecode; extra == "all"
174
- Requires-Dist: cachetools; extra == "all"
175
171
  Requires-Dist: pydantic-extra-types; extra == "all"
176
- Requires-Dist: dask[bag]; extra == "all"
172
+ Requires-Dist: google-auth; extra == "all"
173
+ Requires-Dist: openai; extra == "all"
174
+ Requires-Dist: pymupdf; extra == "all"
177
175
  Requires-Dist: transformers[sentencepiece]; extra == "all"
178
- Requires-Dist: torchaudio; extra == "all"
179
- Requires-Dist: python-on-whales; extra == "all"
180
- Requires-Dist: beanie[odm]; extra == "all"
181
- Requires-Dist: setuptools; extra == "all"
182
- Requires-Dist: logfire[httpx]; extra == "all"
183
- Requires-Dist: flet-video; extra == "all"
184
- Requires-Dist: torchvision; extra == "all"
176
+ Requires-Dist: fastapi; extra == "all"
177
+ Requires-Dist: google-auth-httplib2; extra == "all"
178
+ Requires-Dist: deepmerge; extra == "all"
179
+ Requires-Dist: pytest-cov; extra == "all"
185
180
  Requires-Dist: odfpy; extra == "all"
181
+ Requires-Dist: distributed; extra == "all"
186
182
  Requires-Dist: pyyaml; extra == "all"
187
- Requires-Dist: diskcache; extra == "all"
183
+ Requires-Dist: uvicorn[standard]; extra == "all"
184
+ Requires-Dist: torchaudio; extra == "all"
185
+ Requires-Dist: pymupdf4llm; extra == "all"
186
+ Requires-Dist: sre_yield; extra == "all"
187
+ Requires-Dist: appdirs; extra == "all"
188
+ Requires-Dist: filetype; extra == "all"
189
+ Requires-Dist: dnspython[doh]; extra == "all"
190
+ Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
191
+ Requires-Dist: html2text; extra == "all"
192
+ Requires-Dist: openpyxl; extra == "all"
188
193
  Requires-Dist: google-api-python-client; extra == "all"
189
- Requires-Dist: motor; extra == "all"
190
- Requires-Dist: yamlscript; extra == "all"
191
- Requires-Dist: tinynetrc; extra == "all"
192
- Requires-Dist: pandas; extra == "all"
193
- Requires-Dist: google-auth; extra == "all"
194
+ Requires-Dist: flet-video; extra == "all"
195
+ Requires-Dist: python-on-whales; extra == "all"
196
+ Requires-Dist: diskcache; extra == "all"
194
197
  Requires-Dist: json_repair; extra == "all"
195
- Requires-Dist: deepmerge; extra == "all"
196
- Requires-Dist: google-auth-httplib2; extra == "all"
197
- Requires-Dist: openai; extra == "all"
198
- Requires-Dist: pytest-cov; extra == "all"
199
- Requires-Dist: pymupdf4llm; extra == "all"
200
- Requires-Dist: logfire; extra == "all"
198
+ Requires-Dist: pandas; extra == "all"
199
+ Requires-Dist: logfire[fastapi]; extra == "all"
200
+ Requires-Dist: ollama; extra == "all"
201
+ Requires-Dist: sentence_transformers; extra == "all"
201
202
  Requires-Dist: semver; extra == "all"
202
- Requires-Dist: contexttimer; extra == "all"
203
- Requires-Dist: regex; extra == "all"
203
+ Requires-Dist: pycountry; extra == "all"
204
+ Requires-Dist: httpx_retries; extra == "all"
205
+ Requires-Dist: logfire[httpx]; extra == "all"
206
+ Requires-Dist: flet[all]; extra == "all"
204
207
  Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
205
- Requires-Dist: pydantic-settings; extra == "all"
206
- Requires-Dist: fastapi; extra == "all"
207
- Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
208
- Requires-Dist: uvicorn[standard]; extra == "all"
209
- Requires-Dist: deepdiff; extra == "all"
210
- Requires-Dist: dnspython[doh]; extra == "all"
211
- Requires-Dist: google-auth-oauthlib; extra == "all"
212
- Requires-Dist: pymupdf; extra == "all"
208
+ Requires-Dist: tabulate; extra == "all"
209
+ Requires-Dist: cachetools; extra == "all"
210
+ Requires-Dist: beanie[odm]; extra == "all"
211
+ Requires-Dist: Unidecode; extra == "all"
212
+ Requires-Dist: bokeh; extra == "all"
213
+ Requires-Dist: torchvision; extra == "all"
213
214
  Requires-Dist: tokenizers; extra == "all"
214
- Requires-Dist: filetype; extra == "all"
215
- Requires-Dist: pydantic; extra == "all"
216
- Requires-Dist: logfire[fastapi]; extra == "all"
215
+ Requires-Dist: pydantic-settings; extra == "all"
216
+ Requires-Dist: flet-webview; extra == "all"
217
217
  Requires-Dist: faker; extra == "all"
218
- Requires-Dist: flet[all]; extra == "all"
219
- Requires-Dist: tabulate; extra == "all"
220
218
  Requires-Dist: httpx; extra == "all"
221
- Requires-Dist: peft; extra == "all"
222
- Requires-Dist: flet-webview; extra == "all"
223
- Requires-Dist: pycountry; extra == "all"
224
- Requires-Dist: html2text; extra == "all"
225
- Requires-Dist: sentence_transformers; extra == "all"
226
- Requires-Dist: appdirs; extra == "all"
227
- Requires-Dist: httpx_retries; extra == "all"
228
- Requires-Dist: distributed; extra == "all"
219
+ Requires-Dist: playwright; extra == "all"
220
+ Requires-Dist: pydantic; extra == "all"
229
221
  Requires-Dist: huggingface_hub; extra == "all"
230
- Requires-Dist: openpyxl; extra == "all"
231
- Requires-Dist: sre_yield; extra == "all"
232
- Requires-Dist: bokeh; extra == "all"
222
+ Requires-Dist: regex; extra == "all"
223
+ Requires-Dist: contexttimer; extra == "all"
224
+ Requires-Dist: dask[bag]; extra == "all"
225
+ Requires-Dist: logfire; extra == "all"
226
+ Requires-Dist: tinynetrc; extra == "all"
227
+ Requires-Dist: deepdiff; extra == "all"
228
+ Requires-Dist: setuptools; extra == "all"
229
+ Requires-Dist: yamlscript; extra == "all"
230
+ Requires-Dist: google-auth-oauthlib; extra == "all"
231
+ Requires-Dist: peft; extra == "all"
232
+ Requires-Dist: motor; extra == "all"
233
233
  Dynamic: author
234
234
  Dynamic: author-email
235
235
  Dynamic: description
@@ -5,7 +5,7 @@ fmtr/tools/augmentation_tools.py,sha256=-6ESbO4CDlKqVOV1J1V6qBeoBMzbFIinkDHRHnCB
5
5
  fmtr/tools/caching_tools.py,sha256=74p7m2GLFfeP41LX69wxgfkilxEAoWkMIfFMjKsYpyg,4976
6
6
  fmtr/tools/constants.py,sha256=90wCirUpw4bWMAbjhip0LL6k57eS5VmxRUP9pLCChBg,1812
7
7
  fmtr/tools/context_tools.py,sha256=4UvIHYgLqAh7dXMX9EBrLEpYp81qfzhSVrkffOSAoGA,350
8
- fmtr/tools/data_modelling_tools.py,sha256=qTKyLlSOnFnkJTa2Wg3eRlec9kiKsrddrO2Zi9vZvqA,6188
8
+ fmtr/tools/data_modelling_tools.py,sha256=KZlY0BkGY1DWro0lhWE1ezgbnv9wPWaj9E2CEqMnTXM,6605
9
9
  fmtr/tools/dataclass_tools.py,sha256=0Gt6KeLhtPgubo_2tYkIVqB8oQ91Qzag8OAGZDdjvMU,1209
10
10
  fmtr/tools/datatype_tools.py,sha256=qFPFrZK70-an4w7H46g8eT5j6Jez--U2XnmFdrQibeE,1983
11
11
  fmtr/tools/datetime_tools.py,sha256=L7wmBoQbD9h_pJIL92WQOX32r_vrXgRvE-_0PVPRAGY,232
@@ -45,7 +45,7 @@ fmtr/tools/tabular_tools.py,sha256=mw6vOij1Ch-pVAyHMPtm5zj__ULZN_TKeBYOfj33wFM,1
45
45
  fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
46
46
  fmtr/tools/tools.py,sha256=sLMXk8juOL8_n_D776cJ-kzjyMHqFI_fctDEjy6PIKs,1115
47
47
  fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
48
- fmtr/tools/version,sha256=RKfpJYVUZqgI7UFHG-wGYsY7K7pJ5MVrkwjYpSOb6ro,6
48
+ fmtr/tools/version,sha256=igGdG23ZKXmxPHu73EVw5gtOGr5KGif-26oVR4QTXis,6
49
49
  fmtr/tools/webhook_tools.py,sha256=q3pVJ1NCem2SrMuFcLxiWd7DibFs7Q-uGtojfXd3Qcg,380
50
50
  fmtr/tools/yaml_tools.py,sha256=Bhhyd6GQVKO72Lp8ky7bAUjIB_65Hdh0Q45SKIEe6S8,1901
51
51
  fmtr/tools/ai_tools/__init__.py,sha256=O8VRlPnnQCncg2ZZ2l_VdWLJf4jkKH6dkZFVbv6o7IM,388
@@ -67,7 +67,7 @@ fmtr/tools/entrypoints/remote_debug_test.py,sha256=wmKg9o2pQq7eqeHmaO8oviujNgtns
67
67
  fmtr/tools/entrypoints/shell_debug.py,sha256=0No3tAg9Ri4_vvSlQCUtAY-11HR0nE45i0VVtiAViwY,106
68
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
- fmtr/tools/interface_tools/controls.py,sha256=KYjo-TLQuoh8gCgw6saZs6Sz1zDwCm5wfIgqta4mKrE,3030
70
+ fmtr/tools/interface_tools/controls.py,sha256=gm8mlgrV014r8fQYHd5pVwnDIvxWiNkS8g_9sYSir5Y,3870
71
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
@@ -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.71.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
- fmtr_tools-1.3.71.dist-info/METADATA,sha256=t-oB0K3EpWbRCOh4g-3xeK7fmkfs1NM8BsudZY98i7Y,18035
90
- fmtr_tools-1.3.71.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
- fmtr_tools-1.3.71.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
- fmtr_tools-1.3.71.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
- fmtr_tools-1.3.71.dist-info/RECORD,,
88
+ fmtr_tools-1.3.73.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
+ fmtr_tools-1.3.73.dist-info/METADATA,sha256=EUuFhzj8FMERfXkqqQpPCSDcqCBJpsUjrJZsMwvxFvQ,18035
90
+ fmtr_tools-1.3.73.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
+ fmtr_tools-1.3.73.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
+ fmtr_tools-1.3.73.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
+ fmtr_tools-1.3.73.dist-info/RECORD,,