fmtr.tools 1.3.52__py3-none-any.whl → 1.3.54__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
@@ -21,6 +21,7 @@ import fmtr.tools.string_tools as string
21
21
  from fmtr.tools import ai_tools as ai
22
22
  from fmtr.tools import datetime_tools as dt
23
23
  from fmtr.tools import dns_tools as dns
24
+ from fmtr.tools import docker_tools as docker
24
25
  from fmtr.tools import interface_tools as interface
25
26
  from fmtr.tools import version_tools as version
26
27
  from fmtr.tools.constants import Constants
@@ -40,11 +41,6 @@ try:
40
41
  except ModuleNotFoundError as exception:
41
42
  yaml = MissingExtraMockModule('yaml', exception)
42
43
 
43
- try:
44
- from fmtr.tools import docker_tools as docker
45
- from fmtr.tools.docker_tools import Container
46
- except ModuleNotFoundError as exception:
47
- docker = Container = MissingExtraMockModule('docker.api', exception)
48
44
 
49
45
  try:
50
46
  from fmtr.tools import parallel_tools as parallel
@@ -1,10 +1,12 @@
1
1
  import pydantic_ai
2
2
  from pydantic import PlainValidator
3
3
  from pydantic_ai import RunContext, ModelRetry
4
+ from pydantic_ai._output import OutputDataT
4
5
  from pydantic_ai.agent import AgentRunResult, Agent
5
6
  from pydantic_ai.models.openai import OpenAIModel
6
7
  from pydantic_ai.providers.openai import OpenAIProvider
7
- from typing import List, Optional, Any, Annotated
8
+ from pydantic_ai.tools import AgentDepsT
9
+ from typing import List, Optional, Any, Annotated, Generic
8
10
 
9
11
  from fmtr.tools import environment_tools as env
10
12
  from fmtr.tools.constants import Constants
@@ -25,15 +27,16 @@ class Validator:
25
27
  raise NotImplementedError()
26
28
 
27
29
 
28
-
29
-
30
- class Task:
30
+ class Task(Generic[AgentDepsT, OutputDataT]):
31
31
  """
32
32
 
33
33
  Linear task definition, as Agent configuration and typing, plus state history.
34
34
 
35
35
  """
36
36
 
37
+ TypeDeps = str
38
+ TypeOutput = str
39
+
37
40
  PROVIDER = OpenAIProvider(api_key=env.get(Constants.FMTR_OPENAI_API_KEY_KEY))
38
41
 
39
42
  API_HOST_FMTR = env.get(Constants.FMTR_AI_HOST_KEY, Constants.FMTR_AI_HOST_DEFAULT)
@@ -43,8 +46,6 @@ class Task:
43
46
  MODEL_ID = 'gpt-4o'
44
47
  MODEL_ID_FMTR = 'qwen2.5-coder:14b'
45
48
  SYSTEM_PROMPT_STATIC = None
46
- DEPS_TYPE = str
47
- RESULT_TYPE = str
48
49
  RESULT_RETRIES = 5
49
50
  VALIDATORS: List[Validator] = []
50
51
 
@@ -56,13 +57,13 @@ class Task:
56
57
  """
57
58
 
58
59
  self.model = OpenAIModel(self.MODEL_ID, provider=self.PROVIDER)
59
- self.agent = Agent(
60
+ self.agent = Agent[AgentDepsT, OutputDataT](
60
61
  *args,
61
62
  model=self.model,
62
63
  system_prompt=self.SYSTEM_PROMPT_STATIC or [],
63
- deps_type=self.DEPS_TYPE,
64
- result_type=self.RESULT_TYPE,
65
- result_retries=self.RESULT_RETRIES,
64
+ deps_type=self.TypeDeps,
65
+ output_type=self.TypeOutput,
66
+ output_retries=self.RESULT_RETRIES,
66
67
  **kwargs
67
68
  )
68
69
 
@@ -80,7 +81,7 @@ class Task:
80
81
  import asyncio
81
82
  return asyncio.run
82
83
 
83
- async def run(self, *args, deps=None, **kwargs) -> AgentRunResult[RESULT_TYPE]:
84
+ async def run(self, *args, deps=None, **kwargs) -> AgentRunResult[OutputDataT]:
84
85
  """
85
86
 
86
87
  Run Agent with deps-relative user prompt and while storing history
@@ -90,7 +91,7 @@ class Task:
90
91
  self.history = result.all_messages()
91
92
  return result
92
93
 
