fmtr.tools 1.3.75__py3-none-any.whl → 1.3.76__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/constants.py CHANGED
@@ -46,7 +46,10 @@ class Constants:
46
46
  FILENAME_VERSION = 'version'
47
47
  DIR_NAME_HF = 'hf'
48
48
 
49
- ENTRYPOINTS_DIR = 'entrypoints'
49
+ ENTRYPOINT = 'entrypoint'
50
+ ENTRYPOINTS_DIR = f'{ENTRYPOINT}s'
51
+ ENTRYPOINT_FILE = f'{ENTRYPOINT}.py'
52
+
50
53
  PACKAGE_EXCLUDE_DIRS = {'data', 'build', 'dist', '.*', '*egg-info*'}
51
54
  INIT_FILENAME = '__init__.py'
52
55
 
@@ -182,8 +182,38 @@ class MixinFromJson:
182
182
  return self
183
183
 
184
184
 
185
+ class CliRunMixin:
186
+ """
187
+
188
+ Mixin only so that it can also be used with Pydantic Settings.
189
+
190
+ TODO Ideally, the run method would be defined on dm.Base and the settings base would just inherit like set.Base(BaseSettings, dm.Base), but this isn't yet tested/could break Fields.
191
+
192
+ """
193
+
194
+ def run(self):
195
+ """
196
+
197
+ Behaviour when run as a CLI command, i.e. via Pydantic Settings. Run any subcommands then exit.
198
+
199
+ """
200
+
201
+ from pydantic_settings import get_subcommand
202
+
203
+ command = get_subcommand(self, is_required=False, cli_exit_on_error=False)
204
+
205
+ if not command:
206
+ return
207
+
208
+ result = command.run()
209
+ if inspect.isawaitable(result):
210
+ import asyncio
211
+ result = asyncio.run(result)
212
+
213
+ raise SystemExit(result)
214
+
185
215
 
186
- class Base(BaseModel, MixinFromJson):
216
+ class Base(BaseModel, MixinFromJson, CliRunMixin):
187
217
  """
188
218
 
189
219
  Base model allowing model definition via a list of custom Field objects.
@@ -1,6 +1,8 @@
1
- from pydantic_settings import BaseSettings, PydanticBaseSettingsSource, YamlConfigSettingsSource, EnvSettingsSource, CliSettingsSource
2
1
  from typing import ClassVar, Any
3
2
 
3
+ from pydantic_settings import BaseSettings, PydanticBaseSettingsSource, YamlConfigSettingsSource, EnvSettingsSource, CliSettingsSource
4
+
5
+ from fmtr.tools.data_modelling_tools import CliRunMixin
4
6
  from fmtr.tools.path_tools import PackagePaths, Path
5
7
 
6
8
 
@@ -21,7 +23,7 @@ class YamlScriptConfigSettingsSource(YamlConfigSettingsSource):
21
23
  return data
22
24
 
23
25
 
24
- class Base(BaseSettings):
26
+ class Base(BaseSettings, CliRunMixin):
25
27
  """
26
28
 
27
29
  Base class for settings configuration using Pydantic BaseSettings.
@@ -88,6 +88,15 @@ class SetupPaths(FromCallerMixin):
88
88
  return False
89
89
  return org
90
90
 
91
+ @property
92
+ def entrypoint(self) -> Path:
93
+ """
94
+
95
+ Path of base entrypoint module.
96
+
97
+ """
98
+ return self.path / Constants.ENTRYPOINT_FILE
99
+
91
100
  @property
92
101
  def entrypoints(self) -> Path:
93
102
  """
@@ -182,23 +191,38 @@ class Setup(FromCallerMixin):
182
191
  def console_scripts(self) -> List[str]:
183
192
  """
184
193
 
185
- Generate console scripts for any modules in the `entrypoints` sub-package.
194
+ Generate console scripts for the `entrypoint` module - and/or any modules in `entrypoints` sub-package.
186
195
 
