Skip to content

Conversation

@punit-naik-amp
Copy link
Contributor

@punit-naik-amp punit-naik-amp commented Oct 31, 2025

Summary

Major improvements to Chuck job status tracking and display, including new /jobs command, job caching, enhanced status display, and bug fixes.

Key Features

  • New /jobs command: List up to 20 recent cached jobs with status, records, and credit tracking
  • Job caching: Automatically cache last 20 jobs for quick lookup and parameterless queries
  • Enhanced display: Boxed format with Unicode borders, status symbols (✓✗◷), and dynamic width
  • Smart fallback: Use cached Databricks run IDs when backend returns placeholder values
  • Label improvements: "Processing" vs "Processed" changes based on job completion state

Technical Changes

  • Added job caching system with LRU eviction (20 job limit)
  • Migrated to prettytable library for table formatting
  • Fixed datetime deprecation warning in bug reports
  • Fixed URL wrapping issues with long Databricks links
  • Fixed duration calculation to use Chuck timestamps

Test Coverage

  • Added 30 new tests (17 for caching, 11 for /jobs, 2 for display)
  • All 359 command tests passing

Examples:

Without passing the job-id, fetches the last run chuck job along with databricks run status:

chuck > /job-status
┌─ Job: chk-20251031-24637-FvgQhjMQiHf ──────────────────────────────────────────────────────────────────────────────┐
│ Status: ◷ SUBMITTED                                                                                                │
│ Created: 2025-10-31 06:50:37.086                                                                                   │
│                                                                                                                    │
│ Databricks:                                                                                                        │
│ Status: RUNNING                                                                                                    │
│ Run ID: 1099033616708616                                                                                           │
│ Name: Stitch Setup: stitch-2025-10-31_12-20                                                                        │
│ Creator: v-punit.naik@amperity.com                                                                                 │
│ Tasks: 1                                                                                                           │
│                                                                                                                    │
│ • View: https://dbc-6e75f43b-0f28.cloud.databricks.com/?o=4142544475373761#job/383234174830207/run/1099033616708616│
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Fetching chuck job status:

chuck > /job-status --job-id chk-20251031-24637-FvgQhjMQiHf
┌─ Job: chk-20251031-24637-FvgQhjMQiHf ──────────────────────────────────────────┐
│ Status: ◷ SUBMITTED                                                            │
│ Created: 2025-10-31 06:50:37.086                                               │
└────────────────────────────────────────────────────────────────────────────────┘

Fetching databricks run status:

chuck > /job-status --run-id 1099033616708616
┌─ Databricks Run: 1099033616708616 ─────────────────────────────────────────────────────────────────────────────────┐
│ Status: ◷ RUNNING                                                                                                  │
│ Name: Stitch Setup: stitch-2025-10-31_12-20                                                                        │
│ Creator: v-punit.naik@amperity.com                                                                                 │
│ Tasks: 1                                                                                                           │
│                                                                                                                    │
│ • View: https://dbc-6e75f43b-0f28.cloud.databricks.com/?o=4142544475373761#job/383234174830207/run/1099033616708616│
│                                                                                                                    │
│ Note: Databricks data only - no Chuck telemetry                                                                    │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Job running:

chuck > /job-status
┌─ Job: chk-20251031-24637-FvgQhjMQiHf ──────────────────────────────────────────────────────────────────────────────┐
│ Status: ◷ RUNNING                                                                                                  │
│ Created: 2025-10-31 06:50:37.086                                                                                   │
│ Started: 2025-10-31 06:59:34.519592987                                                                             │
│                                                                                                                    │
│ Processing:                                                                                                        │
│ • Records: 7,155,216                                                                                               │
│ • Build: stitch-service-build/7766-6a34055                                                                         │
│                                                                                                                    │
│ Databricks:                                                                                                        │
│ Status: RUNNING                                                                                                    │
│ Run ID: 1099033616708616                                                                                           │
│ Name: Stitch Setup: stitch-2025-10-31_12-20                                                                        │
│ Creator: v-punit.naik@amperity.com                                                                                 │
│ Tasks: 1                                                                                                           │
│                                                                                                                    │
│ • View: https://dbc-6e75f43b-0f28.cloud.databricks.com/?o=4142544475373761#job/383234174830207/run/1099033616708616│
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Job running but no chuck telemetry:

chuck > /job-status --run-id 1099033616708616
┌─ Databricks Run: 1099033616708616 ─────────────────────────────────────────────────────────────────────────────────┐
│ Status: ◷ RUNNING                                                                                                  │
│ Name: Stitch Setup: stitch-2025-10-31_12-20                                                                        │
│ Creator: v-punit.naik@amperity.com                                                                                 │
│ Tasks: 1                                                                                                           │
│                                                                                                                    │
│ • View: https://dbc-6e75f43b-0f28.cloud.databricks.com/?o=4142544475373761#job/383234174830207/run/1099033616708616│
│                                                                                                                    │
│ Note: Databricks data only - no Chuck telemetry                                                                    │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Job succeeded:

