pieui 0.1.0__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.
Files changed (76) hide show
  1. pieui-0.1.0/PKG-INFO +230 -0
  2. pieui-0.1.0/README.md +208 -0
  3. pieui-0.1.0/pie/__init__.py +27 -0
  4. pieui-0.1.0/pie/__main__.py +99 -0
  5. pieui-0.1.0/pie/async_page.py +381 -0
  6. pieui-0.1.0/pie/card.py +218 -0
  7. pieui-0.1.0/pie/cli.py +244 -0
  8. pieui-0.1.0/pie/code/__init__.py +8 -0
  9. pieui-0.1.0/pie/code/build.py +26 -0
  10. pieui-0.1.0/pie/code/card_add.py +87 -0
  11. pieui-0.1.0/pie/code/create.py +64 -0
  12. pieui-0.1.0/pie/code/services/__init__.py +3 -0
  13. pieui-0.1.0/pie/code/services/models.py +13 -0
  14. pieui-0.1.0/pie/code/services/storage.py +379 -0
  15. pieui-0.1.0/pie/code/templates/pages/components/ajax_complex_component.py.j2 +14 -0
  16. pieui-0.1.0/pie/code/templates/pages/components/ajax_complex_container_component.py.j2 +14 -0
  17. pieui-0.1.0/pie/code/templates/pages/components/ajax_component.py.j2 +13 -0
  18. pieui-0.1.0/pie/code/templates/pages/components/ajax_container_component.py.j2 +14 -0
  19. pieui-0.1.0/pie/code/templates/pages/components/ajax_io_complex_component.py.j2 +19 -0
  20. pieui-0.1.0/pie/code/templates/pages/components/ajax_io_complex_container_component.py.j2 +19 -0
  21. pieui-0.1.0/pie/code/templates/pages/components/ajax_io_component.py.j2 +18 -0
  22. pieui-0.1.0/pie/code/templates/pages/components/ajax_io_container_component.py.j2 +18 -0
  23. pieui-0.1.0/pie/code/templates/pages/components/complex_component.py.j2 +9 -0
  24. pieui-0.1.0/pie/code/templates/pages/components/complex_container_component.py.j2 +10 -0
  25. pieui-0.1.0/pie/code/templates/pages/components/component.py.j2 +8 -0
  26. pieui-0.1.0/pie/code/templates/pages/components/container_component.py.j2 +10 -0
  27. pieui-0.1.0/pie/code/templates/pages/components/input_ajax_complex_component.py.j2 +17 -0
  28. pieui-0.1.0/pie/code/templates/pages/components/input_ajax_complex_container_component.py.j2 +17 -0
  29. pieui-0.1.0/pie/code/templates/pages/components/input_ajax_component.py.j2 +16 -0
  30. pieui-0.1.0/pie/code/templates/pages/components/input_ajax_io_complex_component.py.j2 +22 -0
  31. pieui-0.1.0/pie/code/templates/pages/components/input_ajax_io_complex_container_component.py.j2 +22 -0
  32. pieui-0.1.0/pie/code/templates/pages/components/input_ajax_io_component.py.j2 +21 -0
  33. pieui-0.1.0/pie/code/templates/pages/components/input_complex_component.py.j2 +9 -0
  34. pieui-0.1.0/pie/code/templates/pages/components/input_complex_container_component.py.j2 +10 -0
  35. pieui-0.1.0/pie/code/templates/pages/components/input_component.py.j2 +11 -0
  36. pieui-0.1.0/pie/code/templates/pages/components/input_io_complex_component.py.j2 +18 -0
  37. pieui-0.1.0/pie/code/templates/pages/components/input_io_complex_container_component.py.j2 +18 -0
  38. pieui-0.1.0/pie/code/templates/pages/components/input_io_component.py.j2 +17 -0
  39. pieui-0.1.0/pie/code/templates/pages/components/io_complex_component.py.j2 +15 -0
  40. pieui-0.1.0/pie/code/templates/pages/components/io_complex_container_component.py.j2 +15 -0
  41. pieui-0.1.0/pie/code/templates/pages/components/io_component.py.j2 +14 -0
  42. pieui-0.1.0/pie/code/templates/pages/components/io_container_component.py.j2 +15 -0
  43. pieui-0.1.0/pie/code/templates/pages/main.py.j2 +9 -0
  44. pieui-0.1.0/pie/code/templates/pages/page.py.j2 +0 -0
  45. pieui-0.1.0/pie/code/templates/web.py.j2 +26 -0
  46. pieui-0.1.0/pie/code/web.py +28 -0
  47. pieui-0.1.0/pie/components/__init__.py +0 -0
  48. pieui-0.1.0/pie/components/ajax_group.py +29 -0
  49. pieui-0.1.0/pie/components/hidden.py +40 -0
  50. pieui-0.1.0/pie/components/html_embed.py +70 -0
  51. pieui-0.1.0/pie/components/io_log.py +30 -0
  52. pieui-0.1.0/pie/components/one_of.py +28 -0
  53. pieui-0.1.0/pie/components/union.py +87 -0
  54. pieui-0.1.0/pie/config.py +24 -0
  55. pieui-0.1.0/pie/fastweb.py +1334 -0
  56. pieui-0.1.0/pie/hub/__init__.py +2 -0
  57. pieui-0.1.0/pie/hub/centrifuge_helpers/__init__.py +0 -0
  58. pieui-0.1.0/pie/hub/centrifuge_helpers/cent_client_wrapper.py +13 -0
  59. pieui-0.1.0/pie/hub/centrifuge_helpers/session_wrapper.py +69 -0
  60. pieui-0.1.0/pie/hub/checkpoint/__init__.py +12 -0
  61. pieui-0.1.0/pie/hub/checkpoint/archive.py +125 -0
  62. pieui-0.1.0/pie/hub/checkpoint/gdrive.py +42 -0
  63. pieui-0.1.0/pie/hub/checkpoint/mega_path.py +76 -0
  64. pieui-0.1.0/pie/hub/checkpoint/mega_url.py +16 -0
  65. pieui-0.1.0/pie/hub/checkpoint/path.py +16 -0
  66. pieui-0.1.0/pie/hub/checkpoint/pretrained_checkpoint.py +184 -0
  67. pieui-0.1.0/pie/hub/checkpoint/pretrained_jit_model.py +28 -0
  68. pieui-0.1.0/pie/hub/checkpoint/rclone.py +47 -0
  69. pieui-0.1.0/pie/hub/checkpoint/url.py +73 -0
  70. pieui-0.1.0/pie/hub/checkpoint/yadisk.py +12 -0
  71. pieui-0.1.0/pie/hub/svgpil/SVGImage.py +572 -0
  72. pieui-0.1.0/pie/hub/svgpil/__init__.py +0 -0
  73. pieui-0.1.0/pie/hub/svgpil/svg_stream.py +0 -0
  74. pieui-0.1.0/pie/hub/svgpil/test_draw.py +7 -0
  75. pieui-0.1.0/pie/types.py +83 -0
  76. pieui-0.1.0/pyproject.toml +49 -0
pieui-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.3
2
+ Name: pieui
3
+ Version: 0.1.0
4
+ Summary: CLI client for PieUI Storage.
5
+ Author: butusk0, DELTA37
6
+ Author-email: butusk0 <kirill.butusov@romanticai.com>, DELTA37 <gg_plastt@mail.ru>
7
+ Requires-Dist: jinja2>=3.1.0
8
+ Requires-Dist: adaptix>=3.0.0b12
9
+ Requires-Dist: dataclasses>=0.8
10
+ Requires-Dist: dataclasses-json>=0.6.7
11
+ Requires-Dist: fastapi>=0.136.0
12
+ Requires-Dist: httpx>=0.28.1
13
+ Requires-Dist: openai-agents>=0.14.2
14
+ Requires-Dist: python-dotenv>=1.2.2
15
+ Requires-Dist: cent>=5.2.0
16
+ Requires-Dist: fastapi-socketio>=0.0.10
17
+ Requires-Dist: jsonpatch>=1.33
18
+ Requires-Dist: dataclasses-jsonschema>=2.16.0
19
+ Requires-Dist: aiohttp>=3.13.5
20
+ Requires-Python: >=3.14
21
+ Description-Content-Type: text/markdown
22
+
23
+ # pie
24
+
25
+ Python CLI for Pie components.
26
+
27
+ The command surface follows the TypeScript `pieui` CLI:
28
+
29
+ ```text
30
+ init
31
+ add
32
+ remove
33
+ list
34
+ push
35
+ pull
36
+ remote-remove
37
+ list-events
38
+ add-event
39
+ postbuild
40
+ ```
41
+
42
+ Remote commands call the `pieui-storage` API:
43
+
44
+ ```text
45
+ push
46
+ pull
47
+ remote-remove
48
+ ```
49
+
50
+ ## Setup
51
+
52
+ ```bash
53
+ uv sync --python 3.14
54
+ cp .env.example .env
55
+ ```
56
+
57
+ Do not pin the project to `3.14.0b1`: current `pydantic`/`pydantic-settings`
58
+ break on that beta. `uv sync --python 3.14` creates a managed CPython 3.14.0
59
+ environment.
60
+
61
+ ## Config
62
+
63
+ The CLI reads `.env` with the `PIE_` prefix:
64
+
65
+ ```text
66
+ PIE_API_BASE_URL=http://localhost:8000/api
67
+ PIE_USER_ID=default-user
68
+ PIE_PROJECT_SLUG=default-project
69
+ PIE_COMPONENTS_DIR=piecomponents
70
+ PIE_TIMEOUT_SECONDS=30
71
+ PIE_API_KEY=dev-master-key
72
+ ```
73
+
74
+ `PIE_API_BASE_URL` must point to the API prefix of `pieui-storage`, for example:
75
+
76
+ ```bash
77
+ PIE_API_BASE_URL=http://localhost:8000/api
78
+ ```
79
+
80
+ `PIE_API_KEY` is sent to `pieui-storage` as the `x-api-key` header. The local
81
+ API default is `dev-master-key`.
82
+
83
+ ## Commands
84
+
85
+ ### init
86
+
87
+ Initialize the `piecomponents` directory:
88
+
89
+ ```bash
90
+ uv run pie init
91
+ uv run pie init --out-dir packages/app
92
+ uv run pie init -o packages/app
93
+ ```
94
+
95
+ ### add
96
+
97
+ Create a local Python component project under `piecomponents/<ComponentName>`:
98
+
99
+ ```bash
100
+ uv run pie add MyCustomCard
101
+ uv run pie add simple MySimpleCard
102
+ uv run pie add complex MyComplexCard
103
+ uv run pie add simple-container MySimpleContainerCard
104
+ uv run pie add complex-container MyContainerCard
105
+ ```
106
+
107
+ If the type is omitted, `complex-container` is used, matching the TypeScript CLI.
108
+
109
+ The generated template is a minimal `piedemo` web project:
110
+
111
+ ```text
112
+ piecomponents/MyCustomCard/
113
+ pyproject.toml
114
+ web.py
115
+ pages/
116
+ main.py
117
+ ```
118
+
119
+ `web.py` registers `MainPage` on the root route: `{"": MainPage()}`.
120
+ `pages/main.py` also contains `MainCard`, where component events are declared.
121
+
122
+ ### remove
123
+
124
+ Remove a local component directory:
125
+
126
+ ```bash
127
+ uv run pie remove MyCustomCard
128
+ ```
129
+
130
+ ### list
131
+
132
+ List local components:
133
+
134
+ ```bash
135
+ uv run pie list
136
+ uv run pie list simple
137
+ uv run pie list complex-container --src-dir app
138
+ uv run pie list complex-container -s app
139
+ ```
140
+
141
+ Accepted filters:
142
+
143
+ ```text
144
+ all
145
+ simple
146
+ complex
147
+ simple-container
148
+ complex-container
149
+ ```
150
+
151
+ ### push
152
+
153
+ Upload `piecomponents/<ComponentName>` to `pieui-storage`.
154
+
155
+ The storage API stores files under:
156
+
157
+ ```text
158
+ PIE_USER_ID/PIE_PROJECT_SLUG/<ComponentName>/python/*
159
+ ```
160
+
161
+ Command:
162
+
163
+ ```bash
164
+ uv run pie push MyCustomCard
165
+ ```
166
+
167
+ ### pull
168
+
169
+ Download Python files from `pieui-storage` into `piecomponents/<ComponentName>`:
170
+
171
+ ```bash
172
+ uv run pie pull MyCustomCard
173
+ ```
174
+
175
+ ### remote-remove
176
+
177
+ Delete the remote component from `pieui-storage`:
178
+
179
+ ```bash
180
+ uv run pie remote-remove MyCustomCard
181
+ ```
182
+
183
+ ### list-events
184
+
185
+ List events declared by `MainCard.get_supported_events()`:
186
+
187
+ ```bash
188
+ uv run pie list-events MyCustomCard
189
+ uv run pie list-events MyCustomCard --src-dir app
190
+ ```
191
+
192
+ ### add-event
193
+
194
+ Add a card event method and update `get_supported_events()`:
195
+
196
+ ```bash
197
+ uv run pie add-event MyCustomCard alert
198
+ uv run pie add-event MyCustomCard alert --src-dir app
199
+ ```
200
+
201
+ For `alert`, the command adds:
202
+
203
+ ```python
204
+ def create_alert_event(self, data: dict | None = None):
205
+ return self.create_event("alert", data or {})
206
+
207
+ def get_supported_events(self):
208
+ return [
209
+ "alert",
210
+ ]
211
+ ```
212
+
213
+ ### postbuild
214
+
215
+ Generate a manifest file:
216
+
217
+ ```bash
218
+ uv run pie postbuild
219
+ uv run pie postbuild --append --out-dir dist
220
+ uv run pie postbuild --src-dir src --out-dir public
221
+ ```
222
+
223
+ ## Project Layout
224
+
225
+ ```text
226
+ pie/cli.py CLI argument handling and command dispatch
227
+ pie/config.py pydantic-settings config loaded from .env
228
+ pie/models.py pydantic response models
229
+ pie/services/storage.py pieui-storage API client
230
+ ```
pieui-0.1.0/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # pie
2
+
3
+ Python CLI for Pie components.
4
+
5
+ The command surface follows the TypeScript `pieui` CLI:
6
+
7
+ ```text
8
+ init
9
+ add
10
+ remove
11
+ list
12
+ push
13
+ pull
14
+ remote-remove
15
+ list-events
16
+ add-event
17
+ postbuild
18
+ ```
19
+
20
+ Remote commands call the `pieui-storage` API:
21
+
22
+ ```text
23
+ push
24
+ pull
25
+ remote-remove
26
+ ```
27
+
28
+ ## Setup
29
+
30
+ ```bash
31
+ uv sync --python 3.14
32
+ cp .env.example .env
33
+ ```
34
+
35
+ Do not pin the project to `3.14.0b1`: current `pydantic`/`pydantic-settings`
36
+ break on that beta. `uv sync --python 3.14` creates a managed CPython 3.14.0
37
+ environment.
38
+
39
+ ## Config
40
+
41
+ The CLI reads `.env` with the `PIE_` prefix:
42
+
43
+ ```text
44
+ PIE_API_BASE_URL=http://localhost:8000/api
45
+ PIE_USER_ID=default-user
46
+ PIE_PROJECT_SLUG=default-project
47
+ PIE_COMPONENTS_DIR=piecomponents
48
+ PIE_TIMEOUT_SECONDS=30
49
+ PIE_API_KEY=dev-master-key
50
+ ```
51
+
52
+ `PIE_API_BASE_URL` must point to the API prefix of `pieui-storage`, for example:
53
+
54
+ ```bash
55
+ PIE_API_BASE_URL=http://localhost:8000/api
56
+ ```
57
+
58
+ `PIE_API_KEY` is sent to `pieui-storage` as the `x-api-key` header. The local
59
+ API default is `dev-master-key`.
60
+
61
+ ## Commands
62
+
63
+ ### init
64
+
65
+ Initialize the `piecomponents` directory:
66
+
67
+ ```bash
68
+ uv run pie init
69
+ uv run pie init --out-dir packages/app
70
+ uv run pie init -o packages/app
71
+ ```
72
+
73
+ ### add
74
+
75
+ Create a local Python component project under `piecomponents/<ComponentName>`:
76
+
77
+ ```bash
78
+ uv run pie add MyCustomCard
79
+ uv run pie add simple MySimpleCard
80
+ uv run pie add complex MyComplexCard
81
+ uv run pie add simple-container MySimpleContainerCard
82
+ uv run pie add complex-container MyContainerCard
83
+ ```
84
+
85
+ If the type is omitted, `complex-container` is used, matching the TypeScript CLI.
86
+
87
+ The generated template is a minimal `piedemo` web project:
88
+
89
+ ```text
90
+ piecomponents/MyCustomCard/
91
+ pyproject.toml
92
+ web.py
93
+ pages/
94
+ main.py
95
+ ```
96
+
97
+ `web.py` registers `MainPage` on the root route: `{"": MainPage()}`.
98
+ `pages/main.py` also contains `MainCard`, where component events are declared.
99
+
100
+ ### remove
101
+
102
+ Remove a local component directory:
103
+
104
+ ```bash
105
+ uv run pie remove MyCustomCard
106
+ ```
107
+
108
+ ### list
109
+
110
+ List local components:
111
+
112
+ ```bash
113
+ uv run pie list
114
+ uv run pie list simple
115
+ uv run pie list complex-container --src-dir app
116
+ uv run pie list complex-container -s app
117
+ ```
118
+
119
+ Accepted filters:
120
+
121
+ ```text
122
+ all
123
+ simple
124
+ complex
125
+ simple-container
126
+ complex-container
127
+ ```
128
+
129
+ ### push
130
+
131
+ Upload `piecomponents/<ComponentName>` to `pieui-storage`.
132
+
133
+ The storage API stores files under:
134
+
135
+ ```text
136
+ PIE_USER_ID/PIE_PROJECT_SLUG/<ComponentName>/python/*
137
+ ```
138
+
139
+ Command:
140
+
141
+ ```bash
142
+ uv run pie push MyCustomCard
143
+ ```
144
+
145
+ ### pull
146
+
147
+ Download Python files from `pieui-storage` into `piecomponents/<ComponentName>`:
148
+
149
+ ```bash
150
+ uv run pie pull MyCustomCard
151
+ ```
152
+
153
+ ### remote-remove
154
+
155
+ Delete the remote component from `pieui-storage`:
156
+
157
+ ```bash
158
+ uv run pie remote-remove MyCustomCard
159
+ ```
160
+
161
+ ### list-events
162
+
163
+ List events declared by `MainCard.get_supported_events()`:
164
+
165
+ ```bash
166
+ uv run pie list-events MyCustomCard
167
+ uv run pie list-events MyCustomCard --src-dir app
168
+ ```
169
+
170
+ ### add-event
171
+
172
+ Add a card event method and update `get_supported_events()`:
173
+
174
+ ```bash
175
+ uv run pie add-event MyCustomCard alert
176
+ uv run pie add-event MyCustomCard alert --src-dir app
177
+ ```
178
+
179
+ For `alert`, the command adds:
180
+
181
+ ```python
182
+ def create_alert_event(self, data: dict | None = None):
183
+ return self.create_event("alert", data or {})
184
+
185
+ def get_supported_events(self):
186
+ return [
187
+ "alert",
188
+ ]
189
+ ```
190
+
191
+ ### postbuild
192
+
193
+ Generate a manifest file:
194
+
195
+ ```bash
196
+ uv run pie postbuild
197
+ uv run pie postbuild --append --out-dir dist
198
+ uv run pie postbuild --src-dir src --out-dir public
199
+ ```
200
+
201
+ ## Project Layout
202
+
203
+ ```text
204
+ pie/cli.py CLI argument handling and command dispatch
205
+ pie/config.py pydantic-settings config loaded from .env
206
+ pie/models.py pydantic response models
207
+ pie/services/storage.py pieui-storage API client
208
+ ```
@@ -0,0 +1,27 @@
1
+ __version__ = "0.1.0"
2
+
3
+ __author__ = "George K."
4
+
5
+
6
+ from .fastweb import Web
7
+ from .async_page import AsyncPage
8
+ from .card import Card, InputCard
9
+ from .components.hidden import HiddenCard
10
+ from .components.union import UnionCard
11
+ from .components.ajax_group import AjaxGroupCard
12
+ from .components.html_embed import HTMLEmbedCard
13
+ from .components.one_of import OneOfCard
14
+ from .components.io_log import IOLogCard
15
+
16
+
17
+ __all__ = ["__version__",
18
+ "Web",
19
+ "AsyncPage",
20
+ "InputCard",
21
+ "Card",
22
+ "HiddenCard",
23
+ "UnionCard",
24
+ "AjaxGroupCard",
25
+ "HTMLEmbedCard",
26
+ "OneOfCard",
27
+ "IOLogCard"]
@@ -0,0 +1,99 @@
1
+ """PieDemo CLI
2
+
3
+ Command-line interface for the PieDemo framework.
4
+ """
5
+
6
+ import argparse
7
+ import sys
8
+ from typing import Optional
9
+
10
+ from .code import handle_card_add, handle_build, handle_create, handle_web, handle_web_verify
11
+
12
+
13
+ CARD_TYPES = {"simple", "complex", "container", "complex-container"}
14
+
15
+
16
+ def build_parser() -> argparse.ArgumentParser:
17
+ parser = argparse.ArgumentParser(
18
+ prog="pie",
19
+ description="Pie - Framework for building interactive web applications",
20
+ )
21
+
22
+ subparsers = parser.add_subparsers(dest="command", help="Available commands", required=True)
23
+
24
+ # piedemo web module:app [verify|build]
25
+ web_parser = subparsers.add_parser("web", help="Run or lint a web application")
26
+ web_parser.add_argument("web", help="Web in format module:attribute, e.g. some:app")
27
+ web_subparsers = web_parser.add_subparsers(dest="web_command")
28
+ web_subparsers.add_parser("verify", help="Verify the web application")
29
+ web_subparsers.add_parser("build", help="Build static JSON from a Web application")
30
+
31
+ card_parser = subparsers.add_parser("card", help="Manage card templates")
32
+ card_subparsers = card_parser.add_subparsers(dest="card_command", required=True)
33
+ card_add_parser = card_subparsers.add_parser("add", help="Create a card file from a template")
34
+ card_add_parser.add_argument("card_type", choices=sorted(CARD_TYPES))
35
+ card_add_parser.add_argument("card_name", metavar="NAME")
36
+ card_add_parser.add_argument("--io", action="store_true", dest="use_io")
37
+ card_add_parser.add_argument("--ajax", action="store_true", dest="use_ajax")
38
+
39
+ create_parser = subparsers.add_parser("create", help="Create a new Pie project")
40
+ create_parser.add_argument("project_name", metavar="NAME")
41
+
42
+ return parser
43
+
44
+
45
+ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
46
+ return build_parser().parse_args(argv)
47
+
48
+
49
+ def main(
50
+ command: str,
51
+ web: Optional[str] = None,
52
+ web_command: Optional[str] = None,
53
+ card_command: Optional[str] = None,
54
+ card_type: Optional[str] = None,
55
+ card_name: Optional[str] = None,
56
+ project_name: Optional[str] = None,
57
+ use_io: bool = False,
58
+ use_ajax: bool = False,
59
+ ) -> int:
60
+ try:
61
+ if command == "web":
62
+ if web is None:
63
+ raise ValueError("Web path is required")
64
+ if web_command == "verify":
65
+ handle_web_verify(web)
66
+ elif web_command == "build":
67
+ handle_build(web)
68
+ else:
69
+ handle_web(web)
70
+ return 0
71
+
72
+ if command == "page":
73
+ return 0
74
+ if command == "card":
75
+ if card_command == "add":
76
+ handle_card_add(
77
+ card_name=card_name,
78
+ card_type=card_type,
79
+ use_io=use_io,
80
+ use_ajax=use_ajax,
81
+ )
82
+ return 0
83
+ if command == "create":
84
+ if project_name is None:
85
+ raise ValueError("Project name is required")
86
+ handle_create(project_name)
87
+ return 0
88
+ if command == "init":
89
+ return 0
90
+ if command == "login":
91
+ return 0
92
+ return 0
93
+ except ValueError as error:
94
+ print(error, file=sys.stderr)
95
+ return 1
96
+
97
+
98
+ if __name__ == "__main__":
99
+ raise SystemExit(main(**vars(parse_args())))