fmtr.tools 1.1.8__py3-none-any.whl → 1.1.10__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
@@ -19,6 +19,7 @@ import fmtr.tools.string_tools as string
19
19
  import fmtr.tools.name_tools as name
20
20
  import fmtr.tools.logging_tools as logging
21
21
  import fmtr.tools.async_tools as asyncio
22
+ import fmtr.tools.packaging_tools as packaging
22
23
  from fmtr.tools.logging_tools import logger
23
24
 
24
25
  from fmtr.tools.import_tools import MissingExtraMockModule
@@ -1,12 +1,14 @@
1
+ from typing import List, Optional
2
+
1
3
  import pydantic_ai
2
4
  from pydantic_ai import RunContext
3
5
  from pydantic_ai.agent import AgentRunResult, Agent
4
6
  from pydantic_ai.models.openai import OpenAIModel
5
7
  from pydantic_ai.providers.openai import OpenAIProvider
6
- from typing import List, Optional
7
8
 
8
9
  from fmtr.tools import environment_tools as env
9
10
  from fmtr.tools.constants import Constants
11
+ from fmtr.tools.string_tools import truncate_mid
10
12
 
11
13
  pydantic_ai.Agent.instrument_all()
12
14
 
@@ -97,6 +99,14 @@ class Task:
97
99
 
98
100
  return []
99
101
 
102
+ def __repr__(self):
103
+ """
104
+
105
+ String representation of the object
106
+
107
+ """
108
+ return f'{self.__class__.__name__}({repr(truncate_mid(self.SYSTEM_PROMPT_STATIC, 100))})'
109
+
100
110
  if __name__ == '__main__':
101
111
  import asyncio
102
112
  from fmtr.tools import dm
@@ -0,0 +1,14 @@
1
+ import importlib.metadata
2
+
3
+
4
+ def get_version(module):
5
+ """
6
+
7
+ Retrieve the version of a specified module.
8
+
9
+ """
10
+
11
+ if type(module) is not str:
12
+ module = module.__name__
13
+ version = importlib.metadata.version(module)
14
+ return version
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.1.8
1
+ 1.1.10
fmtr/tools/yaml_tools.py CHANGED
@@ -1,12 +1,58 @@
1
+ from functools import lru_cache
1
2
  from typing import Any
2
- from yaml import CLoader as Loader, CDumper as Dumper
3
- from yaml import load, dump
3
+ from yaml import CDumper as Dumper
4
+ from yaml import dump
4
5
 
6
+ from fmtr.tools import environment_tools as env
7
+
8
+
9
+ def install():
10
+ """
11
+
12
+ Installs the YAML Script runtime binary of the specified version.
5
13
 
6
- def to_yaml(obj: Any) -> str:
7
14
  """
15
+ import subprocess
16
+ from fmtr.tools import logger, packaging
17
+
18
+ version = packaging.get_version('yamlscript')
19
+ logger.warning(f"Installing YAML Script runtime binary version {version}...")
20
+ result = subprocess.run(f"curl https://yamlscript.org/install | VERSION={version} LIB=1 bash", shell=True, check=True)
21
+ return result
8
22
 
9
23
 
24
+ @lru_cache
25
+ def get_module(is_auto=env.IS_DEBUG):
26
+ """
27
+
28
+ Get the YAML Script runtime module, installing the runtime if specified
29
+
30
+ """
31
+ try:
32
+ import yamlscript
33
+ except Exception as exception:
34
+ if not is_auto:
35
+ raise ImportError(f'YAML Script runtime missing and {is_auto=}. Set to {True} to install.') from exception
36
+ install()
37
+ import yamlscript
38
+ return yamlscript
39
+
40
+
41
+ @lru_cache
42
+ def get_interpreter():
43
+ """
44
+
45
+ Fetches and returns a cached instance of the YAMLScript interpreter.
46
+
47
+ """
48
+ module = get_module()
49
+ interpreter = module.YAMLScript()
50
+ return interpreter
51
+
52
+ def to_yaml(obj: Any) -> str:
53
+ """
54
+
55
+ Serialize to YAML
10
56
 
11
57
  """