chuck > /job-status
┌─ Job: chk-20251031-24637-FvgQhjMQiHf ──────────────────────────────────────────────────────────────────────────────┐
│ Status: ✓ SUCCEEDED                                                                                                │
│ Created: 2025-10-31 06:50:37.086                                                                                   │
│ Started: 2025-10-31 06:59:34.519592987                                                                             │
│ Ended:   2025-10-31 07:06:49.213575308                                                                             │
│ Duration: 7m 14s                                                                                                   │
│                                                                                                                    │
│ Processed:                                                                                                         │
│ • Records: 7,155,216                                                                                               │
│ • Build: stitch-service-build/7766-6a34055                                                                         │
│                                                                                                                    │
│ Databricks:                                                                                                        │
│ Status: TERMINATED (SUCCESS)                                                                                       │
│ Run ID: 1099033616708616                                                                                           │
│ Name: Stitch Setup: stitch-2025-10-31_12-20                                                                        │
│ Creator: v-punit.naik@amperity.com                                                                                 │
│ Execution: 15m 34s                                                                                                 │
│ Tasks: 1                                                                                                           │
│                                                                                                                    │
│ • View: https://dbc-6e75f43b-0f28.cloud.databricks.com/?o=4142544475373761#job/383234174830207/run/1099033616708616│
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Job succeeded but no chuck telemetry:

chuck > /job-status --run-id 1099033616708616
┌─ Databricks Run: 1099033616708616 ─────────────────────────────────────────────────────────────────────────────────┐
│ Status: ✓ TERMINATED (SUCCESS)                                                                                     │
│ Name: Stitch Setup: stitch-2025-10-31_12-20                                                                        │
│ Creator: v-punit.naik@amperity.com                                                                                 │
│ Execution: 15m 34s                                                                                                 │
│ Tasks: 1                                                                                                           │
│                                                                                                                    │
│ • View: https://dbc-6e75f43b-0f28.cloud.databricks.com/?o=4142544475373761#job/383234174830207/run/1099033616708616│
│                                                                                                                    │
│ Note: Databricks data only - no Chuck telemetry                                                                    │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Print recent jobs:

chuck > /jobs
Recent Jobs:

+--------------------------------+-----------+-----------+---------+
| Job ID                         | Status    |   Records | Credits |
+--------------------------------+-----------+-----------+---------+
| chk-20251031-27413-8Gt2TkDgJPv | ◷ Running | 7,155,216 |       - |
| chk-test-789                   | ◷ Unknown |         - |       - |
| chk-test-456                   | ◷ Unknown |         - |       - |
| chk-20251031-24637-FvgQhjMQiHf | ✓ Success | 7,155,216 |       - |
| chk-20251031-20942-BnhtPxu8YJz | ✓ Success | 7,155,216 |       - |
+--------------------------------+-----------+-----------+---------+

Total credits used: 0

…egration

Core Features:
- Add job_cache.py with LRU eviction (last 5 jobs) and persistence
- Cache job_id/run_id pairs on launch, enable parameterless /job-status queries
- Fallback to cached run_id when Chuck backend returns UNSET_DATABRICKS_RUN_ID
- Parameterless queries auto-enable live Databricks data when cached run_id exists

Display Improvements:
- Refactor to boxed output format with Unicode borders (┌─┐│└┘)
- Add status symbols: ✓ (succeeded), ✗ (failed), ◷ (running/other)
- Change "Processing" to "Processed" for completed jobs (SUCCEEDED/FAILED)
- Expand box width dynamically to accommodate full Databricks URLs on single line
- Fix Databricks section to only show with --live flag (except parameterless queries)
- Match Databricks section format to --run-id output (Status, Run ID, Name, Creator, Execution, Tasks, View)
- Fix duration calculation to use Chuck timestamps (start-time to end-time)
- Preserve full Databricks state object with life_cycle_state and result_state fields

Testing:
- Add 17 unit tests for caching and fallback functionality
- Add 2 tests for dynamic box width and URL display
- All 348 tests passing

Fixes:
- URL wrapping issue where clicking wrapped URLs only opened partial links
- Duration now correctly uses Chuck job timestamps instead of Databricks execution time
- Databricks section no longer appears without --live flag
Implements a new /jobs command that displays a table of recently launched
jobs from the cache (last 5 jobs). The command fetches full job details from
the Chuck API and displays them in a formatted markdown table.

Features:
- List recent jobs with status symbols (✓ Success, ✗ Failed, ◷ Running)
- Display job ID, status, record count, and credits
- Format record counts with comma separators (e.g., 50,000)
- Show total credits used across all listed jobs
- Graceful fallback when authentication unavailable (shows job IDs only)
- Handle API errors and missing jobs gracefully

Implementation:
- Added handle_list_jobs() to job_status.py for main command handler
- Added _format_jobs_table() for full table formatting with details
- Added _format_jobs_table_minimal() for unauthenticated display
- Moved list jobs functionality to job_status.py (collocated with Chuck job commands)
- Registered LIST_JOBS_DEFINITION in command registry

Display behavior:
- Missing records show as "-"
- Missing credits show as "-"
- Total credits line only appears when credits > 0
- Box width dynamically expands for long Databricks URLs (from earlier commits)

Testing:
- Added 11 comprehensive unit tests covering all scenarios
- Tests moved to test_job_status.py alongside implementation
- All 359 tests passing
Replace deprecated datetime.utcnow() with timezone-aware datetime.now(timezone.utc)
to address Python 3.12+ deprecation warnings. The new format produces ISO 8601
timestamps with explicit UTC indicator (+00:00) and is fully backwards compatible.
@punit-naik-amp punit-naik-amp self-assigned this Oct 31, 2025
@punit-naik-amp punit-naik-amp merged commit c27a175 into main Oct 31, 2025
2 checks passed
@punit-naik-amp punit-naik-amp deleted the CHUCK-3-job-status-command-improvements branch October 31, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants