fmtr.tools 1.0.30__tar.gz → 1.0.31__tar.gz

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.

Files changed (67) hide show
  1. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/PKG-INFO +2 -2
  2. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/README.md +1 -1
  3. fmtr.tools-1.0.31/fmtr/tools/interface_tools.py +64 -0
  4. fmtr.tools-1.0.31/fmtr/tools/version +1 -0
  5. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr.tools.egg-info/PKG-INFO +2 -2
  6. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr.tools.egg-info/requires.txt +6 -2
  7. fmtr.tools-1.0.30/fmtr/tools/interface_tools.py +0 -218
  8. fmtr.tools-1.0.30/fmtr/tools/version +0 -1
  9. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/LICENSE +0 -0
  10. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/__init__.py +0 -0
  11. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/ai_tools.py +0 -0
  12. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/api_tools.py +0 -0
  13. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/async_tools.py +0 -0
  14. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/augmentation_tools.py +0 -0
  15. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/caching_tools.py +0 -0
  16. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/config.py +0 -0
  17. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/config_tools.py +0 -0
  18. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/console_script_tools.py +0 -0
  19. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/data_modelling_tools.py +0 -0
  20. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/dataclass_tools.py +0 -0
  21. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/datatype_tools.py +0 -0
  22. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/docker_tools.py +0 -0
  23. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/environment_tools.py +0 -0
  24. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/function_tools.py +0 -0
  25. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/google_api_tools.py +0 -0
  26. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/hash_tools.py +0 -0
  27. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/hfh_tools.py +0 -0
  28. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/html_tools.py +0 -0
  29. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/import_tools.py +0 -0
  30. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/inspection_tools.py +0 -0
  31. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/iterator_tools.py +0 -0
  32. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/json_fix_tools.py +0 -0
  33. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/json_tools.py +0 -0
  34. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/logging_tools.py +0 -0
  35. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/merging_tools.py +0 -0
  36. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/metric_tools.py +0 -0
  37. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/name_tools.py +0 -0
  38. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/netrc_tools.py +0 -0
  39. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/openai_tools.py +0 -0
  40. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/parallel_tools.py +0 -0
  41. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/path_tools.py +0 -0
  42. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/platform_tools.py +0 -0
  43. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/process_tools.py +0 -0
  44. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/profiling_tools.py +0 -0
  45. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/random_tools.py +0 -0
  46. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/semantic_tools.py +0 -0
  47. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/spaces_tools.py +0 -0
  48. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/string_tools.py +0 -0
  49. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/__init__.py +0 -0
  50. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/conftest.py +0 -0
  51. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/helpers.py +0 -0
  52. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/test_datatype.py +0 -0
  53. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/test_environment.py +0 -0
  54. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/test_json.py +0 -0
  55. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/test_path.py +0 -0
  56. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tests/test_yaml.py +0 -0
  57. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tokenization_tools.py +0 -0
  58. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/tools.py +0 -0
  59. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/unicode_tools.py +0 -0
  60. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/version_tools.py +0 -0
  61. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr/tools/yaml_tools.py +0 -0
  62. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr.tools.egg-info/SOURCES.txt +0 -0
  63. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr.tools.egg-info/dependency_links.txt +0 -0
  64. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr.tools.egg-info/entry_points.txt +0 -0
  65. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/fmtr.tools.egg-info/top_level.txt +0 -0
  66. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/setup.cfg +0 -0
  67. {fmtr.tools-1.0.30 → fmtr.tools-1.0.31}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fmtr.tools
3
- Version: 1.0.30
3
+ Version: 1.0.31
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
@@ -140,7 +140,7 @@ The included modules, plus any extra requirements, are as follows:
140
140
  - Extras: `hfh`
141
141
  - `tools.html`: Utilities for converting HTML documents to plain text.
142
142
  - Extras: `html`
143
- - `tools.interface`: Provides a base class for building Streamlit interfaces with a class-based structure.
143
+ - `tools.interface`: Provides a base class for building Flutter/Flet apps.
144
144
  - Extras: `interface`
145
145
  - `tools.iterator`: Pivoting/unpivoting data structures
146
146
  - Extras: None
@@ -102,7 +102,7 @@ The included modules, plus any extra requirements, are as follows:
102
102
  - Extras: `hfh`
103
103
  - `tools.html`: Utilities for converting HTML documents to plain text.
104
104
  - Extras: `html`
105
- - `tools.interface`: Provides a base class for building Streamlit interfaces with a class-based structure.
105
+ - `tools.interface`: Provides a base class for building Flutter/Flet apps.
106
106
  - Extras: `interface`