12
58
  yaml_str = dump(obj, allow_unicode=True, Dumper=Dumper)
@@ -16,8 +62,8 @@ def to_yaml(obj: Any) -> str:
16
62
  def from_yaml(yaml_str: str) -> Any:
17
63
  """
18
64
 
19
-
65
+ Deserialize from YAML
20
66
 
21
67
  """
22
- obj = load(yaml_str, Loader=Loader)
68
+ obj = get_interpreter().load(yaml_str)
23
69
  return obj
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.1.8
3
+ Version: 1.1.10
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
@@ -9,53 +9,53 @@ License: Copyright © 2025 Frontmatter. All rights reserved.
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
11
  Provides-Extra: test
12
- Requires-Dist: pymupdf4llm; extra == "test"
13
12
  Requires-Dist: pydantic-settings; extra == "test"
14
- Requires-Dist: tinynetrc; extra == "test"
15
- Requires-Dist: torchvision; extra == "test"
16
- Requires-Dist: pyyaml; extra == "test"
17
- Requires-Dist: openai; extra == "test"
18
- Requires-Dist: flet-webview; extra == "test"
13
+ Requires-Dist: flet-video; extra == "test"
14
+ Requires-Dist: pydantic; extra == "test"
19
15
  Requires-Dist: pymupdf; extra == "test"
20
- Requires-Dist: faker; extra == "test"
21
- Requires-Dist: pydevd-pycharm; extra == "test"
22
- Requires-Dist: distributed; extra == "test"
23
- Requires-Dist: contexttimer; extra == "test"
24
- Requires-Dist: semver; extra == "test"
25
- Requires-Dist: bokeh; extra == "test"
26
- Requires-Dist: torchaudio; extra == "test"
27
- Requires-Dist: huggingface_hub; extra == "test"
28
- Requires-Dist: google-auth-oauthlib; extra == "test"
29
- Requires-Dist: openpyxl; extra == "test"
30
- Requires-Dist: docker; extra == "test"
16
+ Requires-Dist: flet-webview; extra == "test"
17
+ Requires-Dist: logfire[fastapi]; extra == "test"
18
+ Requires-Dist: sre_yield; extra == "test"
19
+ Requires-Dist: peft; extra == "test"
20
+ Requires-Dist: pandas; extra == "test"
31
21
  Requires-Dist: pytest-cov; extra == "test"
32
- Requires-Dist: uvicorn[standard]; extra == "test"
22
+ Requires-Dist: google-auth-oauthlib; extra == "test"
23
+ Requires-Dist: json_repair; extra == "test"
24
+ Requires-Dist: huggingface_hub; extra == "test"
25
+ Requires-Dist: logfire; extra == "test"
33
26
  Requires-Dist: html2text; extra == "test"
27
+ Requires-Dist: openai; extra == "test"
28
+ Requires-Dist: pydevd-pycharm; extra == "test"
29
+ Requires-Dist: bokeh; extra == "test"
30
+ Requires-Dist: dask[bag]; extra == "test"
31
+ Requires-Dist: pydantic-ai[logfire,openai]; extra == "test"
32
+ Requires-Dist: contexttimer; extra == "test"
33
+ Requires-Dist: flet[all]; extra == "test"
34
34
  Requires-Dist: google-api-python-client; extra == "test"
35
- Requires-Dist: sentence_transformers; extra == "test"
36
- Requires-Dist: logfire; extra == "test"
35
+ Requires-Dist: tabulate; extra == "test"
36
+ Requires-Dist: deepmerge; extra == "test"
37
+ Requires-Dist: tinynetrc; extra == "test"
38
+ Requires-Dist: distributed; extra == "test"
39
+ Requires-Dist: yamlscript; extra == "test"
40
+ Requires-Dist: ollama; extra == "test"
37
41
  Requires-Dist: Unidecode; extra == "test"
