Skip to content

Conversation

@punit-naik-amp
Copy link
Contributor

@punit-naik-amp punit-naik-amp commented Nov 3, 2025

  • Add /monitor-job command for real-time job monitoring

    • Monitors Chuck jobs until completion with live progress updates
    • Shows elapsed time, record count, and credits upon completion
    • Calculates elapsed time from actual job start (not monitoring start)
    • Supports monitoring via --job-id or --run-id
    • Falls back to last cached job if no parameters provided
    • Default 30-second poll interval, 30-minute timeout
  • Implement smart caching for job status data

    • Terminal state jobs (succeeded, failed, error, unknown) served from cache
    • Execution time drops from ~7s to <0.1s on subsequent runs
  • Cache UNKNOWN state for 404/error responses to prevent retry loops

  • Add diagnostic logging (cache hits/misses, timing metrics)

  • Add "Started" date column (format: YYYY-Mon-DD HH:MM)

  • Sort jobs by date in descending order (most recent first)

  • Implement timezone-aware datetime handling for proper sorting

  • Display total credits used across all jobs

  • Extend job_cache.py to store full job data (state, records, credits, timestamps)

  • Add cache_job() calls for terminal states in handle_list_jobs

  • Remove unnecessary cached_at field (use job's own timestamps)

  • Add 7 comprehensive tests for /jobs caching behavior

    • Cache hits for terminal states
    • Fresh data fetching for running jobs
    • UNKNOWN state caching on 404/errors
    • Mixed cache/fetch scenarios
  • All 71 job status tests pass

  • All 8 job cache tests pass

Usage:

chuck > /monitor

Monitoring job progress...
Job running... State: submitted, Elapsed: 1s
Job running... State: submitted, Elapsed: 32s
Job running... State: submitted, Elapsed: 1m 3s
Job running... State: submitted, Elapsed: 1m 34s
Job running... State: submitted, Elapsed: 2m 5s
Job running... State: submitted, Elapsed: 2m 37s
Job running... State: submitted, Elapsed: 3m 8s
Job running... State: submitted, Elapsed: 3m 39s
Job running... State: submitted, Elapsed: 4m 10s
Job running... State: submitted, Elapsed: 4m 41s
Job running... State: submitted, Elapsed: 5m 13s
Job running... State: submitted, Elapsed: 5m 44s
Job running... State: running, Elapsed: 29s, Records: 7,155,216
Job running... State: running, Elapsed: 1m 0s, Records: 7,155,216
Job running... State: running, Elapsed: 1m 32s, Records: 7,155,216
Job running... State: running, Elapsed: 2m 3s, Records: 7,155,216
Job running... State: running, Elapsed: 2m 34s, Records: 7,155,216
Job running... State: running, Elapsed: 3m 6s, Records: 7,155,216
Job running... State: running, Elapsed: 3m 37s, Records: 7,155,216
Job running... State: running, Elapsed: 4m 8s, Records: 7,155,216
Job running... State: running, Elapsed: 4m 39s, Records: 7,155,216
Job running... State: running, Elapsed: 5m 10s, Records: 7,155,216
Job running... State: running, Elapsed: 5m 42s, Records: 7,155,216
Job running... State: running, Elapsed: 6m 13s, Records: 7,155,216
Job running... State: running, Elapsed: 6m 44s, Records: 7,155,216
Job running... State: running, Elapsed: 7m 15s, Records: 7,155,216
Job running... State: running, Elapsed: 7m 46s, Records: 7,155,216
Job running... State: running, Elapsed: 8m 18s, Records: 7,155,216
Job running... State: running, Elapsed: 8m 49s, Records: 7,155,216
Job running... State: running, Elapsed: 9m 20s, Records: 7,155,216
Job running... State: running, Elapsed: 9m 51s, Records: 7,155,216
Job completed successfully! Records: 7,155,216
Job chk-20251103-36166-ez8ciF8cPBb completed successfully!
Records: 7,155,216
Credits: 61
chuck > /job-status
┌─ Job: chk-20251103-36166-ez8ciF8cPBb ─────────────────────────────────────────────────────────────────────────────┐
│ Status: ✓ SUCCEEDED                                                                                               │
│ Created: 2025-11-03 10:02:46.875                                                                                  │
│ Started: 2025-11-03 10:09:08.624520860                                                                            │
│ Ended:   2025-11-03 10:19:22.533733418                                                                            │
│ Duration: 10m 13s                                                                                                 │
│                                                                                                                   │
│ Processed:                                                                                                        │
│ • Records: 7,155,216                                                                                              │
│ • Credits: 61                                                                                                     │
│ • Build: stitch-service-build/7766-6a34055                                                                        │
│                                                                                                                   │
│ Databricks:                                                                                                       │
│ Status: TERMINATED (SUCCESS)                                                                                      │
│ Run ID: 665917544018311                                                                                           │
│ Name: Stitch Setup: stitch-2025-11-03_15-32                                                                       │
│ Creator: v-punit.naik@amperity.com                                                                                │
│ Execution: 16m 29s                                                                                                │
│ Tasks: 1                                                                                                          │
│                                                                                                                   │
│ • View: https://dbc-6e75f43b-0f28.cloud.databricks.com/?o=4142544475373761#job/664891708011811/run/665917544018311│
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
chuck > /jobs
Recent Jobs:

+--------------------------------+-----------+-------------------+-----------+---------+
| Job ID                         | Status    | Started           |   Records | Credits |
+--------------------------------+-----------+-------------------+-----------+---------+
| chk-20251103-36166-ez8ciF8cPBb | ✓ Success | 2025-Nov-03 10:09 | 7,155,216 |      61 |
| chk-20251103-33494-AH1TgWB9AWa | ✓ Success | 2025-Nov-03 09:23 | 7,155,216 |      61 |
| chk-20251103-32414-3Y52fPb4sRo | ✓ Success | 2025-Nov-03 09:06 | 7,155,216 |      61 |
| chk-20251103-30395-Qyxp662YJBL | ✓ Success | 2025-Nov-03 08:32 | 7,155,216 |      61 |
| chk-20251103-30311-LDtBzVtnYkQ | ✓ Success | 2025-Nov-03 08:31 | 7,155,216 |      61 |
| chk-20251102-67214-CXkc2xKEk8j | ✓ Success | 2025-Nov-02 18:47 | 7,155,216 |      61 |
| chk-20251102-66035-aDkVHKnUuyM | ✓ Success | 2025-Nov-02 18:27 | 7,155,216 |      61 |
| chk-20251101-06903-HeLg3TqDBnY | ✓ Success | 2025-Nov-01 02:03 | 7,155,216 |      61 |
| chk-20251031-27413-8Gt2TkDgJPv | ✓ Success | 2025-Oct-31 07:45 | 7,155,216 |       - |
| chk-20251031-24637-FvgQhjMQiHf | ✓ Success | 2025-Oct-31 06:59 | 7,155,216 |       - |
| chk-20251031-20942-BnhtPxu8YJz | ✓ Success | 2025-Oct-31 05:55 | 7,155,216 |       - |
| chk-test-789                   | ◷ Unknown | -                 |         - |       - |
| chk-test-456                   | ◷ Unknown | -                 |         - |       - |
| chk-999                        | ◷ Unknown | -                 |         - |       - |
| chk-456                        | ◷ Unknown | -                 |         - |       - |
| chk-123                        | ◷ Unknown | -                 |         - |       - |
| chk-20251101-16064-GMx3eA2pGMX | ◷ Unknown | -                 |         - |       - |
| chk-20251101-15719-DWBXUTLMJEf | ◷ Unknown | -                 |         - |       - |
| chk-20251101-13942-VZbBEkhMGig | ◷ Unknown | -                 |         - |       - |
| chk-20251101-12525-a7Hqr6JWRGj | ◷ Unknown | -                 |         - |       - |
+--------------------------------+-----------+-------------------+-----------+---------+

Improves developer experience with faster job listing and real-time monitoring

@punit-naik-amp punit-naik-amp self-assigned this Nov 3, 2025
message += f"\nCredits: {credits}"
return CommandResult(True, message=message, data=job_data)

if normalized_state in ["failed", "error"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend can return :unauthorized we should have if normalized_state in ["failed", "error", "unauthorized"]:

Copy link
Contributor

@pragyan-amp pragyan-amp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks great.. I have added my comments... Most critical one being adding support to escape them monitoring command when it is running... rest are just small things... Approving it to merge.. :shipit:

@punit-naik-amp punit-naik-amp force-pushed the CHUCK-3-continuously-monitor-stitch-job branch from 9de6d12 to 04beb50 Compare November 3, 2025 14:33
- Add `/monitor-job` command for real-time job monitoring
  - Monitors Chuck jobs until completion with live progress updates
  - Shows elapsed time, record count, and credits upon completion
  - Calculates elapsed time from actual job start (not monitoring start)
  - Supports monitoring via --job-id or --run-id
  - Falls back to last cached job if no parameters provided
  - Default 30-second poll interval, 30-minute timeout

- Implement smart caching for job status data
  - Terminal state jobs (succeeded, failed, error, unknown) served from cache
  - Reduces API calls from 16 to 0 for fully cached jobs
  - Execution time drops from ~7s to <0.1s on subsequent runs
- Cache UNKNOWN state for 404/error responses to prevent retry loops
- Add diagnostic logging (cache hits/misses, timing metrics)

- Add "Started" date column (format: YYYY-Mon-DD HH:MM)
- Sort jobs by date in descending order (most recent first)
- Implement timezone-aware datetime handling for proper sorting
- Display total credits used across all jobs

- Extend job_cache.py to store full job data (state, records, credits, timestamps)
- Add cache_job() calls for terminal states in handle_list_jobs
- Remove unnecessary cached_at field (use job's own timestamps)

- Add 7 comprehensive tests for /jobs caching behavior
  - Cache hits for terminal states
  - Fresh data fetching for running jobs
  - UNKNOWN state caching on 404/errors
  - Mixed cache/fetch scenarios
- All 71 job status tests pass
- All 8 job cache tests pass

Improves developer experience with faster job listing and real-time monitoring
@punit-naik-amp punit-naik-amp force-pushed the CHUCK-3-continuously-monitor-stitch-job branch from 04beb50 to e1864cc Compare November 3, 2025 14:34
@punit-naik-amp punit-naik-amp merged commit be7d504 into main Nov 3, 2025
2 checks passed
@punit-naik-amp punit-naik-amp deleted the CHUCK-3-continuously-monitor-stitch-job branch November 3, 2025 14:35
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