93
- async def validate(self, ctx: RunContext[DEPS_TYPE], output: RESULT_TYPE) -> RESULT_TYPE:
94
+ async def validate(self, ctx: RunContext[AgentDepsT], output: OutputDataT) -> OutputDataT:
94
95
  """
95
96
 
96
97
  Aggregate any validation failures and combine them into a single ModelRetry exception
@@ -107,7 +108,7 @@ class Task:
107
108
 
108
109
  return output
109
110
 
110
- def get_prompt(self, deps: Optional[DEPS_TYPE]) -> Optional[str]:
111
+ def get_prompt(self, deps: Optional[AgentDepsT]) -> Optional[str]:
111
112
  """
112
113
 
113
114
  Dummy prompt generator
@@ -115,7 +116,7 @@ class Task:
115
116
  """
116
117
  return None
117
118
 
118
- def add_system_prompt(self, ctx: RunContext[DEPS_TYPE]) -> str | List[str]:
119
+ def add_system_prompt(self, ctx: RunContext[AgentDepsT]) -> str | List[str]:
119
120
  """
120
121
 
121
122
  Dummy system prompt append
@@ -181,7 +182,7 @@ if __name__ == '__main__':
181
182
  class TaskTest(Task):
182
183
  # PROVIDER = Task.PROVIDER_FMTR
183
184
  # MODEL_ID = 'qwen2.5-coder:14b'
184
- RESULT_TYPE = TestOutput
185
+ TypeOutput = TestOutput
185
186
  SYSTEM_PROMPT_STATIC = 'Tell the user jokes.'
186
187
 
187
188
  def add_system_prompt(self, ctx: RunContext[TestDeps]) -> str:
@@ -0,0 +1,6 @@
1
+ from fmtr.tools.import_tools import MissingExtraMockModule
2
+
3
+ try:
4
+ from python_on_whales import docker as client
5
+ except ModuleNotFoundError as exception:
6
+ client = MissingExtraMockModule('docker.client', exception)
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.3.52
1
+ 1.3.54
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.3.52
3
+ Version: 1.3.54
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
@@ -28,8 +28,8 @@ Provides-Extra: process
28
28
  Requires-Dist: logfire; extra == "process"
29
29
  Provides-Extra: profiling
30
30
  Requires-Dist: contexttimer; extra == "profiling"
31
- Provides-Extra: docker-api
32
- Requires-Dist: docker; extra == "docker-api"
31
+ Provides-Extra: docker-client
32
+ Requires-Dist: python-on-whales; extra == "docker-client"
33
33
  Provides-Extra: unicode
34
34
  Requires-Dist: Unidecode; extra == "unicode"
35
35
  Provides-Extra: version
@@ -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: 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"
157
+ Requires-Dist: pyyaml; extra == "all"
158
+ Requires-Dist: google-api-python-client; extra == "all"
170
159
  Requires-Dist: openpyxl; extra == "all"
171
- Requires-Dist: filetype; extra == "all"
172
- Requires-Dist: logfire; extra == "all"
173
- Requires-Dist: logfire[httpx]; extra == "all"
174
- Requires-Dist: playwright; extra == "all"
160
+ Requires-Dist: google-auth-httplib2; extra == "all"
161
+ Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
162
+ Requires-Dist: tokenizers; extra == "all"
175
163
  Requires-Dist: semver; extra == "all"
176
- Requires-Dist: yamlscript; extra == "all"
177
- Requires-Dist: flet-video; extra == "all"
178
- Requires-Dist: google-auth; extra == "all"
179
164
  Requires-Dist: fastapi; extra == "all"
180
- Requires-Dist: dask[bag]; extra == "all"
181
- Requires-Dist: docker; extra == "all"
182
- Requires-Dist: huggingface_hub; extra == "all"
183
- Requires-Dist: dnspython[doh]; extra == "all"
184
- Requires-Dist: pytest-cov; extra == "all"
185
- Requires-Dist: deepmerge; 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"
190
- Requires-Dist: ollama; extra == "all"
191
- Requires-Dist: tabulate; extra == "all"
165
+ Requires-Dist: google-auth; extra == "all"
192
166
  Requires-Dist: cachetools; extra == "all"
193
- Requires-Dist: pyyaml; extra == "all"
194
- Requires-Dist: httpx; extra == "all"
195
- Requires-Dist: sentence_transformers; extra == "all"
196
- Requires-Dist: json_repair; extra == "all"
197
- Requires-Dist: diskcache; extra == "all"
167
+ Requires-Dist: distributed; extra == "all"
168
+ Requires-Dist: sre_yield; extra == "all"
169
+ Requires-Dist: contexttimer; extra == "all"
170
+ Requires-Dist: setuptools; extra == "all"
171
+ Requires-Dist: motor; extra == "all"
172
+ Requires-Dist: tinynetrc; extra == "all"
173
+ Requires-Dist: uvicorn[standard]; extra == "all"
174
+ Requires-Dist: html2text; extra == "all"
198
175
  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
176
  Requires-Dist: bokeh; extra == "all"