187
196
  """
188
197
 
189
198
  if not self.paths.entrypoints.exists():
190
- return []
199
+ paths_mods = []
200
+ else:
201
+ paths_mods = list(self.paths.entrypoints.iterdir())
191
202
 
192
- names_mods = [path.stem for path in self.paths.entrypoints.iterdir() if path.is_file() and path.name != Constants.INIT_FILENAME]
193
- command_prefix = self.name.replace('.', self.ENTRYPOINT_COMMAND_SEP)
203
+ names_mods = [path.stem for path in paths_mods if path.is_file() and path.name != Constants.INIT_FILENAME]
194
204
  command_suffixes = [name_mod.replace(self.ENTRYPOINT_FUNCTION_SEP, self.ENTRYPOINT_COMMAND_SEP) for name_mod in names_mods]
195
- commands = [f'{command_prefix}-{command_suffix}' for command_suffix in command_suffixes]
205
+ commands = [f'{self.name_command}-{command_suffix}' for command_suffix in command_suffixes]
196
206
  paths = [f'{self.name}.{Constants.ENTRYPOINTS_DIR}.{name_mod}:{self.ENTRYPOINT_FUNC_NAME}' for name_mod in names_mods]
197
207
 
208
+ if self.paths.entrypoint.exists():
209
+ commands.append(self.name_command)
210
+ path = f'{self.name}.{self.paths.entrypoint.stem}:{self.ENTRYPOINT_FUNC_NAME}'
211
+ paths.append(path)
212
+
198
213
  console_scripts = [f'{command} = {path}' for command, path in zip(commands, paths)]
199
214
 
200
215
  return console_scripts
201
216
 
217
+ @cached_property
218
+ def name_command(self) -> str:
219
+ """
220
+
221
+ Name as a command, e.g. `fmtr-tools`
222
+
223
+ """
224
+ return self.name.replace('.', self.ENTRYPOINT_COMMAND_SEP)
225
+
202
226
  @property
203
227
  def name(self) -> str:
204
228
  """
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.3.75
1
+ 1.3.76
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.3.75
3
+ Version: 1.3.76
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
@@ -21,7 +21,6 @@ Requires-Dist: pyyaml; extra == "dev"
21
21
  Requires-Dist: yamlscript; extra == "dev"
22
22
  Requires-Dist: pyyaml; extra == "dev"
23
23
  Requires-Dist: beanie[odm]; extra == "dev"
24
- Requires-Dist: motor; extra == "dev"
25
24
  Provides-Extra: test
26
25
  Requires-Dist: pytest-cov; extra == "test"
27
26
  Provides-Extra: yaml
@@ -166,70 +165,68 @@ Requires-Dist: playwright; extra == "browsers"
166
165
  Provides-Extra: db
167
166
  Provides-Extra: db-document
168
167
  Requires-Dist: beanie[odm]; extra == "db-document"
169
- Requires-Dist: motor; extra == "db-document"
170
168
  Provides-Extra: all
171
- Requires-Dist: fastapi; extra == "all"
172
- Requires-Dist: flet-webview; extra == "all"
173
- Requires-Dist: sre_yield; extra == "all"
174
- Requires-Dist: html2text; extra == "all"
175
- Requires-Dist: cachetools; extra == "all"
176
- Requires-Dist: pydantic-settings; extra == "all"
177
169
  Requires-Dist: pytest-cov; extra == "all"
178
- Requires-Dist: diskcache; extra == "all"
179
- Requires-Dist: appdirs; extra == "all"
180
- Requires-Dist: json_repair; extra == "all"
181
- Requires-Dist: flet-video; extra == "all"
182
- Requires-Dist: dnspython[doh]; extra == "all"
183
- Requires-Dist: pymupdf4llm; extra == "all"
184
- Requires-Dist: playwright; extra == "all"
185
- Requires-Dist: flet[all]; extra == "all"
186
- Requires-Dist: faker; extra == "all"
170
+ Requires-Dist: peft; extra == "all"
187
171
  Requires-Dist: openpyxl; extra == "all"
188
- Requires-Dist: logfire[httpx]; extra == "all"
189
- Requires-Dist: deepmerge; extra == "all"
190
- Requires-Dist: odfpy; extra == "all"
172
+ Requires-Dist: pymupdf; extra == "all"
173
+ Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
174
+ Requires-Dist: tinynetrc; extra == "all"
175
+ Requires-Dist: torchvision; extra == "all"
176
+ Requires-Dist: google-auth-httplib2; extra == "all"
177
+ Requires-Dist: logfire[fastapi]; extra == "all"
178
+ Requires-Dist: uvicorn[standard]; extra == "all"
179
+ Requires-Dist: pandas; extra == "all"
180
+ Requires-Dist: transformers[sentencepiece]; extra == "all"
181
+ Requires-Dist: google-auth-oauthlib; extra == "all"
182
+ Requires-Dist: flet[all]; extra == "all"
183
+ Requires-Dist: pyyaml; extra == "all"
184
+ Requires-Dist: tokenizers; extra == "all"
191
185
  Requires-Dist: tabulate; extra == "all"
192
- Requires-Dist: pydantic-extra-types; extra == "all"
186
+ Requires-Dist: dask[bag]; extra == "all"
187
+ Requires-Dist: pydantic-settings; extra == "all"
188
+ Requires-Dist: httpx; extra == "all"
189
+ Requires-Dist: google-api-python-client; extra == "all"
190
+ Requires-Dist: flet-webview; extra == "all"
191
+ Requires-Dist: yamlscript; extra == "all"
193
192
  Requires-Dist: semver; extra == "all"