38
- Requires-Dist: diskcache; extra == "test"
39
- Requires-Dist: flet[all]; extra == "test"
40
- Requires-Dist: pandas; extra == "test"
42
+ Requires-Dist: semver; extra == "test"
43
+ Requires-Dist: uvicorn[standard]; extra == "test"
44
+ Requires-Dist: docker; extra == "test"
45
+ Requires-Dist: faker; extra == "test"
41
46
  Requires-Dist: tokenizers; extra == "test"
42
- Requires-Dist: fastapi; extra == "test"
43
- Requires-Dist: peft; extra == "test"
44
- Requires-Dist: json_repair; extra == "test"
45
- Requires-Dist: google-auth; extra == "test"
46
47
  Requires-Dist: transformers[sentencepiece]; extra == "test"
47
- Requires-Dist: tabulate; extra == "test"
48
- Requires-Dist: logfire[fastapi]; extra == "test"
49
- Requires-Dist: ollama; extra == "test"
50
- Requires-Dist: flet-video; extra == "test"
51
- Requires-Dist: deepmerge; extra == "test"
52
- Requires-Dist: sre_yield; extra == "test"
53
- Requires-Dist: pydantic; extra == "test"
54
- Requires-Dist: pydantic-ai[logfire,openai]; extra == "test"
55
- Requires-Dist: dask[bag]; extra == "test"
48
+ Requires-Dist: sentence_transformers; extra == "test"
56
49
  Requires-Dist: google-auth-httplib2; extra == "test"
50
+ Requires-Dist: pymupdf4llm; extra == "test"
51
+ Requires-Dist: torchaudio; extra == "test"
52
+ Requires-Dist: google-auth; extra == "test"
53
+ Requires-Dist: diskcache; extra == "test"
54
+ Requires-Dist: fastapi; extra == "test"
55
+ Requires-Dist: openpyxl; extra == "test"
56
+ Requires-Dist: torchvision; extra == "test"
57
57
  Provides-Extra: yaml
58
- Requires-Dist: pyyaml; extra == "yaml"
58
+ Requires-Dist: yamlscript; extra == "yaml"
59
59
  Provides-Extra: logging
60
60
  Requires-Dist: logfire; extra == "logging"
61
61
  Requires-Dist: semver; extra == "logging"
@@ -1,4 +1,4 @@
1
- fmtr/tools/__init__.py,sha256=_p8-qJSEfrdI5Kc1tTQ7RzIk7dbAcJ9yf0lpLEN4n80,5196
1
+ fmtr/tools/__init__.py,sha256=l1hbOcGF5ET8uHUBiIMHenu4MUTIEcc45XhLp8__mog,5243
2
2
  fmtr/tools/api_tools.py,sha256=w8Zrp_EwN5KlUghwLoTCXo4z1irg5tAsReCqDLjASfE,2133
3
3
  fmtr/tools/async_tools.py,sha256=ewz757WcveQJd-G5SVr2JDOQVbdLGecCgl-tsBGVZz4,284
4
4
  fmtr/tools/augmentation_tools.py,sha256=-6ESbO4CDlKqVOV1J1V6qBeoBMzbFIinkDHRHnCBej0,55
@@ -28,6 +28,7 @@ fmtr/tools/metric_tools.py,sha256=Lvia5CGFRIfrDFA8s37btIfTU5zHbo04cPJdAMtbndQ,27
28
28
  fmtr/tools/name_tools.py,sha256=5CB_phqhHjl66iI8oLxOGPF2odC1apdul-M8Fv2xBhs,5514
29
29
  fmtr/tools/netrc_tools.py,sha256=PpNpz_mWlQi6VHGromKwFfTyLpHUXsd4LY6-OKLCbeI,376
30
30
  fmtr/tools/openai_tools.py,sha256=6SUgejgzUzmlKKct2_ePXntvMegu3FJgfk9x7aqtqYc,742
31
+ fmtr/tools/packaging_tools.py,sha256=FlgOTnDRHZWQL2iR-wucTsyGEHRE-MlddKL30MPmUqE,253
31
32
  fmtr/tools/parallel_tools.py,sha256=QEb_gN1StkxsqYaH4HSjiJX8Y3gpb2uKNsOzG4uFpaM,3071
