-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathinstall_skills_to_genie_code.sh
More file actions
executable file
·119 lines (99 loc) · 4.26 KB
/
install_skills_to_genie_code.sh
File metadata and controls
executable file
·119 lines (99 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
#!/bin/bash
# Deploy skills to Databricks Assistant skills folder
# This enables the built-in Assistant in Agent mode to use all skills
#
# PREREQUISITE: Run ./install_skills.sh first to install skills locally
#
# Usage: ./install_to_dbx_assistant.sh <profile-name>
set -e
PROFILE=${1:-"DEFAULT"}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
LOCAL_SKILLS_DIR="$PROJECT_ROOT/.claude/skills"
echo "================================================"
echo "Deploying Skills to Databricks Assistant"
echo "================================================"
echo "Profile: $PROFILE"
echo ""
# Install all skills (databricks + MLflow + APX) via install_skills.sh
echo " Installing all skills via install_skills.sh..."
INSTALL_SKILLS_SCRIPT="$PROJECT_ROOT/databricks-skills/install_skills.sh"
if [ ! -f "$INSTALL_SKILLS_SCRIPT" ]; then
echo -e "${RED}Error: install_skills.sh not found at ${INSTALL_SKILLS_SCRIPT}${NC}"
exit 1
fi
# Run install_skills.sh to download all skills (databricks, MLflow, APX)
(bash "$INSTALL_SKILLS_SCRIPT")
# Get current user email
USER_EMAIL=$(databricks current-user me --profile "$PROFILE" --output json 2>/dev/null | python3 -c "import sys, json; d=json.load(sys.stdin); print(d.get('userName', ''))" 2>/dev/null || echo "")
if [ -z "$USER_EMAIL" ]; then
echo "Error: Could not determine user email."
exit 1
fi
# Skills destination in workspace
SKILLS_PATH="/Users/$USER_EMAIL/.assistant/skills"
echo "User: $USER_EMAIL"
echo "Skills Path: $SKILLS_PATH"
echo ""
# Create the skills directory
echo "Step 1: Creating skills directory..."
databricks workspace mkdirs "$SKILLS_PATH" --profile "$PROFILE" 2>/dev/null || true
echo ""
# Function to upload a skill directory
upload_skill() {
local skill_dir="$1"
# Remove trailing slash if present
skill_dir="${skill_dir%/}"
local skill_name=$(basename "$skill_dir")
# Skip hidden dirs, TEMPLATE, and non-skill directories
if [[ "$skill_name" == "."* ]] || [[ "$skill_name" == "TEMPLATE" ]] || [[ ! -d "$skill_dir" ]]; then
return
fi
# Check if it has a SKILL.md
if [[ ! -f "$skill_dir/SKILL.md" ]]; then
return
fi
echo " Uploading skill: $skill_name"
# Create skill directory in workspace
databricks workspace mkdirs "$SKILLS_PATH/$skill_name" --profile "$PROFILE" 2>/dev/null || true
# Upload all markdown, python, and yaml files in the skill directory
find "$skill_dir" -type f \( -name "*.md" -o -name "*.py" -o -name "*.yaml" -o -name "*.yml" -o -name "*.sh" \) | while read -r file; do
# Get the relative path within the skill directory
rel_path="${file#$skill_dir/}"
dest_path="$SKILLS_PATH/$skill_name/$rel_path"
# Create parent directories if needed (for subdirs like scripts/)
parent_dir=$(dirname "$dest_path")
if [[ "$parent_dir" != "$SKILLS_PATH/$skill_name" ]]; then
databricks workspace mkdirs "$parent_dir" --profile "$PROFILE" 2>/dev/null || true
fi
# Upload file
databricks workspace import "$dest_path" --file "$file" --profile "$PROFILE" --format AUTO --overwrite 2>/dev/null || true
done
}
# Upload all skills from local .claude/skills directory
echo "Step 2: Uploading skills from $LOCAL_SKILLS_DIR..."
for skill_dir in "$LOCAL_SKILLS_DIR"/*/; do
upload_skill "$skill_dir"
done
echo ""
# List uploaded skills
echo "Step 3: Verifying deployment..."
echo ""
databricks workspace list "$SKILLS_PATH" --profile "$PROFILE" 2>/dev/null || echo " (Could not list skills)"
echo ""
echo "================================================"
echo "Deployment complete!"
echo ""
echo "Your Databricks Assistant in Agent mode now has access to:"
echo ""
skills_count=$(find "$LOCAL_SKILLS_DIR" -maxdepth 1 -type d -exec test -f {}/SKILL.md \; -print 2>/dev/null | wc -l | tr -d ' ')
echo " $skills_count skills deployed to: $SKILLS_PATH"
echo ""
echo "To use:"
echo " 1. Open a Databricks notebook/sql query/anywhere in the workspace"
echo " 2. Open the Genie Code panel"
echo " 3. Switch to 'Agent' mode"
echo " 4. Ask: 'Create a dashboard for my sales data'"
echo ""
echo "The Assistant will automatically load relevant skills!"
echo "================================================"