py-data-engine 0.1.0__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.
- data_engine/__init__.py +37 -0
- data_engine/application/__init__.py +39 -0
- data_engine/application/actions.py +42 -0
- data_engine/application/catalog.py +151 -0
- data_engine/application/control.py +213 -0
- data_engine/application/details.py +73 -0
- data_engine/application/runtime.py +449 -0
- data_engine/application/workspace.py +62 -0
- data_engine/authoring/__init__.py +14 -0
- data_engine/authoring/builder.py +31 -0
- data_engine/authoring/execution/__init__.py +6 -0
- data_engine/authoring/execution/app.py +6 -0
- data_engine/authoring/execution/context.py +82 -0
- data_engine/authoring/execution/continuous.py +176 -0
- data_engine/authoring/execution/grouped.py +106 -0
- data_engine/authoring/execution/logging.py +83 -0
- data_engine/authoring/execution/polling.py +135 -0
- data_engine/authoring/execution/runner.py +210 -0
- data_engine/authoring/execution/single.py +171 -0
- data_engine/authoring/flow.py +361 -0
- data_engine/authoring/helpers.py +160 -0
- data_engine/authoring/model.py +59 -0
- data_engine/authoring/primitives.py +430 -0
- data_engine/authoring/services.py +42 -0
- data_engine/devtools/__init__.py +3 -0
- data_engine/devtools/project_ast_map.py +503 -0
- data_engine/docs/__init__.py +1 -0
- data_engine/docs/sphinx_source/_static/custom.css +13 -0
- data_engine/docs/sphinx_source/api.rst +42 -0
- data_engine/docs/sphinx_source/conf.py +37 -0
- data_engine/docs/sphinx_source/guides/app-runtime-and-workspaces.md +397 -0
- data_engine/docs/sphinx_source/guides/authoring-flow-modules.md +215 -0
- data_engine/docs/sphinx_source/guides/configuring-flows.md +185 -0
- data_engine/docs/sphinx_source/guides/core-concepts.md +208 -0
- data_engine/docs/sphinx_source/guides/database-methods.md +107 -0
- data_engine/docs/sphinx_source/guides/duckdb-helpers.md +462 -0
- data_engine/docs/sphinx_source/guides/flow-context.md +538 -0
- data_engine/docs/sphinx_source/guides/flow-methods.md +206 -0
- data_engine/docs/sphinx_source/guides/getting-started.md +271 -0
- data_engine/docs/sphinx_source/guides/project-inventory.md +5683 -0
- data_engine/docs/sphinx_source/guides/project-map.md +118 -0
- data_engine/docs/sphinx_source/guides/recipes.md +268 -0
- data_engine/docs/sphinx_source/index.rst +22 -0
- data_engine/domain/__init__.py +92 -0
- data_engine/domain/actions.py +69 -0
- data_engine/domain/catalog.py +128 -0
- data_engine/domain/details.py +214 -0
- data_engine/domain/diagnostics.py +56 -0
- data_engine/domain/errors.py +104 -0
- data_engine/domain/inspection.py +99 -0
- data_engine/domain/logs.py +118 -0
- data_engine/domain/operations.py +172 -0
- data_engine/domain/operator.py +72 -0
- data_engine/domain/runs.py +155 -0
- data_engine/domain/runtime.py +279 -0
- data_engine/domain/source_state.py +17 -0
- data_engine/domain/support.py +54 -0
- data_engine/domain/time.py +23 -0
- data_engine/domain/workspace.py +159 -0
- data_engine/flow_modules/__init__.py +1 -0
- data_engine/flow_modules/flow_module_compiler.py +179 -0
- data_engine/flow_modules/flow_module_loader.py +201 -0
- data_engine/helpers/__init__.py +25 -0
- data_engine/helpers/duckdb.py +705 -0
- data_engine/hosts/__init__.py +1 -0
- data_engine/hosts/daemon/__init__.py +23 -0
- data_engine/hosts/daemon/app.py +221 -0
- data_engine/hosts/daemon/bootstrap.py +69 -0
- data_engine/hosts/daemon/client.py +465 -0
- data_engine/hosts/daemon/commands.py +64 -0
- data_engine/hosts/daemon/composition.py +310 -0
- data_engine/hosts/daemon/constants.py +15 -0
- data_engine/hosts/daemon/entrypoints.py +97 -0
- data_engine/hosts/daemon/lifecycle.py +191 -0
- data_engine/hosts/daemon/manager.py +272 -0
- data_engine/hosts/daemon/ownership.py +126 -0
- data_engine/hosts/daemon/runtime_commands.py +188 -0
- data_engine/hosts/daemon/runtime_control.py +31 -0
- data_engine/hosts/daemon/server.py +84 -0
- data_engine/hosts/daemon/shared_state.py +147 -0
- data_engine/hosts/daemon/state_sync.py +101 -0
- data_engine/platform/__init__.py +1 -0
- data_engine/platform/identity.py +35 -0
- data_engine/platform/local_settings.py +146 -0
- data_engine/platform/theme.py +259 -0
- data_engine/platform/workspace_models.py +190 -0
- data_engine/platform/workspace_policy.py +333 -0
- data_engine/runtime/__init__.py +1 -0
- data_engine/runtime/file_watch.py +185 -0
- data_engine/runtime/ledger_models.py +116 -0
- data_engine/runtime/runtime_db.py +938 -0
- data_engine/runtime/shared_state.py +523 -0
- data_engine/services/__init__.py +49 -0
- data_engine/services/daemon.py +64 -0
- data_engine/services/daemon_state.py +40 -0
- data_engine/services/flow_catalog.py +102 -0
- data_engine/services/flow_execution.py +48 -0
- data_engine/services/ledger.py +85 -0
- data_engine/services/logs.py +65 -0
- data_engine/services/runtime_binding.py +105 -0
- data_engine/services/runtime_execution.py +126 -0
- data_engine/services/runtime_history.py +62 -0
- data_engine/services/settings.py +58 -0
- data_engine/services/shared_state.py +28 -0
- data_engine/services/theme.py +59 -0
- data_engine/services/workspace_provisioning.py +224 -0
- data_engine/services/workspaces.py +74 -0
- data_engine/ui/__init__.py +3 -0
- data_engine/ui/cli/__init__.py +19 -0
- data_engine/ui/cli/app.py +161 -0
- data_engine/ui/cli/commands_doctor.py +178 -0
- data_engine/ui/cli/commands_run.py +80 -0
- data_engine/ui/cli/commands_start.py +100 -0
- data_engine/ui/cli/commands_workspace.py +97 -0
- data_engine/ui/cli/dependencies.py +44 -0
- data_engine/ui/cli/parser.py +56 -0
- data_engine/ui/gui/__init__.py +25 -0
- data_engine/ui/gui/app.py +116 -0
- data_engine/ui/gui/bootstrap.py +487 -0
- data_engine/ui/gui/bootstrapper.py +140 -0
- data_engine/ui/gui/cache_models.py +23 -0
- data_engine/ui/gui/control_support.py +185 -0
- data_engine/ui/gui/controllers/__init__.py +6 -0
- data_engine/ui/gui/controllers/flows.py +439 -0
- data_engine/ui/gui/controllers/runtime.py +245 -0
- data_engine/ui/gui/dialogs/__init__.py +12 -0
- data_engine/ui/gui/dialogs/messages.py +88 -0
- data_engine/ui/gui/dialogs/previews.py +222 -0
- data_engine/ui/gui/helpers/__init__.py +62 -0
- data_engine/ui/gui/helpers/inspection.py +81 -0
- data_engine/ui/gui/helpers/lifecycle.py +112 -0
- data_engine/ui/gui/helpers/scroll.py +28 -0
- data_engine/ui/gui/helpers/theming.py +87 -0
- data_engine/ui/gui/icons/dark_light.svg +12 -0
- data_engine/ui/gui/icons/documentation.svg +1 -0
- data_engine/ui/gui/icons/failed.svg +3 -0
- data_engine/ui/gui/icons/group.svg +4 -0
- data_engine/ui/gui/icons/home.svg +2 -0
- data_engine/ui/gui/icons/manual.svg +2 -0
- data_engine/ui/gui/icons/poll.svg +2 -0
- data_engine/ui/gui/icons/schedule.svg +4 -0
- data_engine/ui/gui/icons/settings.svg +2 -0
- data_engine/ui/gui/icons/started.svg +3 -0
- data_engine/ui/gui/icons/success.svg +3 -0
- data_engine/ui/gui/icons/view-log.svg +3 -0
- data_engine/ui/gui/icons.py +50 -0
- data_engine/ui/gui/launcher.py +48 -0
- data_engine/ui/gui/presenters/__init__.py +72 -0
- data_engine/ui/gui/presenters/docs.py +140 -0
- data_engine/ui/gui/presenters/logs.py +58 -0
- data_engine/ui/gui/presenters/runtime_projection.py +29 -0
- data_engine/ui/gui/presenters/sidebar.py +88 -0
- data_engine/ui/gui/presenters/steps.py +148 -0
- data_engine/ui/gui/presenters/workspace.py +39 -0
- data_engine/ui/gui/presenters/workspace_binding.py +75 -0
- data_engine/ui/gui/presenters/workspace_settings.py +182 -0
- data_engine/ui/gui/preview_models.py +37 -0
- data_engine/ui/gui/render_support.py +241 -0
- data_engine/ui/gui/rendering/__init__.py +12 -0
- data_engine/ui/gui/rendering/artifacts.py +95 -0
- data_engine/ui/gui/rendering/icons.py +50 -0
- data_engine/ui/gui/runtime.py +47 -0
- data_engine/ui/gui/state_support.py +193 -0
- data_engine/ui/gui/support.py +214 -0
- data_engine/ui/gui/surface.py +209 -0
- data_engine/ui/gui/theme.py +720 -0
- data_engine/ui/gui/widgets/__init__.py +34 -0
- data_engine/ui/gui/widgets/config.py +41 -0
- data_engine/ui/gui/widgets/logs.py +62 -0
- data_engine/ui/gui/widgets/panels.py +507 -0
- data_engine/ui/gui/widgets/sidebar.py +130 -0
- data_engine/ui/gui/widgets/steps.py +84 -0
- data_engine/ui/tui/__init__.py +5 -0
- data_engine/ui/tui/app.py +222 -0
- data_engine/ui/tui/bootstrap.py +475 -0
- data_engine/ui/tui/bootstrapper.py +117 -0
- data_engine/ui/tui/controllers/__init__.py +6 -0
- data_engine/ui/tui/controllers/flows.py +349 -0
- data_engine/ui/tui/controllers/runtime.py +167 -0
- data_engine/ui/tui/runtime.py +34 -0
- data_engine/ui/tui/state_support.py +141 -0
- data_engine/ui/tui/support.py +63 -0
- data_engine/ui/tui/theme.py +204 -0
- data_engine/ui/tui/widgets.py +123 -0
- data_engine/views/__init__.py +109 -0
- data_engine/views/actions.py +80 -0
- data_engine/views/artifacts.py +58 -0
- data_engine/views/flow_display.py +69 -0
- data_engine/views/logs.py +54 -0
- data_engine/views/models.py +96 -0
- data_engine/views/presentation.py +133 -0
- data_engine/views/runs.py +62 -0
- data_engine/views/state.py +39 -0
- data_engine/views/status.py +13 -0
- data_engine/views/text.py +109 -0
- py_data_engine-0.1.0.dist-info/METADATA +330 -0
- py_data_engine-0.1.0.dist-info/RECORD +200 -0
- py_data_engine-0.1.0.dist-info/WHEEL +5 -0
- py_data_engine-0.1.0.dist-info/entry_points.txt +2 -0
- py_data_engine-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
"""TUI composition helpers for default service wiring."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any, Callable
|
|
8
|
+
|
|
9
|
+
from data_engine.application import (
|
|
10
|
+
ActionStateApplication,
|
|
11
|
+
DetailApplication,
|
|
12
|
+
FlowCatalogApplication,
|
|
13
|
+
OperatorControlApplication,
|
|
14
|
+
RuntimeApplication,
|
|
15
|
+
WorkspaceSessionApplication,
|
|
16
|
+
)
|
|
17
|
+
from data_engine.authoring.builder import load_flow
|
|
18
|
+
from data_engine.flow_modules.flow_module_loader import discover_flow_module_definitions
|
|
19
|
+
from data_engine.hosts.daemon.app import DaemonClientError
|
|
20
|
+
from data_engine.hosts.daemon.app import daemon_request, is_daemon_live, spawn_daemon_process
|
|
21
|
+
from data_engine.platform.local_settings import LocalSettingsStore
|
|
22
|
+
from data_engine.platform.theme import (
|
|
23
|
+
DEFAULT_THEME,
|
|
24
|
+
THEMES,
|
|
25
|
+
resolve_theme_name,
|
|
26
|
+
system_theme_name,
|
|
27
|
+
theme_button_text,
|
|
28
|
+
toggle_theme_name,
|
|
29
|
+
)
|
|
30
|
+
from data_engine.services import (
|
|
31
|
+
DaemonService,
|
|
32
|
+
DaemonStateService,
|
|
33
|
+
FlowCatalogService,
|
|
34
|
+
FlowExecutionService,
|
|
35
|
+
LedgerService,
|
|
36
|
+
LogService,
|
|
37
|
+
RuntimeHistoryService,
|
|
38
|
+
WorkspaceRuntimeBindingService,
|
|
39
|
+
SettingsService,
|
|
40
|
+
SharedStateService,
|
|
41
|
+
ThemeService,
|
|
42
|
+
WorkspaceService,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass(frozen=True)
|
|
47
|
+
class TuiServices:
|
|
48
|
+
"""Concrete service set for the terminal UI surface."""
|
|
49
|
+
|
|
50
|
+
settings_service: SettingsService
|
|
51
|
+
workspace_service: WorkspaceService
|
|
52
|
+
workspace_session_application: WorkspaceSessionApplication
|
|
53
|
+
action_state_application: ActionStateApplication
|
|
54
|
+
detail_application: DetailApplication
|
|
55
|
+
flow_catalog_service: FlowCatalogService
|
|
56
|
+
flow_catalog_application: FlowCatalogApplication
|
|
57
|
+
flow_execution_service: FlowExecutionService
|
|
58
|
+
daemon_service: DaemonService
|
|
59
|
+
daemon_state_service: DaemonStateService
|
|
60
|
+
runtime_application: RuntimeApplication
|
|
61
|
+
control_application: OperatorControlApplication
|
|
62
|
+
ledger_service: LedgerService
|
|
63
|
+
log_service: LogService
|
|
64
|
+
runtime_binding_service: WorkspaceRuntimeBindingService
|
|
65
|
+
runtime_history_service: RuntimeHistoryService
|
|
66
|
+
shared_state_service: SharedStateService
|
|
67
|
+
theme_service: ThemeService
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass(frozen=True)
|
|
71
|
+
class TuiDependencyFactories:
|
|
72
|
+
"""Factories used to build the default TUI dependency bundle."""
|
|
73
|
+
|
|
74
|
+
settings_store_factory: Callable[[Path | None], LocalSettingsStore]
|
|
75
|
+
settings_service_factory: Callable[[LocalSettingsStore], SettingsService]
|
|
76
|
+
workspace_service_factory: Callable[[object | None, object | None], WorkspaceService]
|
|
77
|
+
workspace_session_application_factory: Callable[[WorkspaceService], WorkspaceSessionApplication]
|
|
78
|
+
action_state_application_factory: Callable[[], ActionStateApplication]
|
|
79
|
+
detail_application_factory: Callable[[], DetailApplication]
|
|
80
|
+
flow_catalog_service_factory: Callable[[object], FlowCatalogService]
|
|
81
|
+
flow_catalog_application_factory: Callable[[FlowCatalogService], FlowCatalogApplication]
|
|
82
|
+
flow_execution_service_factory: Callable[[object], FlowExecutionService]
|
|
83
|
+
daemon_service_factory: Callable[[object, object, object, type[Exception]], DaemonService]
|
|
84
|
+
daemon_state_service_factory: Callable[[], DaemonStateService]
|
|
85
|
+
ledger_service_factory: Callable[[], LedgerService]
|
|
86
|
+
log_service_factory: Callable[[], LogService]
|
|
87
|
+
runtime_binding_service_factory: Callable[[LedgerService, LogService, DaemonStateService], WorkspaceRuntimeBindingService]
|
|
88
|
+
runtime_history_service_factory: Callable[[], RuntimeHistoryService]
|
|
89
|
+
shared_state_service_factory: Callable[[], SharedStateService]
|
|
90
|
+
runtime_application_factory: Callable[[DaemonService, DaemonStateService, SharedStateService], RuntimeApplication]
|
|
91
|
+
control_application_factory: Callable[[RuntimeApplication, DaemonStateService], OperatorControlApplication]
|
|
92
|
+
theme_service_factory: Callable[[object, str, object, object, object, object], ThemeService]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def default_tui_dependency_factories() -> TuiDependencyFactories:
|
|
96
|
+
"""Return the default constructor bundle for TUI bootstrap objects."""
|
|
97
|
+
return TuiDependencyFactories(
|
|
98
|
+
settings_store_factory=lambda app_root: LocalSettingsStore.open_default(app_root=app_root),
|
|
99
|
+
settings_service_factory=SettingsService,
|
|
100
|
+
workspace_service_factory=lambda discover, resolve: WorkspaceService(
|
|
101
|
+
discover_workspaces_func=discover,
|
|
102
|
+
resolve_workspace_paths_func=resolve,
|
|
103
|
+
)
|
|
104
|
+
if discover is not None or resolve is not None
|
|
105
|
+
else WorkspaceService(),
|
|
106
|
+
workspace_session_application_factory=lambda workspace_service: WorkspaceSessionApplication(
|
|
107
|
+
workspace_service=workspace_service,
|
|
108
|
+
),
|
|
109
|
+
action_state_application_factory=ActionStateApplication,
|
|
110
|
+
detail_application_factory=DetailApplication,
|
|
111
|
+
flow_catalog_service_factory=lambda discover_definitions: FlowCatalogService(
|
|
112
|
+
discover_definitions_func=discover_definitions,
|
|
113
|
+
),
|
|
114
|
+
flow_catalog_application_factory=lambda flow_catalog_service: FlowCatalogApplication(
|
|
115
|
+
flow_catalog_service=flow_catalog_service,
|
|
116
|
+
),
|
|
117
|
+
flow_execution_service_factory=lambda load_flow_func: FlowExecutionService(
|
|
118
|
+
load_flow_func=load_flow_func,
|
|
119
|
+
),
|
|
120
|
+
daemon_service_factory=lambda spawn, request, is_live, error_type: DaemonService(
|
|
121
|
+
spawn_process_func=spawn,
|
|
122
|
+
request_func=request,
|
|
123
|
+
is_live_func=is_live,
|
|
124
|
+
client_error_type=error_type,
|
|
125
|
+
),
|
|
126
|
+
daemon_state_service_factory=DaemonStateService,
|
|
127
|
+
ledger_service_factory=LedgerService,
|
|
128
|
+
log_service_factory=LogService,
|
|
129
|
+
runtime_binding_service_factory=lambda ledger_service, log_service, daemon_state_service: WorkspaceRuntimeBindingService(
|
|
130
|
+
ledger_service=ledger_service,
|
|
131
|
+
log_service=log_service,
|
|
132
|
+
daemon_state_service=daemon_state_service,
|
|
133
|
+
),
|
|
134
|
+
runtime_history_service_factory=RuntimeHistoryService,
|
|
135
|
+
shared_state_service_factory=SharedStateService,
|
|
136
|
+
runtime_application_factory=lambda daemon_service, daemon_state_service, shared_state_service: RuntimeApplication(
|
|
137
|
+
daemon_service=daemon_service,
|
|
138
|
+
daemon_state_service=daemon_state_service,
|
|
139
|
+
shared_state_service=shared_state_service,
|
|
140
|
+
),
|
|
141
|
+
control_application_factory=lambda runtime_application, daemon_state_service: OperatorControlApplication(
|
|
142
|
+
runtime_application=runtime_application,
|
|
143
|
+
daemon_state_service=daemon_state_service,
|
|
144
|
+
),
|
|
145
|
+
theme_service_factory=lambda themes, default_theme_name, resolve, system, toggle, button_text: ThemeService(
|
|
146
|
+
themes=themes,
|
|
147
|
+
default_theme_name=default_theme_name,
|
|
148
|
+
resolve_theme_name_func=resolve,
|
|
149
|
+
system_theme_name_func=system,
|
|
150
|
+
toggle_theme_name_func=toggle,
|
|
151
|
+
theme_button_text_func=button_text,
|
|
152
|
+
),
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def default_tui_service_kwargs(theme_name: str) -> dict[str, object]:
|
|
157
|
+
"""Return the shared default seam kwargs used by the TUI surface."""
|
|
158
|
+
del theme_name
|
|
159
|
+
return {
|
|
160
|
+
"discover_definitions_func": discover_flow_module_definitions,
|
|
161
|
+
"load_flow_func": load_flow,
|
|
162
|
+
"spawn_process_func": spawn_daemon_process,
|
|
163
|
+
"request_func": daemon_request,
|
|
164
|
+
"is_live_func": is_daemon_live,
|
|
165
|
+
"resolve_theme_name_func": resolve_theme_name,
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _tui_services_from_kwargs(service_kwargs: dict[str, object]) -> TuiServices:
|
|
170
|
+
"""Convert shared surface service kwargs into TUI-specific services."""
|
|
171
|
+
return TuiServices(
|
|
172
|
+
settings_service=service_kwargs["settings_service"],
|
|
173
|
+
workspace_service=service_kwargs["workspace_service"],
|
|
174
|
+
workspace_session_application=service_kwargs["workspace_session_application"],
|
|
175
|
+
action_state_application=service_kwargs["action_state_application"],
|
|
176
|
+
detail_application=service_kwargs["detail_application"],
|
|
177
|
+
flow_catalog_service=service_kwargs["flow_catalog_service"],
|
|
178
|
+
flow_catalog_application=service_kwargs["flow_catalog_application"],
|
|
179
|
+
flow_execution_service=service_kwargs["flow_execution_service"],
|
|
180
|
+
daemon_service=service_kwargs["daemon_service"],
|
|
181
|
+
daemon_state_service=service_kwargs["daemon_state_service"],
|
|
182
|
+
runtime_application=service_kwargs["runtime_application"],
|
|
183
|
+
control_application=service_kwargs["control_application"],
|
|
184
|
+
ledger_service=service_kwargs["ledger_service"],
|
|
185
|
+
log_service=service_kwargs["log_service"],
|
|
186
|
+
runtime_binding_service=service_kwargs["runtime_binding_service"],
|
|
187
|
+
runtime_history_service=service_kwargs["runtime_history_service"],
|
|
188
|
+
shared_state_service=service_kwargs["shared_state_service"],
|
|
189
|
+
theme_service=service_kwargs["theme_service"],
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def build_tui_service_kwargs(
|
|
194
|
+
*,
|
|
195
|
+
settings_service: SettingsService | None = None,
|
|
196
|
+
workspace_service: WorkspaceService | None = None,
|
|
197
|
+
workspace_session_application: WorkspaceSessionApplication | None = None,
|
|
198
|
+
action_state_application: ActionStateApplication | None = None,
|
|
199
|
+
detail_application: DetailApplication | None = None,
|
|
200
|
+
flow_catalog_service: FlowCatalogService | None = None,
|
|
201
|
+
flow_catalog_application: FlowCatalogApplication | None = None,
|
|
202
|
+
flow_execution_service: FlowExecutionService | None = None,
|
|
203
|
+
daemon_service: DaemonService | None = None,
|
|
204
|
+
daemon_state_service: DaemonStateService | None = None,
|
|
205
|
+
runtime_application: RuntimeApplication | None = None,
|
|
206
|
+
control_application: OperatorControlApplication | None = None,
|
|
207
|
+
ledger_service: LedgerService | None = None,
|
|
208
|
+
log_service: LogService | None = None,
|
|
209
|
+
runtime_binding_service: WorkspaceRuntimeBindingService | None = None,
|
|
210
|
+
runtime_history_service: RuntimeHistoryService | None = None,
|
|
211
|
+
shared_state_service: SharedStateService | None = None,
|
|
212
|
+
theme_service: ThemeService | None = None,
|
|
213
|
+
settings_store: LocalSettingsStore | None = None,
|
|
214
|
+
factories: TuiDependencyFactories | None = None,
|
|
215
|
+
app_root: Path | None = None,
|
|
216
|
+
discover_workspaces_func=None,
|
|
217
|
+
resolve_workspace_paths_func=None,
|
|
218
|
+
discover_definitions_func=discover_flow_module_definitions,
|
|
219
|
+
load_flow_func=load_flow,
|
|
220
|
+
spawn_process_func=spawn_daemon_process,
|
|
221
|
+
request_func=daemon_request,
|
|
222
|
+
is_live_func=is_daemon_live,
|
|
223
|
+
client_error_type: type[Exception] = DaemonClientError,
|
|
224
|
+
resolve_theme_name_func=resolve_theme_name,
|
|
225
|
+
system_theme_name_func=system_theme_name,
|
|
226
|
+
toggle_theme_name_func=toggle_theme_name,
|
|
227
|
+
theme_button_text_func=theme_button_text,
|
|
228
|
+
themes=THEMES,
|
|
229
|
+
default_theme_name: str | None = None,
|
|
230
|
+
) -> dict[str, Any]:
|
|
231
|
+
"""Build the common service bundle used by the TUI bootstrap module."""
|
|
232
|
+
factories = factories or default_tui_dependency_factories()
|
|
233
|
+
discover_definitions_func = discover_definitions_func or discover_flow_module_definitions
|
|
234
|
+
load_flow_func = load_flow_func or load_flow
|
|
235
|
+
spawn_process_func = spawn_process_func or spawn_daemon_process
|
|
236
|
+
request_func = request_func or daemon_request
|
|
237
|
+
is_live_func = is_live_func or is_daemon_live
|
|
238
|
+
resolve_theme_name_func = resolve_theme_name_func or resolve_theme_name
|
|
239
|
+
system_theme_name_func = system_theme_name_func or system_theme_name
|
|
240
|
+
toggle_theme_name_func = toggle_theme_name_func or toggle_theme_name
|
|
241
|
+
theme_button_text_func = theme_button_text_func or theme_button_text
|
|
242
|
+
themes = themes or THEMES
|
|
243
|
+
default_theme_name = default_theme_name or DEFAULT_THEME
|
|
244
|
+
settings_store = settings_store or factories.settings_store_factory(app_root)
|
|
245
|
+
settings_service = settings_service or factories.settings_service_factory(settings_store)
|
|
246
|
+
workspace_service = workspace_service or factories.workspace_service_factory(
|
|
247
|
+
discover_workspaces_func,
|
|
248
|
+
resolve_workspace_paths_func,
|
|
249
|
+
)
|
|
250
|
+
workspace_session_application = workspace_session_application or factories.workspace_session_application_factory(
|
|
251
|
+
workspace_service,
|
|
252
|
+
)
|
|
253
|
+
action_state_application = action_state_application or factories.action_state_application_factory()
|
|
254
|
+
detail_application = detail_application or factories.detail_application_factory()
|
|
255
|
+
flow_catalog_service = flow_catalog_service or factories.flow_catalog_service_factory(discover_definitions_func)
|
|
256
|
+
flow_catalog_application = flow_catalog_application or factories.flow_catalog_application_factory(flow_catalog_service)
|
|
257
|
+
flow_execution_service = flow_execution_service or factories.flow_execution_service_factory(load_flow_func)
|
|
258
|
+
daemon_service = daemon_service or factories.daemon_service_factory(
|
|
259
|
+
spawn_process_func,
|
|
260
|
+
request_func,
|
|
261
|
+
is_live_func,
|
|
262
|
+
client_error_type,
|
|
263
|
+
)
|
|
264
|
+
daemon_state_service = daemon_state_service or factories.daemon_state_service_factory()
|
|
265
|
+
ledger_service = ledger_service or factories.ledger_service_factory()
|
|
266
|
+
log_service = log_service or factories.log_service_factory()
|
|
267
|
+
runtime_binding_service = runtime_binding_service or factories.runtime_binding_service_factory(
|
|
268
|
+
ledger_service,
|
|
269
|
+
log_service,
|
|
270
|
+
daemon_state_service,
|
|
271
|
+
)
|
|
272
|
+
runtime_history_service = runtime_history_service or factories.runtime_history_service_factory()
|
|
273
|
+
shared_state_service = shared_state_service or factories.shared_state_service_factory()
|
|
274
|
+
runtime_application = runtime_application or factories.runtime_application_factory(
|
|
275
|
+
daemon_service,
|
|
276
|
+
daemon_state_service,
|
|
277
|
+
shared_state_service,
|
|
278
|
+
)
|
|
279
|
+
control_application = control_application or factories.control_application_factory(
|
|
280
|
+
runtime_application,
|
|
281
|
+
daemon_state_service,
|
|
282
|
+
)
|
|
283
|
+
theme_service = theme_service or factories.theme_service_factory(
|
|
284
|
+
themes,
|
|
285
|
+
default_theme_name,
|
|
286
|
+
resolve_theme_name_func,
|
|
287
|
+
system_theme_name_func,
|
|
288
|
+
toggle_theme_name_func,
|
|
289
|
+
theme_button_text_func,
|
|
290
|
+
)
|
|
291
|
+
return {
|
|
292
|
+
"settings_service": settings_service,
|
|
293
|
+
"workspace_service": workspace_service,
|
|
294
|
+
"workspace_session_application": workspace_session_application,
|
|
295
|
+
"action_state_application": action_state_application,
|
|
296
|
+
"detail_application": detail_application,
|
|
297
|
+
"flow_catalog_service": flow_catalog_service,
|
|
298
|
+
"flow_catalog_application": flow_catalog_application,
|
|
299
|
+
"flow_execution_service": flow_execution_service,
|
|
300
|
+
"daemon_service": daemon_service,
|
|
301
|
+
"daemon_state_service": daemon_state_service,
|
|
302
|
+
"runtime_application": runtime_application,
|
|
303
|
+
"control_application": control_application,
|
|
304
|
+
"ledger_service": ledger_service,
|
|
305
|
+
"log_service": log_service,
|
|
306
|
+
"runtime_binding_service": runtime_binding_service,
|
|
307
|
+
"runtime_history_service": runtime_history_service,
|
|
308
|
+
"shared_state_service": shared_state_service,
|
|
309
|
+
"theme_service": theme_service,
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def build_default_tui_services(
|
|
314
|
+
*,
|
|
315
|
+
settings_service: SettingsService | None = None,
|
|
316
|
+
workspace_service: WorkspaceService | None = None,
|
|
317
|
+
workspace_session_application: WorkspaceSessionApplication | None = None,
|
|
318
|
+
action_state_application: ActionStateApplication | None = None,
|
|
319
|
+
detail_application: DetailApplication | None = None,
|
|
320
|
+
flow_catalog_service: FlowCatalogService | None = None,
|
|
321
|
+
flow_catalog_application: FlowCatalogApplication | None = None,
|
|
322
|
+
flow_execution_service: FlowExecutionService | None = None,
|
|
323
|
+
daemon_service: DaemonService | None = None,
|
|
324
|
+
daemon_state_service: DaemonStateService | None = None,
|
|
325
|
+
runtime_application: RuntimeApplication | None = None,
|
|
326
|
+
control_application: OperatorControlApplication | None = None,
|
|
327
|
+
ledger_service: LedgerService | None = None,
|
|
328
|
+
log_service: LogService | None = None,
|
|
329
|
+
runtime_binding_service: WorkspaceRuntimeBindingService | None = None,
|
|
330
|
+
runtime_history_service: RuntimeHistoryService | None = None,
|
|
331
|
+
shared_state_service: SharedStateService | None = None,
|
|
332
|
+
theme_service: ThemeService | None = None,
|
|
333
|
+
settings_store: LocalSettingsStore | None = None,
|
|
334
|
+
factories: TuiDependencyFactories | None = None,
|
|
335
|
+
app_root: Path | None = None,
|
|
336
|
+
discover_workspaces_func=None,
|
|
337
|
+
resolve_workspace_paths_func=None,
|
|
338
|
+
discover_definitions_func=None,
|
|
339
|
+
load_flow_func=None,
|
|
340
|
+
spawn_process_func=None,
|
|
341
|
+
request_func=None,
|
|
342
|
+
is_live_func=None,
|
|
343
|
+
client_error_type: type[Exception] = DaemonClientError,
|
|
344
|
+
resolve_theme_name_func=None,
|
|
345
|
+
system_theme_name_func=None,
|
|
346
|
+
toggle_theme_name_func=None,
|
|
347
|
+
theme_button_text_func=None,
|
|
348
|
+
themes=None,
|
|
349
|
+
default_theme_name: str | None = None,
|
|
350
|
+
) -> TuiServices:
|
|
351
|
+
"""Build the default terminal UI service set."""
|
|
352
|
+
service_kwargs = build_tui_service_kwargs(
|
|
353
|
+
settings_service=settings_service,
|
|
354
|
+
workspace_service=workspace_service,
|
|
355
|
+
workspace_session_application=workspace_session_application,
|
|
356
|
+
action_state_application=action_state_application,
|
|
357
|
+
detail_application=detail_application,
|
|
358
|
+
flow_catalog_service=flow_catalog_service,
|
|
359
|
+
flow_catalog_application=flow_catalog_application,
|
|
360
|
+
flow_execution_service=flow_execution_service,
|
|
361
|
+
daemon_service=daemon_service,
|
|
362
|
+
daemon_state_service=daemon_state_service,
|
|
363
|
+
runtime_application=runtime_application,
|
|
364
|
+
control_application=control_application,
|
|
365
|
+
ledger_service=ledger_service,
|
|
366
|
+
log_service=log_service,
|
|
367
|
+
runtime_binding_service=runtime_binding_service,
|
|
368
|
+
runtime_history_service=runtime_history_service,
|
|
369
|
+
shared_state_service=shared_state_service,
|
|
370
|
+
theme_service=theme_service,
|
|
371
|
+
settings_store=settings_store,
|
|
372
|
+
factories=factories,
|
|
373
|
+
app_root=app_root,
|
|
374
|
+
discover_workspaces_func=discover_workspaces_func,
|
|
375
|
+
resolve_workspace_paths_func=resolve_workspace_paths_func,
|
|
376
|
+
discover_definitions_func=discover_definitions_func,
|
|
377
|
+
load_flow_func=load_flow_func,
|
|
378
|
+
spawn_process_func=spawn_process_func,
|
|
379
|
+
request_func=request_func,
|
|
380
|
+
is_live_func=is_live_func,
|
|
381
|
+
client_error_type=client_error_type,
|
|
382
|
+
resolve_theme_name_func=resolve_theme_name_func,
|
|
383
|
+
system_theme_name_func=system_theme_name_func,
|
|
384
|
+
toggle_theme_name_func=toggle_theme_name_func,
|
|
385
|
+
theme_button_text_func=theme_button_text_func,
|
|
386
|
+
themes=themes,
|
|
387
|
+
default_theme_name=default_theme_name,
|
|
388
|
+
)
|
|
389
|
+
return _tui_services_from_kwargs(service_kwargs)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def build_tui_services(
|
|
393
|
+
*,
|
|
394
|
+
settings_service: SettingsService | None = None,
|
|
395
|
+
workspace_service: WorkspaceService | None = None,
|
|
396
|
+
workspace_session_application: WorkspaceSessionApplication | None = None,
|
|
397
|
+
action_state_application: ActionStateApplication | None = None,
|
|
398
|
+
detail_application: DetailApplication | None = None,
|
|
399
|
+
flow_catalog_service: FlowCatalogService | None = None,
|
|
400
|
+
flow_catalog_application: FlowCatalogApplication | None = None,
|
|
401
|
+
flow_execution_service: FlowExecutionService | None = None,
|
|
402
|
+
daemon_service: DaemonService | None = None,
|
|
403
|
+
daemon_state_service: DaemonStateService | None = None,
|
|
404
|
+
runtime_application: RuntimeApplication | None = None,
|
|
405
|
+
control_application: OperatorControlApplication | None = None,
|
|
406
|
+
ledger_service: LedgerService | None = None,
|
|
407
|
+
log_service: LogService | None = None,
|
|
408
|
+
runtime_history_service: RuntimeHistoryService | None = None,
|
|
409
|
+
shared_state_service: SharedStateService | None = None,
|
|
410
|
+
theme_service: ThemeService | None = None,
|
|
411
|
+
settings_store: LocalSettingsStore | None = None,
|
|
412
|
+
factories: TuiDependencyFactories | None = None,
|
|
413
|
+
app_root: Path | None = None,
|
|
414
|
+
discover_workspaces_func=None,
|
|
415
|
+
resolve_workspace_paths_func=None,
|
|
416
|
+
discover_definitions_func=None,
|
|
417
|
+
load_flow_func=None,
|
|
418
|
+
spawn_process_func=None,
|
|
419
|
+
request_func=None,
|
|
420
|
+
is_live_func=None,
|
|
421
|
+
client_error_type: type[Exception] = DaemonClientError,
|
|
422
|
+
resolve_theme_name_func=None,
|
|
423
|
+
system_theme_name_func=None,
|
|
424
|
+
toggle_theme_name_func=None,
|
|
425
|
+
theme_button_text_func=None,
|
|
426
|
+
themes=None,
|
|
427
|
+
default_theme_name: str | None = None,
|
|
428
|
+
) -> TuiServices:
|
|
429
|
+
"""Compatibility wrapper around the TUI default composition root."""
|
|
430
|
+
return build_default_tui_services(
|
|
431
|
+
settings_service=settings_service,
|
|
432
|
+
workspace_service=workspace_service,
|
|
433
|
+
workspace_session_application=workspace_session_application,
|
|
434
|
+
action_state_application=action_state_application,
|
|
435
|
+
detail_application=detail_application,
|
|
436
|
+
flow_catalog_service=flow_catalog_service,
|
|
437
|
+
flow_catalog_application=flow_catalog_application,
|
|
438
|
+
flow_execution_service=flow_execution_service,
|
|
439
|
+
daemon_service=daemon_service,
|
|
440
|
+
daemon_state_service=daemon_state_service,
|
|
441
|
+
runtime_application=runtime_application,
|
|
442
|
+
control_application=control_application,
|
|
443
|
+
ledger_service=ledger_service,
|
|
444
|
+
log_service=log_service,
|
|
445
|
+
runtime_history_service=runtime_history_service,
|
|
446
|
+
shared_state_service=shared_state_service,
|
|
447
|
+
theme_service=theme_service,
|
|
448
|
+
settings_store=settings_store,
|
|
449
|
+
factories=factories,
|
|
450
|
+
app_root=app_root,
|
|
451
|
+
discover_workspaces_func=discover_workspaces_func,
|
|
452
|
+
resolve_workspace_paths_func=resolve_workspace_paths_func,
|
|
453
|
+
discover_definitions_func=discover_definitions_func,
|
|
454
|
+
load_flow_func=load_flow_func,
|
|
455
|
+
spawn_process_func=spawn_process_func,
|
|
456
|
+
request_func=request_func,
|
|
457
|
+
is_live_func=is_live_func,
|
|
458
|
+
client_error_type=client_error_type,
|
|
459
|
+
resolve_theme_name_func=resolve_theme_name_func,
|
|
460
|
+
system_theme_name_func=system_theme_name_func,
|
|
461
|
+
toggle_theme_name_func=toggle_theme_name_func,
|
|
462
|
+
theme_button_text_func=theme_button_text_func,
|
|
463
|
+
themes=themes,
|
|
464
|
+
default_theme_name=default_theme_name,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
__all__ = [
|
|
468
|
+
"TuiDependencyFactories",
|
|
469
|
+
"TuiServices",
|
|
470
|
+
"build_default_tui_services",
|
|
471
|
+
"build_tui_service_kwargs",
|
|
472
|
+
"build_tui_services",
|
|
473
|
+
"default_tui_dependency_factories",
|
|
474
|
+
"default_tui_service_kwargs",
|
|
475
|
+
]
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Bootstrap helpers for the terminal TUI application shell."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from queue import Queue
|
|
7
|
+
from uuid import uuid4
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
|
+
|
|
10
|
+
from data_engine.domain import FlowLogEntry, OperationSessionState, OperatorSessionState, WorkspaceControlState
|
|
11
|
+
from data_engine.platform.workspace_models import DATA_ENGINE_WORKSPACE_COLLECTION_ROOT_ENV_VAR
|
|
12
|
+
from data_engine.ui.tui.bootstrap import TuiServices, build_tui_services, default_tui_service_kwargs
|
|
13
|
+
from data_engine.ui.tui.controllers import TuiFlowController, TuiRuntimeController
|
|
14
|
+
from data_engine.ui.tui.runtime import QueueLogHandler
|
|
15
|
+
from data_engine.ui.tui.theme import stylesheet as tui_stylesheet
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from data_engine.ui.tui.app import DataEngineTui
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def resolve_initial_tui_workspace_collection_root_override(settings_service):
|
|
22
|
+
"""Resolve the initial workspace collection root override for one TUI process."""
|
|
23
|
+
env_collection_root = os.environ.get(DATA_ENGINE_WORKSPACE_COLLECTION_ROOT_ENV_VAR)
|
|
24
|
+
return None if env_collection_root and env_collection_root.strip() else settings_service.workspace_collection_root()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def build_initial_tui_app_state(
|
|
28
|
+
*,
|
|
29
|
+
workspace_service,
|
|
30
|
+
workspace_session_application,
|
|
31
|
+
runtime_binding_service,
|
|
32
|
+
settings_service,
|
|
33
|
+
) -> dict[str, object]:
|
|
34
|
+
"""Build the initial runtime/session state needed to boot the TUI surface."""
|
|
35
|
+
initial_override = resolve_initial_tui_workspace_collection_root_override(settings_service)
|
|
36
|
+
workspace_paths = workspace_service.resolve_paths(
|
|
37
|
+
workspace_collection_root=initial_override,
|
|
38
|
+
)
|
|
39
|
+
operator_session_state = OperatorSessionState.from_paths(workspace_paths, override_root=initial_override)
|
|
40
|
+
workspace_session_state = workspace_session_application.refresh_session(
|
|
41
|
+
workspace_paths=workspace_paths,
|
|
42
|
+
override_root=initial_override,
|
|
43
|
+
)
|
|
44
|
+
client_session_id = uuid4().hex
|
|
45
|
+
runtime_binding = runtime_binding_service.open_binding(workspace_paths)
|
|
46
|
+
return {
|
|
47
|
+
"workspace_paths": workspace_paths,
|
|
48
|
+
"operator_session_state": operator_session_state,
|
|
49
|
+
"workspace_session_state": workspace_session_state,
|
|
50
|
+
"workspace_control_state": WorkspaceControlState.empty(),
|
|
51
|
+
"operation_tracker": OperationSessionState.empty(),
|
|
52
|
+
"runtime_binding": runtime_binding,
|
|
53
|
+
"client_session_id": client_session_id,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def bootstrap_tui_app(app: "DataEngineTui", *, theme_name: str, services: TuiServices | None = None) -> None:
|
|
58
|
+
"""Bind one TUI app shell to its services, session state, and runtime objects."""
|
|
59
|
+
app.services = services or build_tui_services(
|
|
60
|
+
**default_tui_service_kwargs(theme_name),
|
|
61
|
+
client_error_type=Exception,
|
|
62
|
+
)
|
|
63
|
+
app.workspace_service = app.services.workspace_service
|
|
64
|
+
app.action_state_application = app.services.action_state_application
|
|
65
|
+
app.detail_application = app.services.detail_application
|
|
66
|
+
app.daemon_service = app.services.daemon_service
|
|
67
|
+
app.daemon_state_service = app.services.daemon_state_service
|
|
68
|
+
app.ledger_service = app.services.ledger_service
|
|
69
|
+
app.log_service = app.services.log_service
|
|
70
|
+
app.runtime_binding_service = app.services.runtime_binding_service
|
|
71
|
+
app.shared_state_service = app.services.shared_state_service
|
|
72
|
+
app.settings_service = app.services.settings_service
|
|
73
|
+
app.theme_service = app.services.theme_service
|
|
74
|
+
app.workspace_session_application = app.services.workspace_session_application
|
|
75
|
+
app.flow_catalog_application = app.services.flow_catalog_application
|
|
76
|
+
app.flow_controller = TuiFlowController(
|
|
77
|
+
workspace_session_application=app.workspace_session_application,
|
|
78
|
+
flow_catalog_application=app.flow_catalog_application,
|
|
79
|
+
control_application=app.services.control_application,
|
|
80
|
+
log_service=app.log_service,
|
|
81
|
+
)
|
|
82
|
+
app.runtime_controller = TuiRuntimeController(
|
|
83
|
+
runtime_application=app.services.runtime_application,
|
|
84
|
+
daemon_service=app.daemon_service,
|
|
85
|
+
log_service=app.log_service,
|
|
86
|
+
)
|
|
87
|
+
app.theme_name = app.theme_service.resolve_name(theme_name)
|
|
88
|
+
app.CSS = tui_stylesheet(app.theme_name)
|
|
89
|
+
initial_state = build_initial_tui_app_state(
|
|
90
|
+
workspace_service=app.workspace_service,
|
|
91
|
+
workspace_session_application=app.workspace_session_application,
|
|
92
|
+
runtime_binding_service=app.runtime_binding_service,
|
|
93
|
+
settings_service=app.settings_service,
|
|
94
|
+
)
|
|
95
|
+
app.workspace_paths = initial_state["workspace_paths"]
|
|
96
|
+
app._operator_session_state = initial_state["operator_session_state"]
|
|
97
|
+
app.workspace_session_state = initial_state["workspace_session_state"]
|
|
98
|
+
app.runtime_binding = initial_state["runtime_binding"]
|
|
99
|
+
app.client_session_id = initial_state["client_session_id"]
|
|
100
|
+
app.operation_tracker = initial_state["operation_tracker"]
|
|
101
|
+
app.log_queue: Queue[FlowLogEntry] = Queue()
|
|
102
|
+
app.log_handler = QueueLogHandler(app.log_queue)
|
|
103
|
+
app.workspace_control_state = initial_state["workspace_control_state"]
|
|
104
|
+
app._last_daemon_spawn_attempt = 0.0
|
|
105
|
+
app._daemon_startup_in_progress = False
|
|
106
|
+
app._workspace_switch_suppressed = False
|
|
107
|
+
app.selected_run_key: tuple[str, str] | None = None
|
|
108
|
+
app._last_rendered_flow_signature = None
|
|
109
|
+
app._last_run_list_signature = None
|
|
110
|
+
app._last_detail_signature = None
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
__all__ = [
|
|
114
|
+
"bootstrap_tui_app",
|
|
115
|
+
"build_initial_tui_app_state",
|
|
116
|
+
"resolve_initial_tui_workspace_collection_root_override",
|
|
117
|
+
]
|