107
107
  - `tools.iterator`: Pivoting/unpivoting data structures
108
108
  - Extras: None
@@ -0,0 +1,64 @@
1
+ import flet as ft
2
+ from flet.core.event import Event
3
+ from flet.core.types import AppView
4
+ from flet.core.view import View
5
+
6
+ from fmtr.tools.logging_tools import logger
7
+
8
+
9
+ class Interface:
10
+ """
11
+
12
+ Simple interface base class.
13
+
14
+ """
15
+ TITLE = 'Base Interface'
16
+ HOST = '0.0.0.0'
17
+ PORT = 8080
18
+ APPVIEW = AppView.WEB_BROWSER
19
+ PATH_ASSETS = None
20
+ ROUTE_ROOT = '/'
21
+
22
+ def render(self, page: ft.Page):
23
+ """
24
+
25
+ Interface entry point.
26
+
27
+ """
28
+
29
+ if not page.on_route_change:
30
+ page.on_route_change = lambda e, page=page: self.route(page, e)
31
+ page.on_view_pop = lambda view, page=page: self.pop(page, view)
32
+
33
+ page.go(self.ROUTE_ROOT)
34
+
35
+ def route(self, page: ft.Page, event: Event):
36
+ """
37
+
38
+ Overridable router.
39
+
40
+ """
41
+ raise NotImplementedError
42
+
43
+ def pop(self, page: ft.Page, view: View):
44
+ """
45
+
46
+ Overridable view pop.
47
+
48
+ """
49
+ raise NotImplementedError
50
+
51
+ @classmethod
52
+ def launch(cls):
53
+ """
54
+
55
+ Initialise self and launch.
56
+
57
+ """
58
+ self = cls()
59
+ logger.info(f"Launching {self.TITLE} at http://{self.HOST}:{self.PORT}")
60
+ ft.app(self.render, view=self.APPVIEW, host=self.HOST, port=self.PORT, assets_dir=self.PATH_ASSETS)
61
+
62
+
63
+ if __name__ == "__main__":
64
+ Interface.launch()
@@ -0,0 +1 @@
1
+ 1.0.31
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fmtr.tools
3
- Version: 1.0.30
3
+ Version: 1.0.31
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
@@ -140,7 +140,7 @@ The included modules, plus any extra requirements, are as follows:
140
140
  - Extras: `hfh`
141
141
  - `tools.html`: Utilities for converting HTML documents to plain text.
142
142
  - Extras: `html`
143
- - `tools.interface`: Provides a base class for building Streamlit interfaces with a class-based structure.
143
+ - `tools.interface`: Provides a base class for building Flutter/Flet apps.
144
144
  - Extras: `interface`
145
145
  - `tools.iterator`: Pivoting/unpivoting data structures
146
146
  - Extras: None
@@ -47,8 +47,10 @@ huggingface_hub
47
47
  html2text
48
48
 
49
49
  [interface]
50
+ flet-video
51
+ flet-webview
52
+ flet[all]
50
53
  pydantic
51
- streamlit
52
54
 
53
55
  [json-fix]
54
56
  json_repair
@@ -99,6 +101,9 @@ distributed
99
101
  docker
100
102
  faker
101
103
  fastapi
104
+ flet-video
105
+ flet-webview
106
+ flet[all]
102
107
  google-api-python-client
103
108
  google-auth
104
109
  google-auth-httplib2
@@ -118,7 +123,6 @@ pyyaml
118
123
  semver
119
124
  sentence_transformers
120
125
  sre_yield
121
- streamlit
122
126
  tinynetrc
123
127
  tokenizers
124
128
  torchaudio
