|
7 | 7 | import logging
|
8 | 8 | import errno
|
9 | 9 | import re
|
10 |
| -# Use pty to create a pseudo-terminal for better interactive support |
11 | 10 | import pty
|
12 | 11 | import select
|
13 | 12 | import fcntl
|
|
16 | 15 | import signal
|
17 | 16 | import json
|
18 | 17 |
|
19 |
| -# Configure logging |
20 | 18 | logging.basicConfig(level=logging.INFO,
|
21 | 19 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
22 | 20 | handlers=[logging.FileHandler("dlt-meta-app.log"),
|
@@ -227,15 +225,15 @@ def start_command():
|
227 | 225 | if 'PYTHONPATH' not in os.environ or not os.path.isdir(os.environ.get('PYTHONPATH', '')):
|
228 | 226 | commands = [
|
229 | 227 | "pip install databricks-cli",
|
230 |
| - # "git clone https://github.com/databrickslabs/dlt-meta.git", |
231 |
| - "git clone https://github.com/dattawalake/dlt-meta.git", |
| 228 | + "git clone https://github.com/databrickslabs/dlt-meta.git", |
232 | 229 | f"python -m venv {current_directory}/dlt-meta/.venv",
|
233 | 230 | f"export HOME={current_directory}",
|
234 | 231 | "cd dlt-meta",
|
235 | 232 | "source .venv/bin/activate",
|
236 | 233 | f"export PYTHONPATH={current_directory}/dlt-meta/",
|
237 | 234 | "pwd",
|
238 | 235 | "pip install databricks-sdk",
|
| 236 | + "pip install PyYAML", |
239 | 237 | ]
|
240 | 238 | print("Start setting up dlt-meta environment")
|
241 | 239 | for c in commands:
|
@@ -322,6 +320,7 @@ def handle_onboard_form():
|
322 | 320 | "silver_schema": request.form.get('silver_schema', 'dltmeta_silver_7b4e981029b843c799bf61a0a121b3ca'),
|
323 | 321 | "dlt_meta_layer": request.form.get('dlt_meta_layer', '1'),
|
324 | 322 | "bronze_table": request.form.get('bronze_table', 'bronze_dataflowspec'),
|
| 323 | + "silver_table": request.form.get('silver_table', 'silver_dataflowspec'), |
325 | 324 | "overwrite": "1" if request.form.get('overwrite') == "1" else "0",
|
326 | 325 | "version": request.form.get('version', 'v1'),
|
327 | 326 | "environment": request.form.get('environment', 'prod'),
|
@@ -375,26 +374,67 @@ def handle_deploy_form():
|
375 | 374 | def run_demo():
|
376 | 375 | code_to_run = request.json.get('demo_name', '')
|
377 | 376 | print(f"processing demo for :{request.json}")
|
378 |
| - current_directory = os.environ['PYTHONPATH'] # os.getcwd() |
| 377 | + current_directory = os.environ['PYTHONPATH'] |
379 | 378 | demo_dict = {"demo_cloudfiles": "demo/launch_af_cloudfiles_demo.py",
|
380 | 379 | "demo_acf": "demo/launch_acfs_demo.py",
|
381 | 380 | "demo_silverfanout": "demo/launch_silver_fanout_demo.py",
|
382 |
| - "demo_dias": "demo/launch_dais_demo.py" |
| 381 | + "demo_dias": "demo/launch_dais_demo.py", |
| 382 | + "demo_dlt_sink": "demo/launch_dlt_sink_demo.py", |
| 383 | + "demo_dabs": "demo/generate_dabs_resources.py" |
383 | 384 | }
|
384 | 385 | demo_file = demo_dict.get(code_to_run, None)
|
385 | 386 | uc_name = request.json.get('uc_name', '')
|
386 |
| - result = subprocess.run(f"python {current_directory}/{demo_file} --uc_catalog_name {uc_name} --profile DEFAULT", |
387 |
| - shell=True, |
388 |
| - capture_output=True, |
389 |
| - text=True |
390 |
| - ) |
| 387 | + |
| 388 | + if code_to_run == 'demo_dabs': |
| 389 | + |
| 390 | + # Step 1: Generate Databricks resources |
| 391 | + subprocess.run(f"python {current_directory}/{demo_file} --uc_catalog_name {uc_name} " |
| 392 | + f"--source=cloudfiles --profile DEFAULT", |
| 393 | + shell=True, |
| 394 | + capture_output=True, |
| 395 | + text=True |
| 396 | + ) |
| 397 | + |
| 398 | + # Step 2: Change working directory to demo/dabs for all next commands |
| 399 | + subprocess.run("databricks bundle validate --profile=DEFAULT", cwd=f"{current_directory}/demo/dabs", |
| 400 | + shell=True, |
| 401 | + capture_output=True, |
| 402 | + text=True) |
| 403 | + |
| 404 | + # Step 4: Deploy the bundle |
| 405 | + subprocess.run("databricks bundle deploy --target dev --profile=DEFAULT", |
| 406 | + cwd=f"{current_directory}/demo/dabs", shell=True, |
| 407 | + capture_output=True, |
| 408 | + text=True) |
| 409 | + |
| 410 | + # Step 5: Run 'onboard_people' task |
| 411 | + rs1 = subprocess.run("databricks bundle run onboard_people -t dev --profile=DEFAULT", |
| 412 | + cwd=f"{current_directory}/demo/dabs", shell=True, |
| 413 | + capture_output=True, |
| 414 | + text=True) |
| 415 | + print(f"onboarding completed: {rs1.stdout}") |
| 416 | + # Step 6: Run 'execute_pipelines_people' task |
| 417 | + result = subprocess.run("databricks bundle run execute_pipelines_people -t dev --profile=DEFAULT", |
| 418 | + cwd=f"{current_directory}/demo/dabs", |
| 419 | + shell=True, |
| 420 | + capture_output=True, |
| 421 | + text=True |
| 422 | + ) |
| 423 | + print(f"execution of pipeline completed: {result.stdout}") |
| 424 | + else: |
| 425 | + result = subprocess.run(f"python {current_directory}/{demo_file} --uc_catalog_name {uc_name} " |
| 426 | + f"--profile DEFAULT", |
| 427 | + shell=True, |
| 428 | + capture_output=True, |
| 429 | + text=True |
| 430 | + ) |
391 | 431 | return extract_command_output(result)
|
392 | 432 |
|
393 | 433 |
|
394 | 434 | def extract_command_output(result):
|
395 | 435 | stdout = result.stdout
|
396 | 436 | job_id_match = re.search(r"job_id=(\d+) | pipeline=(\d+)", stdout)
|
397 |
| - url_match = re.search(r"url=(https?://[^\s]+)", stdout) |
| 437 | + url_match = re.search(r"(https?://[^\s]+)", stdout) |
398 | 438 |
|
399 | 439 | job_id = job_id_match.group(1) or job_id_match.group(2) if job_id_match else None
|
400 | 440 | job_url = url_match.group(1) if url_match else None
|
|
0 commit comments