platybus-redash 0.1.1__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.
- platybus_redash-0.1.1/.gitignore +46 -0
- platybus_redash-0.1.1/LICENSE +21 -0
- platybus_redash-0.1.1/PKG-INFO +41 -0
- platybus_redash-0.1.1/README.md +16 -0
- platybus_redash-0.1.1/pyproject.toml +43 -0
- platybus_redash-0.1.1/src/platybus_redash/__init__.py +94 -0
- platybus_redash-0.1.1/src/platybus_redash/py.typed +0 -0
- platybus_redash-0.1.1/src/platybus_redash/sandbox.py +134 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.venv/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
*.egg-info/
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.mypy_cache/
|
|
10
|
+
.ruff_cache/
|
|
11
|
+
.coverage
|
|
12
|
+
htmlcov/
|
|
13
|
+
|
|
14
|
+
# Node
|
|
15
|
+
web/node_modules/
|
|
16
|
+
web/dist/
|
|
17
|
+
src/platybus/server/static/
|
|
18
|
+
web/*.tsbuildinfo
|
|
19
|
+
# Playwright artifacts
|
|
20
|
+
web/playwright-report/
|
|
21
|
+
web/test-results/
|
|
22
|
+
web/blob-report/
|
|
23
|
+
web/playwright/.cache/
|
|
24
|
+
|
|
25
|
+
# Platybus local state and demos
|
|
26
|
+
.platybus/
|
|
27
|
+
.tmp/
|
|
28
|
+
*.duckdb
|
|
29
|
+
*.duckdb.wal
|
|
30
|
+
|
|
31
|
+
# Secrets
|
|
32
|
+
.env
|
|
33
|
+
.env.*
|
|
34
|
+
!.env.example
|
|
35
|
+
|
|
36
|
+
# Editors / OS
|
|
37
|
+
.idea/
|
|
38
|
+
.vscode/
|
|
39
|
+
.DS_Store
|
|
40
|
+
Thumbs.db
|
|
41
|
+
|
|
42
|
+
# Claude Code local settings
|
|
43
|
+
.claude/settings.local.json
|
|
44
|
+
.claude
|
|
45
|
+
# MkDocs output
|
|
46
|
+
site/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yaroslav Ozerov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: platybus-redash
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Platybus plugin: Redash dashboards embedded as a web view.
|
|
5
|
+
Project-URL: Homepage, https://github.com/RobbyTheFish/platybus
|
|
6
|
+
Project-URL: Documentation, https://robbythefish.github.io/platybus/
|
|
7
|
+
Project-URL: Repository, https://github.com/RobbyTheFish/platybus
|
|
8
|
+
Project-URL: Issues, https://github.com/RobbyTheFish/platybus/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/RobbyTheFish/platybus/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Yaroslav Ozerov
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: duckdb,platybus,platybus-plugin,redash
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Database
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Requires-Dist: platybus>=0.1.1
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# platybus-redash
|
|
27
|
+
|
|
28
|
+
Redash dashboards embedded as a web view.
|
|
29
|
+
|
|
30
|
+
A plugin for [Platybus](https://github.com/RobbyTheFish/platybus), a compact data platform:
|
|
31
|
+
a hub of projects with pluggable stores (DuckLake, Iceberg, PostgreSQL), a DuckDB engine,
|
|
32
|
+
ETL, dbt and dashboards.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install platybus platybus-redash
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Platybus discovers the plugin through the `platybus.plugins` entry point; no configuration
|
|
39
|
+
is needed. Documentation: <https://robbythefish.github.io/platybus/> (this plugin: <https://robbythefish.github.io/platybus/plugins/webview-dashboards/>).
|
|
40
|
+
|
|
41
|
+
License: MIT.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# platybus-redash
|
|
2
|
+
|
|
3
|
+
Redash dashboards embedded as a web view.
|
|
4
|
+
|
|
5
|
+
A plugin for [Platybus](https://github.com/RobbyTheFish/platybus), a compact data platform:
|
|
6
|
+
a hub of projects with pluggable stores (DuckLake, Iceberg, PostgreSQL), a DuckDB engine,
|
|
7
|
+
ETL, dbt and dashboards.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install platybus platybus-redash
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Platybus discovers the plugin through the `platybus.plugins` entry point; no configuration
|
|
14
|
+
is needed. Documentation: <https://robbythefish.github.io/platybus/> (this plugin: <https://robbythefish.github.io/platybus/plugins/webview-dashboards/>).
|
|
15
|
+
|
|
16
|
+
License: MIT.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "platybus-redash"
|
|
3
|
+
version = "0.1.1" # x-release-please-version
|
|
4
|
+
description = "Platybus plugin: Redash dashboards embedded as a web view."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Yaroslav Ozerov" }]
|
|
9
|
+
requires-python = ">=3.12"
|
|
10
|
+
keywords = ["platybus", "platybus-plugin", "duckdb", "redash"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Topic :: Database",
|
|
19
|
+
"Typing :: Typed",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"platybus>=0.1.1", # x-release-please-version
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/RobbyTheFish/platybus"
|
|
27
|
+
Documentation = "https://robbythefish.github.io/platybus/"
|
|
28
|
+
Repository = "https://github.com/RobbyTheFish/platybus"
|
|
29
|
+
Issues = "https://github.com/RobbyTheFish/platybus/issues"
|
|
30
|
+
Changelog = "https://github.com/RobbyTheFish/platybus/blob/main/CHANGELOG.md"
|
|
31
|
+
|
|
32
|
+
[project.entry-points."platybus.plugins"]
|
|
33
|
+
redash = "platybus_redash:plugin"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["hatchling>=1.26"]
|
|
37
|
+
build-backend = "hatchling.build"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.wheel]
|
|
40
|
+
packages = ["src/platybus_redash"]
|
|
41
|
+
|
|
42
|
+
[tool.uv.sources]
|
|
43
|
+
platybus = { workspace = true }
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Platybus plugin: Redash dashboards embedded as a web view.
|
|
2
|
+
|
|
3
|
+
Settings (``platybus.yml``)::
|
|
4
|
+
|
|
5
|
+
plugins:
|
|
6
|
+
dashboards: [native, redash]
|
|
7
|
+
settings:
|
|
8
|
+
redash:
|
|
9
|
+
url: http://localhost:5000
|
|
10
|
+
api_key: ${REDASH_API_KEY} # optional: list dashboards via the API
|
|
11
|
+
|
|
12
|
+
Redash only allows framing of *shared* dashboards (their public URL); for other
|
|
13
|
+
dashboards the UI offers "open in a new tab". See docs/plugins/redash.md.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
from pydantic import Field
|
|
21
|
+
|
|
22
|
+
from platybus.plugins import DashboardEntry, Plugin, ProviderContext
|
|
23
|
+
from platybus.plugins.webview import WebviewProvider, WebviewSettings, http_json, settings_of
|
|
24
|
+
from platybus.stores import SandboxPreset
|
|
25
|
+
from platybus_redash.sandbox import REDASH_API_KEY, REDASH_SERVICES, REDASH_URL
|
|
26
|
+
|
|
27
|
+
#: Dashboards whose detail (public URL) is fetched per listing.
|
|
28
|
+
DETAIL_LIMIT = 50
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class RedashSettings(WebviewSettings):
|
|
32
|
+
api_key: str | None = Field(None, description="Redash user API key; use ${ENV}.")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class RedashProvider(WebviewProvider):
|
|
36
|
+
name = "redash"
|
|
37
|
+
default_title = "Redash"
|
|
38
|
+
|
|
39
|
+
def __init__(self, settings: RedashSettings) -> None:
|
|
40
|
+
super().__init__(settings)
|
|
41
|
+
self.redash = settings
|
|
42
|
+
|
|
43
|
+
def _get(self, path: str) -> Any:
|
|
44
|
+
return http_json(
|
|
45
|
+
f"{self.settings.url}{path}",
|
|
46
|
+
headers={"Authorization": f"Key {self.redash.api_key}"},
|
|
47
|
+
timeout=self.settings.timeout,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def _entry(self, item: dict[str, Any]) -> DashboardEntry:
|
|
51
|
+
ident = item.get("id") or item.get("slug")
|
|
52
|
+
public: str | None = None
|
|
53
|
+
try:
|
|
54
|
+
detail = self._get(f"/api/dashboards/{ident}")
|
|
55
|
+
public = detail.get("public_url")
|
|
56
|
+
except (OSError, ValueError):
|
|
57
|
+
public = None
|
|
58
|
+
page = f"{self.settings.url}/dashboards/{ident}"
|
|
59
|
+
if item.get("slug") and item.get("id"):
|
|
60
|
+
page += f"-{item['slug']}"
|
|
61
|
+
return DashboardEntry(
|
|
62
|
+
id=str(ident),
|
|
63
|
+
title=str(item.get("name") or f"Dashboard {ident}"),
|
|
64
|
+
description="shared (embeddable)" if public else "not shared: opens in a new tab",
|
|
65
|
+
url=public or page,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def fetch(self) -> list[DashboardEntry]:
|
|
69
|
+
if not self.redash.api_key:
|
|
70
|
+
return []
|
|
71
|
+
data = self._get("/api/dashboards?page_size=100&order=name")
|
|
72
|
+
items = data.get("results", data) if isinstance(data, dict) else data
|
|
73
|
+
return [self._entry(i) for i in list(items)[:DETAIL_LIMIT] if not i.get("is_archived")]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _provider(context: ProviderContext) -> RedashProvider:
|
|
77
|
+
return RedashProvider(settings_of(RedashSettings, context.settings, "redash"))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
plugin = Plugin(
|
|
81
|
+
name="redash",
|
|
82
|
+
kind="dashboards",
|
|
83
|
+
title="Redash",
|
|
84
|
+
description="Show dashboards of an existing Redash instance inside Platybus (web view).",
|
|
85
|
+
dashboards=_provider,
|
|
86
|
+
settings_model=RedashSettings,
|
|
87
|
+
# on demand: `platybus sandbox up redash`
|
|
88
|
+
sandbox=REDASH_SERVICES,
|
|
89
|
+
settings_sandbox=SandboxPreset(
|
|
90
|
+
services=("redash",), settings={"url": REDASH_URL, "api_key": REDASH_API_KEY}
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
__all__ = ["RedashProvider", "RedashSettings", "plugin"]
|
|
File without changes
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Sandbox services: a local Redash (with its Redis) to try the Redash dashboard provider.
|
|
2
|
+
|
|
3
|
+
On demand (``platybus sandbox up redash``). One container runs the web server, an RQ
|
|
4
|
+
worker and the scheduler. Its metadata lives in a ``redash`` database on the sandbox
|
|
5
|
+
Postgres. On every start a setup script (idempotent) creates that database, the tables,
|
|
6
|
+
the admin user ``platybus@example.com`` with the sandbox password, a fixed API key (so the
|
|
7
|
+
plugin can list dashboards right away) and a data source for the sandbox ``shop`` database.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from platybus.sandbox import SANDBOX_PASSWORD, SANDBOX_USER, SandboxService
|
|
13
|
+
|
|
14
|
+
REDASH_IMAGE = "redash/redash:26.9.0"
|
|
15
|
+
REDIS_IMAGE = "redis:7-alpine"
|
|
16
|
+
#: Host port of the web UI (the container listens on 5000).
|
|
17
|
+
REDASH_PORT = 18500
|
|
18
|
+
REDASH_URL = f"http://127.0.0.1:{REDASH_PORT}"
|
|
19
|
+
REDASH_EMAIL = f"{SANDBOX_USER}@example.com"
|
|
20
|
+
#: API key of the sandbox admin: a well-known development value, like every sandbox secret.
|
|
21
|
+
REDASH_API_KEY = "platybus-sandbox-redash-api-key"
|
|
22
|
+
|
|
23
|
+
_PG = {"host": "postgres", "port": 5432, "user": SANDBOX_USER, "password": SANDBOX_PASSWORD}
|
|
24
|
+
|
|
25
|
+
SETUP_PY = f"""\
|
|
26
|
+
# Generated by the Platybus sandbox: idempotent first-start setup of Redash.
|
|
27
|
+
import json
|
|
28
|
+
import subprocess
|
|
29
|
+
import time
|
|
30
|
+
|
|
31
|
+
import psycopg2
|
|
32
|
+
|
|
33
|
+
PG = {_PG!r}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def connect(dbname):
|
|
37
|
+
for _ in range(60):
|
|
38
|
+
try:
|
|
39
|
+
conn = psycopg2.connect(dbname=dbname, **PG)
|
|
40
|
+
conn.autocommit = True
|
|
41
|
+
return conn
|
|
42
|
+
except psycopg2.OperationalError:
|
|
43
|
+
time.sleep(2)
|
|
44
|
+
raise SystemExit("cannot reach the sandbox Postgres")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
with connect("postgres").cursor() as cur:
|
|
48
|
+
cur.execute("SELECT 1 FROM pg_database WHERE datname = 'redash'")
|
|
49
|
+
if cur.fetchone() is None:
|
|
50
|
+
cur.execute("CREATE DATABASE redash")
|
|
51
|
+
|
|
52
|
+
subprocess.run(["/app/manage.py", "database", "create_tables"], check=True)
|
|
53
|
+
|
|
54
|
+
with connect("redash").cursor() as cur:
|
|
55
|
+
cur.execute("SELECT count(*) FROM users")
|
|
56
|
+
if cur.fetchone()[0] == 0:
|
|
57
|
+
subprocess.run(
|
|
58
|
+
["/app/manage.py", "users", "create_root", {REDASH_EMAIL!r}, "Platybus",
|
|
59
|
+
"--password", {SANDBOX_PASSWORD!r}],
|
|
60
|
+
check=True,
|
|
61
|
+
)
|
|
62
|
+
cur.execute("UPDATE users SET api_key = %s WHERE email = %s",
|
|
63
|
+
({REDASH_API_KEY!r}, {REDASH_EMAIL!r}))
|
|
64
|
+
cur.execute("SELECT 1 FROM data_sources WHERE name = 'Sandbox shop'")
|
|
65
|
+
if cur.fetchone() is None:
|
|
66
|
+
options = dict(PG, dbname="shop")
|
|
67
|
+
subprocess.run(
|
|
68
|
+
["/app/manage.py", "ds", "new", "Sandbox shop", "--type", "pg",
|
|
69
|
+
"--options", json.dumps(options)],
|
|
70
|
+
check=True,
|
|
71
|
+
)
|
|
72
|
+
print("Redash sandbox setup done")
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
_ENV = {
|
|
76
|
+
"REDASH_DATABASE_URL": (f"postgresql://{SANDBOX_USER}:{SANDBOX_PASSWORD}@postgres:5432/redash"),
|
|
77
|
+
"REDASH_REDIS_URL": "redis://redash-redis:6379/0",
|
|
78
|
+
"REDASH_COOKIE_SECRET": "platybus-sandbox-redash-cookie-secret",
|
|
79
|
+
"REDASH_SECRET_KEY": "platybus-sandbox-redash-secret-key",
|
|
80
|
+
"REDASH_WEB_WORKERS": "2",
|
|
81
|
+
"WORKERS_COUNT": "1",
|
|
82
|
+
"QUEUES": "queries,scheduled_queries,schemas,periodic,emails,default",
|
|
83
|
+
"PYTHONUNBUFFERED": "1",
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
STARTUP = (
|
|
87
|
+
"python /sandbox/setup.py"
|
|
88
|
+
" && (/app/bin/docker-entrypoint worker &)"
|
|
89
|
+
" && (/app/bin/docker-entrypoint scheduler &)"
|
|
90
|
+
" && exec /app/bin/docker-entrypoint server"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
REDIS_SERVICE = SandboxService(
|
|
94
|
+
name="redash-redis",
|
|
95
|
+
title="Redis for Redash",
|
|
96
|
+
kind="bi",
|
|
97
|
+
image=REDIS_IMAGE,
|
|
98
|
+
healthcheck=("CMD", "redis-cli", "ping"),
|
|
99
|
+
description="Queue and cache of the sandbox Redash.",
|
|
100
|
+
on_demand=True,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
REDASH_SERVICE = SandboxService(
|
|
104
|
+
name="redash",
|
|
105
|
+
title="Redash",
|
|
106
|
+
kind="bi",
|
|
107
|
+
image=REDASH_IMAGE,
|
|
108
|
+
ports={REDASH_PORT: 5000},
|
|
109
|
+
environment=_ENV,
|
|
110
|
+
# the image's entrypoint passes unknown commands through: bash runs setup, then the
|
|
111
|
+
# worker and the scheduler in the background and the web server in the foreground
|
|
112
|
+
command=("bash", "-c", STARTUP),
|
|
113
|
+
healthcheck=(
|
|
114
|
+
"CMD",
|
|
115
|
+
"python",
|
|
116
|
+
"-c",
|
|
117
|
+
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:5000/ping', timeout=3)",
|
|
118
|
+
),
|
|
119
|
+
depends_on=("postgres", "redash-redis"),
|
|
120
|
+
files={"setup.py": SETUP_PY},
|
|
121
|
+
description="A BI server for the Redash dashboard provider; sign in as "
|
|
122
|
+
f"{REDASH_EMAIL} with the sandbox password. The sandbox Postgres shop database is a "
|
|
123
|
+
"data source.",
|
|
124
|
+
endpoints={
|
|
125
|
+
"url": REDASH_URL,
|
|
126
|
+
"user": REDASH_EMAIL,
|
|
127
|
+
"api_key": REDASH_API_KEY,
|
|
128
|
+
"data source": "Sandbox shop",
|
|
129
|
+
},
|
|
130
|
+
on_demand=True,
|
|
131
|
+
start_period=600,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
REDASH_SERVICES = (REDIS_SERVICE, REDASH_SERVICE)
|