@@ -1,218 +0,0 @@
1
- from time import sleep
2
- from typing import ClassVar
3
-
4
- from fmtr.tools.data_modelling_tools import Base
5
- from fmtr.tools.logging_tools import logger
6
- from fmtr.tools.path_tools import Path
7
-
8
-
9
- def material(name):
10
- """
11
-
12
- Get Material Design icon markdown
13
-
14
- """
15
- return f":material/{name}:"
16
-
17
-
18
- def color(name, text):
19
- """
20
-
21
- Get markdown coloured text
22
-
23
- """
24
- return f":{name}[{text}]"
25
-
26
-
27
- def get_streamlit():
28
- import streamlit
29
- return streamlit
30
-
31
- class Interface(Base):
32
- """
33
-
34
- Base for using streamlit via classes
35
-
36
- """
37
-
38
- PATH: ClassVar = __file__
39
- LAYOUT: ClassVar = 'centered'
40
- NAME: ClassVar = None
41
- IS_ASYNC: ClassVar = False
42
-
43
- parent: Base = None
44
-
45
- @property
46
- def st(self):
47
- return get_streamlit()
48
-
49
- @classmethod
50
- def get_name(cls):
51
- return cls.NAME or cls.__name__
52
-
53
- def set_title(self):
54
- """
55
-
56
- Set page title and layout when root interface
57
-
58
- """
59
-
60
- self.st.set_page_config(page_title=self.get_name(), layout=self.LAYOUT)
61
- self.st.title(self.get_name())
62
-
63
- def render(self):
64
- """
65
-
66
- Render the Interface
67
-
68
- """
69
- raise NotImplementedError()
70
-
71
- def get_key(self, seg=None):
72
- """
73
-
74
- Get a structure-friendly unique ID
75
-
76
- """
77
-
78
- suffix = f'{self.__class__.__name__}({self.get_key_self()})'
79
-
80
- if self.parent is None:
81
- base = Path(suffix)
82
- else:
83
- base = self.parent.get_key() / suffix
84
-
85
- if seg:
86
- path = base / seg
87
- else:
88
- path = base
89
-
90
- return path
91
-
92
- def get_url_data(self):
93
- """
94
-
95
- Get URL params data pertaining to the current object
96
-
97
- """
98
-
99
- if self.parent is None:
100
- data = {}
101
- else:
102
- data = self.parent.get_url_data()
103
-
104
- url_self = self.get_url_self()
105
-
106
- if url_self:
107
- data |= {self.__class__.__name__.lower(): url_self}
108
-
109
- return data
110
-
111
- def get_url_self(self):
112
- """
113
-
114
- Get URL params ID pertaining to the current object
115
-
116
- """
117
- return str(id(self))
118
-
119
- def get_key_self(self):
120
- """
121
-
122
- Get a streamlit key pertaining to the current object
123
-
124
- """
125
- return str(id(self))
126
-
127
- def get_url(self):
128
- """
129
-
130
- Get URL string suffix pertaining to the current object
131
-
132
- """
133
- import urllib
134
- return urllib.parse.urlencode(self.get_url_data())
135
-
136
- def to_tabs(self, *classes):
137
- """
138
-
139
- Add tabs from a list of interface classes
140
-
141
- """
142
- tab_names = [cls.get_name() for cls in classes]
143
- tabs = st.tabs(tab_names)
144
-
145
- for cls, tab in zip(classes, tabs):
146
- with tab:
147
- cls()
148
-
149
- @classmethod
150
- def is_streamlit(cls):
151
- """
152
-
153
- Infer whether we are running within StreamLit
154
-
155
- """
156
- return bool(get_streamlit().context.headers)
157
-
158
- @classmethod
159
- def get_state(cls):
160
- """
161
-
162
- Initialise this Interface and keep cached. This needs to be a cached_resource to avoid serialisation/copying.
163
- This is global, so session handling needs to happen downstream.
164
-
165
- """
166
- msg = f'Initialising State "{cls.get_name()}"...'
167
- logger.info(msg)
168
- self = cls()
169
- return self
170
-
171
- @classmethod
172
- def launch(cls):
173
- """
174
-
175
- Launch StreamLit, if not already running - otherwise get self from cache and render
176
-
177
- """
178
-
179
- st = get_streamlit()
180
-
181
- if cls.is_streamlit():
182
-
183
- if cls.IS_ASYNC:
184
- from fmtr.tools import async_tools
185
- async_tools.ensure_loop()
186
-
187
- self = st.cache_resource(show_spinner=False)(cls.get_state)()
188
- logger.debug(f'Rendering Interface "{self.get_name()}" with state: {st.session_state}...')
189
- self.set_title()
190
- self.render()
191
- else:
192
- logger.info(f'Launching Streamlit interface "{cls.get_name()}"...')
193
- from streamlit.web import bootstrap
194
- bootstrap.run(cls.PATH, False, [], {})
195
-
196
-
197
- class InterfaceTest(Interface):
198
- NAME: ClassVar = 'Test Interface'
199
-
200
- parent: Base = None
201
-
202
- def render(self):
203
- """
204
-
205
- Render the Interface
206
-
207
- """
208
- if not self.st.button('Run Test'):
209
- return
210
- msg = 'Running test...'
211
- with self.st.spinner(msg):
212
- sleep(3)
213
- self.st.success("Success!")
214
-
215
-
216
- if __name__ == '__main__':
217
- InterfaceTest.launch()
218
-
@@ -1 +0,0 @@
1
- 1.0.30
File without changes
File without changes
File without changes