32
33
  fmtr/tools/path_tools.py,sha256=f4FOFhWdC5U1yeMtHPQatvXhs6cCTCC4RuPoLZo0kRE,7094
33
34
  fmtr/tools/pdf_tools.py,sha256=xvv9B84uAF81rFJRnXhSsxYuP42vY9ZdPVFrSMVe8G8,4069
@@ -43,11 +44,11 @@ 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=mTnviWxfu32TdnriwXIi9L7V08GJiIKe9xvXj3QQt_k,5
47
+ fmtr/tools/version,sha256=fwouFtO6CLpL2yNldE6I_4EcNV5NzZtvFNNjL9rePsc,6
47
48
  fmtr/tools/version_tools.py,sha256=yNs_CGqWpqE4jbK9wsPIi14peJVXYbhIcMqHAFOw3yE,1480
48
- fmtr/tools/yaml_tools.py,sha256=Ol43ZwbnSXGnn1K98Uxx61KPGSqfC4axE-X2q1LKMwk,349
49
+ fmtr/tools/yaml_tools.py,sha256=RVm-PuTv5XNneMea9iZ-x-oI3UdpbLi2-KA0rSf2ybk,1537
49
50
  fmtr/tools/ai_tools/__init__.py,sha256=JZrLuOFNV1A3wvJgonxOgz_4WS-7MfCuowGWA5uYCjs,372
50
- fmtr/tools/ai_tools/agentic_tools.py,sha256=pHmsWixulpIBEoIQvamfkQT9BDJ39unqS9ndVw0JVUw,3477
51
+ fmtr/tools/ai_tools/agentic_tools.py,sha256=YebH7R9ovVo3GzfWAZxY49e2fNt13APDMe290xx7zks,3720
51
52
  fmtr/tools/ai_tools/inference_tools.py,sha256=yF8Oxph0L8W2CnK_o-MVztBhWVwBpgOEkx9_m3uqQww,11840
52
53
  fmtr/tools/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
54
  fmtr/tools/tests/conftest.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -57,9 +58,9 @@ fmtr/tools/tests/test_environment.py,sha256=iHaiMQfECYZPkPKwfuIZV9uHuWe3aE-p_dN_
57
58
  fmtr/tools/tests/test_json.py,sha256=IeSP4ziPvRcmS8kq7k9tHonC9rN5YYq9GSNT2ul6Msk,287
58
59
  fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g,2188
59
60
  fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
60
- fmtr_tools-1.1.8.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
61
- fmtr_tools-1.1.8.dist-info/METADATA,sha256=lRqf1T5nQM155_hTay8XZjAK5A7YukM321G73D4BSWw,14646
62
- fmtr_tools-1.1.8.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
63
- fmtr_tools-1.1.8.dist-info/entry_points.txt,sha256=e-eOW1Ml13tbxHC6Er1MnVOEDePeWw7DKwlE-l-gCY0,205
64
- fmtr_tools-1.1.8.dist-info/top_level.txt,sha256=t5341a8ii3n4RFizwTeXGmcq_pf4GqL1h9ylE5LIWRk,12
65
- fmtr_tools-1.1.8.dist-info/RECORD,,
61
+ fmtr_tools-1.1.10.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
62
+ fmtr_tools-1.1.10.dist-info/METADATA,sha256=syY6z8ssJ9lkXfiUgexn8tnVX6yo_gYY4ICnmG2kVgs,14655
63
+ fmtr_tools-1.1.10.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
64
+ fmtr_tools-1.1.10.dist-info/entry_points.txt,sha256=e-eOW1Ml13tbxHC6Er1MnVOEDePeWw7DKwlE-l-gCY0,205
65
+ fmtr_tools-1.1.10.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
66
+ fmtr_tools-1.1.10.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ fmtr
@@ -1,2 +0,0 @@
1
- docker
2
- fmtr