194
- Requires-Dist: logfire[fastapi]; extra == "all"
193
+ Requires-Dist: json_repair; extra == "all"
194
+ Requires-Dist: distributed; extra == "all"
195
+ Requires-Dist: diskcache; extra == "all"
195
196
  Requires-Dist: contexttimer; extra == "all"
197
+ Requires-Dist: ollama; extra == "all"
198
+ Requires-Dist: appdirs; extra == "all"
199
+ Requires-Dist: google-auth; extra == "all"
196
200
  Requires-Dist: pycountry; extra == "all"
197
- Requires-Dist: httpx_retries; extra == "all"
198
- Requires-Dist: yamlscript; extra == "all"
201
+ Requires-Dist: deepmerge; extra == "all"
202
+ Requires-Dist: pydantic-extra-types; extra == "all"
203
+ Requires-Dist: python-on-whales; extra == "all"
199
204
  Requires-Dist: regex; extra == "all"
200
- Requires-Dist: uvicorn[standard]; extra == "all"
201
- Requires-Dist: pymupdf; extra == "all"
202
- Requires-Dist: filetype; extra == "all"
203
- Requires-Dist: motor; extra == "all"
204
- Requires-Dist: logfire; extra == "all"
205
- Requires-Dist: google-auth-httplib2; extra == "all"
206
- Requires-Dist: dask[bag]; extra == "all"
207
- Requires-Dist: setuptools; extra == "all"
208
- Requires-Dist: bokeh; extra == "all"
209
- Requires-Dist: google-auth; extra == "all"
210
- Requires-Dist: Unidecode; extra == "all"
205
+ Requires-Dist: flet-video; extra == "all"
211
206
  Requires-Dist: sentence_transformers; extra == "all"
212
- Requires-Dist: huggingface_hub; extra == "all"
213
- Requires-Dist: httpx; extra == "all"
214
- Requires-Dist: tinynetrc; extra == "all"
215
- Requires-Dist: pandas; extra == "all"
216
- Requires-Dist: google-auth-oauthlib; extra == "all"
217
- Requires-Dist: torchvision; extra == "all"
218
- Requires-Dist: pydantic; extra == "all"
219
- Requires-Dist: transformers[sentencepiece]; extra == "all"
220
- Requires-Dist: distributed; extra == "all"
221
207
  Requires-Dist: openai; extra == "all"
222
208
  Requires-Dist: deepdiff; extra == "all"
223
- Requires-Dist: peft; extra == "all"
224
- Requires-Dist: tokenizers; extra == "all"
225
- Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
226
- Requires-Dist: python-on-whales; extra == "all"
209
+ Requires-Dist: fastapi; extra == "all"
210
+ Requires-Dist: bokeh; extra == "all"
211
+ Requires-Dist: logfire; extra == "all"
227
212
  Requires-Dist: beanie[odm]; extra == "all"
228
- Requires-Dist: ollama; extra == "all"
213
+ Requires-Dist: pymupdf4llm; extra == "all"
214
+ Requires-Dist: dnspython[doh]; extra == "all"
215
+ Requires-Dist: setuptools; extra == "all"
216
+ Requires-Dist: playwright; extra == "all"
217
+ Requires-Dist: filetype; extra == "all"
218
+ Requires-Dist: pydantic; extra == "all"
219
+ Requires-Dist: sre_yield; extra == "all"
220
+ Requires-Dist: huggingface_hub; extra == "all"
221
+ Requires-Dist: Unidecode; extra == "all"
222
+ Requires-Dist: faker; extra == "all"
223
+ Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
224
+ Requires-Dist: odfpy; extra == "all"
225
+ Requires-Dist: logfire[httpx]; extra == "all"
226
+ Requires-Dist: html2text; extra == "all"
227
+ Requires-Dist: httpx_retries; extra == "all"
229
228
  Requires-Dist: torchaudio; extra == "all"
230
- Requires-Dist: google-api-python-client; extra == "all"
231
- Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
232
- Requires-Dist: pyyaml; extra == "all"
229
+ Requires-Dist: cachetools; extra == "all"
233
230
  Dynamic: author
234
231
  Dynamic: author-email
235
232
  Dynamic: description
@@ -3,9 +3,9 @@ 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=90wCirUpw4bWMAbjhip0LL6k57eS5VmxRUP9pLCChBg,1812
6
+ fmtr/tools/constants.py,sha256=h85mq2JuOsHj-TUKnV0rYTddWFRSRAd4yLyCkpeGjX0,1887
7
7
  fmtr/tools/context_tools.py,sha256=4UvIHYgLqAh7dXMX9EBrLEpYp81qfzhSVrkffOSAoGA,350
