spark-cell-runner 0.7.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.
- spark_cell_runner-0.7.0/PKG-INFO +111 -0
- spark_cell_runner-0.7.0/README.md +84 -0
- spark_cell_runner-0.7.0/pyproject.toml +49 -0
- spark_cell_runner-0.7.0/setup.cfg +4 -0
- spark_cell_runner-0.7.0/spark_cell_runner/__init__.py +10 -0
- spark_cell_runner-0.7.0/spark_cell_runner/bootstrap.py +536 -0
- spark_cell_runner-0.7.0/spark_cell_runner/bootstrap_builder.py +224 -0
- spark_cell_runner-0.7.0/spark_cell_runner/cli.py +370 -0
- spark_cell_runner-0.7.0/spark_cell_runner/execute_sql.py +197 -0
- spark_cell_runner-0.7.0/spark_cell_runner/parser.py +178 -0
- spark_cell_runner-0.7.0/spark_cell_runner/pool.py +276 -0
- spark_cell_runner-0.7.0/spark_cell_runner/preview_table.py +86 -0
- spark_cell_runner-0.7.0/spark_cell_runner/runtime_data.py +7 -0
- spark_cell_runner-0.7.0/spark_cell_runner/session_driver.py +39 -0
- spark_cell_runner-0.7.0/spark_cell_runner/table_formats.py +143 -0
- spark_cell_runner-0.7.0/spark_cell_runner/uc_explore.py +111 -0
- spark_cell_runner-0.7.0/spark_cell_runner/uc_sync.py +242 -0
- spark_cell_runner-0.7.0/spark_cell_runner/warehouse_registry.py +30 -0
- spark_cell_runner-0.7.0/spark_cell_runner.egg-info/PKG-INFO +111 -0
- spark_cell_runner-0.7.0/spark_cell_runner.egg-info/SOURCES.txt +25 -0
- spark_cell_runner-0.7.0/spark_cell_runner.egg-info/dependency_links.txt +1 -0
- spark_cell_runner-0.7.0/spark_cell_runner.egg-info/entry_points.txt +2 -0
- spark_cell_runner-0.7.0/spark_cell_runner.egg-info/requires.txt +9 -0
- spark_cell_runner-0.7.0/spark_cell_runner.egg-info/top_level.txt +1 -0
- spark_cell_runner-0.7.0/tests/test_parser.py +111 -0
- spark_cell_runner-0.7.0/tests/test_pool.py +101 -0
- spark_cell_runner-0.7.0/tests/test_table_formats.py +131 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spark-cell-runner
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Run Databricks notebook-source .py cells and SQL against Databricks (Databricks Connect) or a local Sail Spark pool, with Unity Catalog sync and a local Delta / Iceberg warehouse.
|
|
5
|
+
Author: Iamprashanth-1
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: databricks,notebook,pyspark,spark,sail,unity-catalog,delta-lake,iceberg
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: pysail>=0.4
|
|
21
|
+
Requires-Dist: pyspark-client
|
|
22
|
+
Requires-Dist: databricks-sdk
|
|
23
|
+
Provides-Extra: databricks
|
|
24
|
+
Requires-Dist: databricks-connect; extra == "databricks"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest; extra == "dev"
|
|
27
|
+
|
|
28
|
+
# spark-cell-runner (Python CLI)
|
|
29
|
+
|
|
30
|
+
Run Databricks notebook-source `.py` cells and SQL from the terminal — against
|
|
31
|
+
Databricks (Databricks Connect) or fully offline on a local
|
|
32
|
+
[Sail](https://github.com/lakehq/sail) Spark pool — with Unity Catalog sync and
|
|
33
|
+
a local Delta / Iceberg warehouse. This is the pip-installable twin of the
|
|
34
|
+
[Spark Cell Runner VS Code extension](https://marketplace.visualstudio.com/items?itemName=PrashanthReddyMunagala.spark-cell-runner);
|
|
35
|
+
pools, warehouses, and Databricks profiles are shared between the two.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install spark-cell-runner
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# 1. Create and start a local pool (offline engine, ~1s startup, no JVM)
|
|
45
|
+
spark-cell-runner pool create dev
|
|
46
|
+
spark-cell-runner pool start dev
|
|
47
|
+
|
|
48
|
+
# 2. Run a Databricks notebook export, cell by cell
|
|
49
|
+
spark-cell-runner run my_notebook.py --pool dev
|
|
50
|
+
|
|
51
|
+
# 3. Run SQL
|
|
52
|
+
spark-cell-runner sql query.sql --pool dev
|
|
53
|
+
echo "SELECT 1" | spark-cell-runner sql - --pool dev
|
|
54
|
+
|
|
55
|
+
# 4. Mirror Unity Catalog schemas/tables into the local warehouse
|
|
56
|
+
spark-cell-runner sync --catalog main --schema sales --mode schema
|
|
57
|
+
spark-cell-runner sync --catalog main --mode data --format iceberg --limit 10000
|
|
58
|
+
|
|
59
|
+
# 5. Explore and preview (JSON / CSV)
|
|
60
|
+
spark-cell-runner explore --source local --level tables --pool dev
|
|
61
|
+
spark-cell-runner preview ~/.spark-cell-runner/warehouse/dev/demo.db/orders
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Open table formats: Delta + Iceberg
|
|
65
|
+
|
|
66
|
+
The local warehouse supports both open table formats natively (requires
|
|
67
|
+
`pysail >= 0.4`):
|
|
68
|
+
|
|
69
|
+
| | Delta | Iceberg |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| Write (Python) | `df.write.format('delta').save(path)` | `df.write.format('iceberg').save(path)` |
|
|
72
|
+
| Write (SQL) | `CREATE TABLE t ... USING delta LOCATION '...'` | `CREATE TABLE t ... USING iceberg LOCATION '...'` |
|
|
73
|
+
| Time travel | `VERSION AS OF 0` / `versionAsOf` option | `snapshotId` / `branch` / `tag` options |
|
|
74
|
+
| On-disk marker | `_delta_log/` | `metadata/*.metadata.json` |
|
|
75
|
+
|
|
76
|
+
A directory with either marker is a table: the warehouse registry re-registers
|
|
77
|
+
on-disk tables (both formats) into every new session, the Unity Catalog
|
|
78
|
+
explorer shows the format per table, and previews auto-detect the format.
|
|
79
|
+
The `sync` command and the extension's `sparkCellRunner.syncFormat` setting
|
|
80
|
+
choose the local format for UC sync (default `delta`).
|
|
81
|
+
|
|
82
|
+
## Running on Databricks instead
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
spark-cell-runner run my_notebook.py --serverless
|
|
86
|
+
spark-cell-runner run my_notebook.py --cluster-id 1234-567890 --profile DEFAULT
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Requires the `databricks-connect` extra: `pip install "spark-cell-runner[databricks]"`.
|
|
90
|
+
|
|
91
|
+
## Shared state with the VS Code extension
|
|
92
|
+
|
|
93
|
+
- Pools: `~/.spark-cell-runner/pools/<name>.json` (create from either side)
|
|
94
|
+
- Warehouses: `~/.spark-cell-runner/warehouse/<pool>/`
|
|
95
|
+
- Databricks profiles: `~/.databrickscfg`
|
|
96
|
+
|
|
97
|
+
## Notebook magic support
|
|
98
|
+
|
|
99
|
+
`%sql` (shown via `result.show()`), `%md` (skipped), `%python`, `%pip`
|
|
100
|
+
(reported, not auto-installed), `%sh`, and `%run` (reported) are handled;
|
|
101
|
+
plain Python cells execute against the shared session namespace.
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
cd python
|
|
107
|
+
pip install -e ".[dev]"
|
|
108
|
+
pytest tests
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
MIT License — see the repository for details.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# spark-cell-runner (Python CLI)
|
|
2
|
+
|
|
3
|
+
Run Databricks notebook-source `.py` cells and SQL from the terminal — against
|
|
4
|
+
Databricks (Databricks Connect) or fully offline on a local
|
|
5
|
+
[Sail](https://github.com/lakehq/sail) Spark pool — with Unity Catalog sync and
|
|
6
|
+
a local Delta / Iceberg warehouse. This is the pip-installable twin of the
|
|
7
|
+
[Spark Cell Runner VS Code extension](https://marketplace.visualstudio.com/items?itemName=PrashanthReddyMunagala.spark-cell-runner);
|
|
8
|
+
pools, warehouses, and Databricks profiles are shared between the two.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install spark-cell-runner
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# 1. Create and start a local pool (offline engine, ~1s startup, no JVM)
|
|
18
|
+
spark-cell-runner pool create dev
|
|
19
|
+
spark-cell-runner pool start dev
|
|
20
|
+
|
|
21
|
+
# 2. Run a Databricks notebook export, cell by cell
|
|
22
|
+
spark-cell-runner run my_notebook.py --pool dev
|
|
23
|
+
|
|
24
|
+
# 3. Run SQL
|
|
25
|
+
spark-cell-runner sql query.sql --pool dev
|
|
26
|
+
echo "SELECT 1" | spark-cell-runner sql - --pool dev
|
|
27
|
+
|
|
28
|
+
# 4. Mirror Unity Catalog schemas/tables into the local warehouse
|
|
29
|
+
spark-cell-runner sync --catalog main --schema sales --mode schema
|
|
30
|
+
spark-cell-runner sync --catalog main --mode data --format iceberg --limit 10000
|
|
31
|
+
|
|
32
|
+
# 5. Explore and preview (JSON / CSV)
|
|
33
|
+
spark-cell-runner explore --source local --level tables --pool dev
|
|
34
|
+
spark-cell-runner preview ~/.spark-cell-runner/warehouse/dev/demo.db/orders
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Open table formats: Delta + Iceberg
|
|
38
|
+
|
|
39
|
+
The local warehouse supports both open table formats natively (requires
|
|
40
|
+
`pysail >= 0.4`):
|
|
41
|
+
|
|
42
|
+
| | Delta | Iceberg |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| Write (Python) | `df.write.format('delta').save(path)` | `df.write.format('iceberg').save(path)` |
|
|
45
|
+
| Write (SQL) | `CREATE TABLE t ... USING delta LOCATION '...'` | `CREATE TABLE t ... USING iceberg LOCATION '...'` |
|
|
46
|
+
| Time travel | `VERSION AS OF 0` / `versionAsOf` option | `snapshotId` / `branch` / `tag` options |
|
|
47
|
+
| On-disk marker | `_delta_log/` | `metadata/*.metadata.json` |
|
|
48
|
+
|
|
49
|
+
A directory with either marker is a table: the warehouse registry re-registers
|
|
50
|
+
on-disk tables (both formats) into every new session, the Unity Catalog
|
|
51
|
+
explorer shows the format per table, and previews auto-detect the format.
|
|
52
|
+
The `sync` command and the extension's `sparkCellRunner.syncFormat` setting
|
|
53
|
+
choose the local format for UC sync (default `delta`).
|
|
54
|
+
|
|
55
|
+
## Running on Databricks instead
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
spark-cell-runner run my_notebook.py --serverless
|
|
59
|
+
spark-cell-runner run my_notebook.py --cluster-id 1234-567890 --profile DEFAULT
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Requires the `databricks-connect` extra: `pip install "spark-cell-runner[databricks]"`.
|
|
63
|
+
|
|
64
|
+
## Shared state with the VS Code extension
|
|
65
|
+
|
|
66
|
+
- Pools: `~/.spark-cell-runner/pools/<name>.json` (create from either side)
|
|
67
|
+
- Warehouses: `~/.spark-cell-runner/warehouse/<pool>/`
|
|
68
|
+
- Databricks profiles: `~/.databrickscfg`
|
|
69
|
+
|
|
70
|
+
## Notebook magic support
|
|
71
|
+
|
|
72
|
+
`%sql` (shown via `result.show()`), `%md` (skipped), `%python`, `%pip`
|
|
73
|
+
(reported, not auto-installed), `%sh`, and `%run` (reported) are handled;
|
|
74
|
+
plain Python cells execute against the shared session namespace.
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cd python
|
|
80
|
+
pip install -e ".[dev]"
|
|
81
|
+
pytest tests
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
MIT License — see the repository for details.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "spark-cell-runner"
|
|
7
|
+
version = "0.7.0"
|
|
8
|
+
description = "Run Databricks notebook-source .py cells and SQL against Databricks (Databricks Connect) or a local Sail Spark pool, with Unity Catalog sync and a local Delta / Iceberg warehouse."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Iamprashanth-1" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"databricks",
|
|
15
|
+
"notebook",
|
|
16
|
+
"pyspark",
|
|
17
|
+
"spark",
|
|
18
|
+
"sail",
|
|
19
|
+
"unity-catalog",
|
|
20
|
+
"delta-lake",
|
|
21
|
+
"iceberg",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"Environment :: Console",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"License :: OSI Approved :: MIT License",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.9",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
34
|
+
]
|
|
35
|
+
dependencies = [
|
|
36
|
+
"pysail>=0.4",
|
|
37
|
+
"pyspark-client",
|
|
38
|
+
"databricks-sdk",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
databricks = ["databricks-connect"]
|
|
43
|
+
dev = ["pytest"]
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
spark-cell-runner = "spark_cell_runner.cli:main"
|
|
47
|
+
|
|
48
|
+
[tool.setuptools]
|
|
49
|
+
packages = ["spark_cell_runner"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""spark-cell-runner — headless engine for Databricks notebook cells and SQL.
|
|
2
|
+
|
|
3
|
+
Runs Databricks notebook-source .py cells and SQL against Databricks
|
|
4
|
+
(Databricks Connect) or a local Sail Spark pool, with Unity Catalog sync and
|
|
5
|
+
a local Delta / Iceberg warehouse. The VS Code extension of the same name
|
|
6
|
+
ships these same modules and spawns them by path; this package is the
|
|
7
|
+
pip-installable CLI form.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.7.0"
|