Spaces:
Sleeping
Sleeping
Merge branch 'main' into mcp-scribe-client
Browse files- .github/workflows/update-docs.yml +0 -58
- .gitignore +1 -1
- scribe_python_client/yaml_export.py +47 -0
.github/workflows/update-docs.yml
DELETED
|
@@ -1,58 +0,0 @@
|
|
| 1 |
-
name: Export Superset Tables and Create PR
|
| 2 |
-
|
| 3 |
-
on:
|
| 4 |
-
push:
|
| 5 |
-
branches:
|
| 6 |
-
- main
|
| 7 |
-
- issue-5-superset-token-cache
|
| 8 |
-
workflow_dispatch:
|
| 9 |
-
|
| 10 |
-
jobs:
|
| 11 |
-
export-and-pr:
|
| 12 |
-
runs-on: ubuntu-latest
|
| 13 |
-
|
| 14 |
-
steps:
|
| 15 |
-
- name: Checkout repo
|
| 16 |
-
uses: actions/checkout@v4
|
| 17 |
-
with:
|
| 18 |
-
fetch-depth: 0
|
| 19 |
-
|
| 20 |
-
- name: Set up Python
|
| 21 |
-
uses: actions/setup-python@v5
|
| 22 |
-
with:
|
| 23 |
-
python-version: '3.11'
|
| 24 |
-
|
| 25 |
-
- name: Install dependencies
|
| 26 |
-
run: |
|
| 27 |
-
python -m pip install --upgrade pip
|
| 28 |
-
pip install .
|
| 29 |
-
pip install networkx pyvis
|
| 30 |
-
|
| 31 |
-
- name: Run export commands
|
| 32 |
-
run: |
|
| 33 |
-
python -m scribe_python_client.cli --api-call get-dataset-tables-dict --env dev --username "${{ secrets.SUPERSET_USERNAME }}" --password "${{ secrets.SUPERSET_PASSWORD }}"
|
| 34 |
-
python -m scribe_python_client.cli --api-call get-dataset-tables-md --env dev --username "${{ secrets.SUPERSET_USERNAME }}" --password "${{ secrets.SUPERSET_PASSWORD }}"
|
| 35 |
-
|
| 36 |
-
- name: Bump version
|
| 37 |
-
run: |
|
| 38 |
-
VERSION_FILE="scribe_python_client/version.py"
|
| 39 |
-
OLD_VERSION=$(grep '__version__' $VERSION_FILE | cut -d '"' -f2)
|
| 40 |
-
NEW_VERSION=$(echo $OLD_VERSION | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
| 41 |
-
echo "__version__ = \"$NEW_VERSION\"" > $VERSION_FILE
|
| 42 |
-
echo "Bumped version from $OLD_VERSION to $NEW_VERSION"
|
| 43 |
-
|
| 44 |
-
- name: Create PR
|
| 45 |
-
uses: peter-evans/create-pull-request@v5
|
| 46 |
-
with:
|
| 47 |
-
token: ${{ secrets.GITHUB_TOKEN }}
|
| 48 |
-
commit-message: "Automated update of Superset docs and version bump"
|
| 49 |
-
title: "Update Superset Docs and Version"
|
| 50 |
-
body: |
|
| 51 |
-
This PR was automatically generated by a CI workflow.
|
| 52 |
-
|
| 53 |
-
- Updates: `docs/dataset_tables.json` and `docs/dataset_tables.md`
|
| 54 |
-
- Bumps the version in `scribe_python_client/version.py`
|
| 55 |
-
branch: update-docs
|
| 56 |
-
add-paths: |
|
| 57 |
-
docs/*
|
| 58 |
-
scribe_python_client/version.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
CHANGED
|
@@ -8,7 +8,7 @@ __pycache__/
|
|
| 8 |
|
| 9 |
# C extensions
|
| 10 |
*.so
|
| 11 |
-
|
| 12 |
# Distribution / packaging
|
| 13 |
.Python
|
| 14 |
build/
|
|
|
|
| 8 |
|
| 9 |
# C extensions
|
| 10 |
*.so
|
| 11 |
+
.vscode/mcp.json
|
| 12 |
# Distribution / packaging
|
| 13 |
.Python
|
| 14 |
build/
|
scribe_python_client/yaml_export.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import yaml
|
| 2 |
+
import csv
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
#Path to the YAML file that needs to be updated with column descriptions (Take the unzipped file, and copy the path of the yaml file here)
|
| 6 |
+
yaml_input_path = ""
|
| 7 |
+
|
| 8 |
+
#Path to the CSV file containing data we can export to YAML
|
| 9 |
+
# Sample: https://docs.google.com/spreadsheets/d/1MaUylXeocaeoJueLRRf6GdPAupSW88huCMPQeYjYfz8/edit?usp=sharing
|
| 10 |
+
csv_input_path = ""
|
| 11 |
+
|
| 12 |
+
#Path where the updated YAML file will be saved
|
| 13 |
+
yaml_output_path = ""
|
| 14 |
+
|
| 15 |
+
output_dir = os.path.dirname(yaml_output_path)
|
| 16 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
column_descriptions = {}
|
| 20 |
+
with open(csv_input_path, newline='', encoding='utf-8') as csvfile:
|
| 21 |
+
reader = csv.DictReader(csvfile)
|
| 22 |
+
for row in reader:
|
| 23 |
+
table = row['table_name'].strip()
|
| 24 |
+
column = row['column_name'].strip()
|
| 25 |
+
desc = row['column_description'].strip()
|
| 26 |
+
if desc:
|
| 27 |
+
column_descriptions[(table, column)] = desc
|
| 28 |
+
|
| 29 |
+
with open(yaml_input_path, 'r', encoding='utf-8') as f:
|
| 30 |
+
dataset = yaml.safe_load(f)
|
| 31 |
+
|
| 32 |
+
table_name = dataset.get('table_name')
|
| 33 |
+
columns = dataset.get('columns', [])
|
| 34 |
+
|
| 35 |
+
updated_count = 0
|
| 36 |
+
for col in columns:
|
| 37 |
+
col_name = col.get('column_name')
|
| 38 |
+
key = (table_name, col_name)
|
| 39 |
+
if key in column_descriptions:
|
| 40 |
+
col['description'] = column_descriptions[key]
|
| 41 |
+
updated_count += 1
|
| 42 |
+
|
| 43 |
+
with open(yaml_output_path, 'w', encoding='utf-8') as f:
|
| 44 |
+
yaml.dump(dataset, f, sort_keys=False, allow_unicode=True)
|
| 45 |
+
|
| 46 |
+
print(f"Updated descriptions for {updated_count} columns in dataset '{table_name}'.")
|
| 47 |
+
print(f"Saved updated YAML to: {yaml_output_path}")
|