8
- fmtr/tools/data_modelling_tools.py,sha256=KZlY0BkGY1DWro0lhWE1ezgbnv9wPWaj9E2CEqMnTXM,6605
8
+ fmtr/tools/data_modelling_tools.py,sha256=c703EhL2ZIj5iN0wjuohakvUnElRblQhvFSLyfRTWwA,7416
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
@@ -38,14 +38,14 @@ fmtr/tools/process_tools.py,sha256=Ysh5Dk2QFBhXQerArjKdt7xZd3JrN5Ho02AaOjH0Nnw,1
38
38
  fmtr/tools/profiling_tools.py,sha256=jpXVjaNKPydTasEQVNXvxzGtMhXPit08AnJddkU8uIc,46
39
39
  fmtr/tools/random_tools.py,sha256=4VlQdk5THbR8ka4pZaLbk_ZO_4yy6PF_lHZes_rgenY,2223
40
40
  fmtr/tools/semantic_tools.py,sha256=cxY9NSAHWj4nEc6Oj4qA1omR3dWbl2OuH7_PkINc6_E,1386
41
- fmtr/tools/settings_tools.py,sha256=o11W3T60UZSvCTkh_eEQq1Mx74GycQ6JxUr0plBDbsk,2356
41
+ fmtr/tools/settings_tools.py,sha256=Uq1-Cdzz83I4dmr62K0L4xFUsUqp0uDI9SeYCa6EHc0,2426
42
42
  fmtr/tools/spaces_tools.py,sha256=D_he3mve6DruB3OPS6QyzqD05ChHnRTb4buViKPe7To,1099
43
43
  fmtr/tools/string_tools.py,sha256=ZKHBrl2tui9VjWt7qit4UWbvpuzY6zp5ytiQvhlJVG4,5610
44
44
  fmtr/tools/tabular_tools.py,sha256=mw6vOij1Ch-pVAyHMPtm5zj__ULZN_TKeBYOfj33wFM,1634
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=EAFGJKF2ntHAJlv_mAXqigAu1JKLkQdZZFpYL7Vh3p0,6
48
+ fmtr/tools/version,sha256=NsbF2x120gFOktRo0UW0oi60P8h7eq7HQIUtLO66Zy8,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
@@ -74,7 +74,7 @@ fmtr/tools/path_tools/app_path_tools.py,sha256=JrJvtTDd_gkCKcZtBCDTMktsM77PZwGV_
74
74
  fmtr/tools/path_tools/path_tools.py,sha256=s3RTXsjnr2Ah7vXQGjpGs-4DlWaVGvChu0aTFXX3gsE,8867
75
75
  fmtr/tools/path_tools/type_path_tools.py,sha256=Zgs-ek-GXRKDIlVDGdg3muB0PIxTg2ba0NeHw6y8FWQ,40
76
76
  fmtr/tools/setup_tools/__init__.py,sha256=Ro_Qj3Xndv8Z68DeWPI7c6X-aWKsdDm0KcX_k1xDhgE,394
77
- fmtr/tools/setup_tools/setup_tools.py,sha256=7Z6jlU6UE8P4cntGQ_hJR7hGvoqwh15xzZY63cnxG7E,10363
77
+ fmtr/tools/setup_tools/setup_tools.py,sha256=ykW7rAv6ixfXdmLKcPgotenEQ94-NSsdFnDUZqgRbpI,10956
78
78
  fmtr/tools/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
79
79
  fmtr/tools/tests/conftest.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
80
  fmtr/tools/tests/helpers.py,sha256=N5sf9YoZV93a7tf_UxpLeyQ9vp6Ec0teNIimFDvc054,1091
@@ -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.75.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
- fmtr_tools-1.3.75.dist-info/METADATA,sha256=tc0dLbu9SrTc1jlpcDdW3c6g1z4QtzdRyLnk0VMVwe4,18035
90
- fmtr_tools-1.3.75.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
- fmtr_tools-1.3.75.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
- fmtr_tools-1.3.75.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
- fmtr_tools-1.3.75.dist-info/RECORD,,
88
+ fmtr_tools-1.3.76.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
+ fmtr_tools-1.3.76.dist-info/METADATA,sha256=qceqhfyIUdA5X0mZdsbNpOg2f59Mk_W0zxEiulcydIs,17916
90
+ fmtr_tools-1.3.76.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
+ fmtr_tools-1.3.76.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
+ fmtr_tools-1.3.76.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
+ fmtr_tools-1.3.76.dist-info/RECORD,,