203
- Requires-Dist: setuptools; extra == "all"
177
+ Requires-Dist: pydantic-extra-types; extra == "all"
178
+ Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
179
+ Requires-Dist: logfire; extra == "all"
180
+ Requires-Dist: dnspython[doh]; extra == "all"
181
+ Requires-Dist: Unidecode; extra == "all"
182
+ Requires-Dist: torchaudio; extra == "all"
183
+ Requires-Dist: yamlscript; extra == "all"
184
+ Requires-Dist: huggingface_hub; extra == "all"
185
+ Requires-Dist: logfire[fastapi]; extra == "all"
204
186
  Requires-Dist: pydantic-settings; extra == "all"
205
- Requires-Dist: google-auth-httplib2; extra == "all"
206
187
  Requires-Dist: transformers[sentencepiece]; extra == "all"
207
- Requires-Dist: Unidecode; extra == "all"
208
- Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
188
+ Requires-Dist: logfire[httpx]; extra == "all"
189
+ Requires-Dist: faker; extra == "all"
190
+ Requires-Dist: tabulate; extra == "all"
209
191
  Requires-Dist: torchvision; extra == "all"
192
+ Requires-Dist: pandas; extra == "all"
193
+ Requires-Dist: json_repair; extra == "all"
194
+ Requires-Dist: appdirs; extra == "all"
195
+ Requires-Dist: dask[bag]; extra == "all"
196
+ Requires-Dist: beanie[odm]; extra == "all"
197
+ Requires-Dist: flet-video; extra == "all"
198
+ Requires-Dist: diskcache; extra == "all"
199
+ Requires-Dist: filetype; extra == "all"
200
+ Requires-Dist: deepdiff; extra == "all"
201
+ Requires-Dist: playwright; extra == "all"
202
+ Requires-Dist: ollama; extra == "all"
203
+ Requires-Dist: python-on-whales; extra == "all"
204
+ Requires-Dist: regex; extra == "all"
205
+ Requires-Dist: pycountry; extra == "all"
206
+ Requires-Dist: flet[all]; extra == "all"
207
+ Requires-Dist: peft; extra == "all"
208
+ Requires-Dist: pymupdf4llm; extra == "all"
209
+ Requires-Dist: httpx; extra == "all"
210
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
211
  Requires-Dist: odfpy; extra == "all"
217
- Requires-Dist: motor; extra == "all"
218
- Requires-Dist: deepdiff; extra == "all"
212
+ Requires-Dist: pytest-cov; extra == "all"
213
+ Requires-Dist: deepmerge; extra == "all"
214
+ Requires-Dist: openai; extra == "all"
215
+ Requires-Dist: sentence_transformers; extra == "all"
216
+ Requires-Dist: httpx_retries; extra == "all"
217
+ Requires-Dist: flet-webview; extra == "all"
218
+ Requires-Dist: pymupdf; extra == "all"
219
219
  Dynamic: author
220
220
  Dynamic: author-email
221
221
  Dynamic: description
@@ -1,4 +1,4 @@
1
- fmtr/tools/__init__.py,sha256=MwGzpdPZJq-ts-KVcq3tTnHlqLUEDEdbt_xD2Dq5Mmw,6125
1
+ fmtr/tools/__init__.py,sha256=Qh3jGKdC3MMZd7vQvIlrhZ0U7oTcTpBueX39VZwxX4U,5952
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
@@ -10,7 +10,6 @@ fmtr/tools/dataclass_tools.py,sha256=0Gt6KeLhtPgubo_2tYkIVqB8oQ91Qzag8OAGZDdjvMU
10
10
  fmtr/tools/datatype_tools.py,sha256=3P4AWIFGkJ-UqvXlj0Jc9IvkIIgTOE9jRrOk3NVbpH8,1508
11
11
  fmtr/tools/datetime_tools.py,sha256=StliYw51ZXi-miVB4O9Ps0zI6wsT_nbWhIb6R2ybNuo,330
12
12
  fmtr/tools/debugging_tools.py,sha256=_xzqS0V5BpL8d06j-jVQjGgI7T020QsqVXKAKMz7Du8,2082
13
- fmtr/tools/docker_tools.py,sha256=rdaZje2xhlmnfQqZnR7IHgRdWncTLjrJcViUTt5oEwk,617
14
13
  fmtr/tools/environment_tools.py,sha256=43uqfj1G1bNX0IwKz-NKbu3AbFYSdbBuGN9rlThe030,1845
15
14
  fmtr/tools/function_tools.py,sha256=O1K8HwftXfzrBblNZrj-BhWNbr4poJghrXNr2mFcylI,2831
16
15
  fmtr/tools/google_api_tools.py,sha256=QUungBoj5SCaBQnMjn9QpXtWmdNCplbw8ZPK9LXi77U,1691
@@ -46,11 +45,11 @@ fmtr/tools/tabular_tools.py,sha256=mw6vOij1Ch-pVAyHMPtm5zj__ULZN_TKeBYOfj33wFM,1
46
45
  fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
47
46
  fmtr/tools/tools.py,sha256=CAsApa1YwVdNE6H66Vjivs_mXYvOas3rh7fPELAnTpk,795
48
47
  fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
49
- fmtr/tools/version,sha256=6mg-f0Dob6XPK21vB0XIalETo4iilcVpjzUomZIQS3Y,6
48
+ fmtr/tools/version,sha256=e7sG0pzqTEZCFyq-p4XV7ZnrBdiNXOVK9wniHT6cbaA,6
50
49
  fmtr/tools/webhook_tools.py,sha256=q3pVJ1NCem2SrMuFcLxiWd7DibFs7Q-uGtojfXd3Qcg,380
51
50
  fmtr/tools/yaml_tools.py,sha256=Bhhyd6GQVKO72Lp8ky7bAUjIB_65Hdh0Q45SKIEe6S8,1901
52
51
  fmtr/tools/ai_tools/__init__.py,sha256=O8VRlPnnQCncg2ZZ2l_VdWLJf4jkKH6dkZFVbv6o7IM,388
53
- fmtr/tools/ai_tools/agentic_tools.py,sha256=aLejbLSmftXQpxnt1Kgia9UcCmj108U1pqOiAUI6l_I,4939
52
+ fmtr/tools/ai_tools/agentic_tools.py,sha256=-bYP5Kjlz1E75CDBW_qZEQjVWegyx_7BOgqx8C5vWl0,5089
54
53
  fmtr/tools/ai_tools/inference_tools.py,sha256=2UP2gXEyOJUjyyV6zmFIYmIxUsh1rXkRH0IbFvr2bRs,11908
55
54
  fmtr/tools/database_tools/__init__.py,sha256=-YXEs3P4nwg7hdvALpaW4K2Pg9FIc49rD53smqnBgT4,221
56
55
  fmtr/tools/database_tools/document.py,sha256=QLW-Ll2uVp1UTjA4leiJ3gtrUJHQPzwpFT_AZ3jow3A,812
@@ -59,6 +58,7 @@ fmtr/tools/dns_tools/client.py,sha256=IBbd7Xgx9ExTn_EPoL7ts9JfXokHHuOiD9m4K6tl1Q
59
58
  fmtr/tools/dns_tools/dm.py,sha256=Lp1HaF7rpVtL_Ji4Bd32B29105H9ZKQ8AcVj_AB7nsA,6678
60
59
  fmtr/tools/dns_tools/proxy.py,sha256=gCWfH1pyWjj8xnJ8Pm4id7bsBWqcar3dQ9PeP5XjRXY,1624
61
60
  fmtr/tools/dns_tools/server.py,sha256=_Y5w5bGHhBI32fYWl-SmnOALAw_eF9fEbmrOqqgzSq8,4263
61
+ fmtr/tools/docker_tools/__init__.py,sha256=yEw5v6aqA_PSiEu7uTvq2DhXiZ2DmA9LqV4R7qAxI_4,220
62
62
  fmtr/tools/entrypoints/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  fmtr/tools/entrypoints/cache_hfh.py,sha256=fQNs4J9twQuZH_Yj98-oOvEX7-LrSUP3kO8nzw2HrHs,60
64
64
  fmtr/tools/entrypoints/ep_test.py,sha256=B8HfWISfSgw_xVX475CbJGh_QnpOe9MH65H8qGjTWbY,46
@@ -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.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,,
88
+ fmtr_tools-1.3.54.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
+ fmtr_tools-1.3.54.dist-info/METADATA,sha256=nDQPMFGoVatq6bJ8vS-uIKTVV9fgQA5zwQHhUuO9uWw,17455
90
+ fmtr_tools-1.3.54.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
+ fmtr_tools-1.3.54.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
+ fmtr_tools-1.3.54.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
+ fmtr_tools-1.3.54.dist-info/RECORD,,
@@ -1,30 +0,0 @@
1
- import contextlib
2
- import docker
3
-
4
-
5
- @contextlib.contextmanager
6
- def Container(image, ports=None, name=None, **kwargs):
7
- """
8
-
9
- Run a Docker container in a context manager
10
-
11
- """
12
- client = docker.from_env()
13
-
14
- try:
15
- container = client.containers.get(name)
16
- container.stop()
17
- container.remove()
18
- except docker.errors.NotFound:
19
- pass
20
-
21
- ports = {f'{port}/tcp': port for port in ports}
22
- container = client.containers.run(image, ports=ports, detach=True, name=name, **kwargs)
23
-
24
- try:
25
- yield container
26
- finally:
27
- container.stop()
28
- container.remove()
29
-
30
-