Python API¶
Auto-generated reference for the public Python modules in the hub package.
When to use this
This reference is useful if you are extending the hub itself, writing tests, or scripting against the hub's internals. For most app development, the CLI and Hub API are sufficient.
hub.config¶
Configuration loading and directory resolution. The HubConfig dataclass holds all runtime settings; helper functions resolve the paths used by the hub at startup.
hub.config
¶
Hub configuration loading and directory resolution.
HubConfig
dataclass
¶
load_config(path=None)
¶
Load hub configuration from a TOML file.
Defaults to the user config at $XDG_CONFIG_HOME/squareberg/config.toml.
Falls back to built-in defaults if the file does not exist.
Source code in hub/config.py
get_socket_dir(config=None)
¶
Resolve the socket directory and create it if needed.
Source code in hub/config.py
get_log_dir(config=None)
¶
Resolve the log directory and create it if needed.
Source code in hub/config.py
get_apps_dir()
¶
Return the apps directory under XDG_DATA_HOME, creating it if needed.
hub.registry¶
App discovery and runtime status tracking. The Registry class scans the filesystem for manifests and maintains an in-memory map of app names to AppInfo objects.
hub.registry
¶
App registry — discovers and tracks installed Squareberg apps.
AppInfo
dataclass
¶
Source code in hub/registry.py
Registry
¶
Discovers apps from the filesystem and tracks their runtime status.
Source code in hub/registry.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
hub.manager¶
Process lifecycle management. ProcessManager spawns uvicorn subprocesses for apps, waits for their sockets to appear, and handles graceful shutdown.
hub.manager
¶
Process manager — spawns, monitors, and stops app subprocesses.
ProcessManager
¶
Manage app subprocesses — start, stop, health-check.
Source code in hub/manager.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
health_check(name)
async
¶
Probe an app's /api/health endpoint via its Unix socket.
Source code in hub/manager.py
start_all()
async
¶
Start all registered apps.
start_app(name)
async
¶
Start an app by name.
Resolves the app's venv Python, spawns uvicorn on a Unix socket, and waits for the socket file to appear.
Source code in hub/manager.py
stop_all()
async
¶
Stop all running apps.
stop_app(name)
async
¶
Stop a running app gracefully, escalating to SIGKILL if needed.