Write an hourly running jobs status into a separate YAML#886
Write an hourly running jobs status into a separate YAML#886
Conversation
Append per-hour snapshot only when changed; otherwise emit a one-line heartbeat in ARC.log.
There was a problem hiding this comment.
Pull request overview
This PR reduces repetitive “currently running jobs” log spam by moving periodic status reporting out of ARC.log and into a dedicated YAML file, while logging only short heartbeat lines when the status hasn’t changed.
Changes:
- Added
Scheduler.report_running_jobs_snapshot()and wired it into the hourly scheduler reporting path. - Introduced
arc.common.append_yaml_document()to append multi-document YAML snapshots. - Added unit tests for both the scheduler snapshot reporting and the YAML append helper.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
arc/scheduler.py |
Writes periodic running-jobs/active-pipes snapshots to running_jobs.yml and logs a heartbeat when unchanged. |
arc/scheduler_test.py |
Adds a test ensuring snapshots append only when the status changes. |
arc/common.py |
Adds append_yaml_document() helper for multi-document YAML snapshot files. |
arc/common_test.py |
Adds tests for append_yaml_document(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| payload = {'running_jobs': dict(self.running_jobs), | ||
| 'active_pipes': list(self.active_pipes.keys())} | ||
| n_species = len(self.running_jobs) | ||
| n_jobs = sum(len(v) for v in self.running_jobs.values()) | ||
| n_pipes = len(self.active_pipes) | ||
| summary = f'{n_species} species / {n_jobs} jobs / {n_pipes} active pipes' | ||
| if payload == self._last_status_payload: | ||
| logger.info(f'Status unchanged: {summary}.') |
| def report_running_jobs_snapshot(self) -> None: | ||
| """ | ||
| Append a snapshot of the currently running jobs and active pipes to | ||
| ``<project>/running_jobs.yml`` (each snapshot is a separate YAML | ||
| document prefixed with ``---``). If the payload is identical to the | ||
| previous snapshot, only a one-line heartbeat is logged to ARC.log. | ||
| """ | ||
| payload = {'running_jobs': dict(self.running_jobs), | ||
| 'active_pipes': list(self.active_pipes.keys())} | ||
| n_species = len(self.running_jobs) | ||
| n_jobs = sum(len(v) for v in self.running_jobs.values()) | ||
| n_pipes = len(self.active_pipes) | ||
| summary = f'{n_species} species / {n_jobs} jobs / {n_pipes} active pipes' | ||
| if payload == self._last_status_payload: | ||
| logger.info(f'Status unchanged: {summary}.') | ||
| return | ||
| snapshot = {'timestamp': datetime.datetime.now().isoformat(timespec='seconds'), | ||
| **payload} | ||
| append_yaml_document(self.running_jobs_snapshot_path, snapshot) | ||
| logger.info(f'Status changed: {summary}; snapshot appended to running_jobs.yml.') |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #886 +/- ##
==========================================
- Coverage 60.40% 60.37% -0.04%
==========================================
Files 103 103
Lines 31156 31177 +21
Branches 8121 8122 +1
==========================================
+ Hits 18821 18824 +3
- Misses 9989 10005 +16
- Partials 2346 2348 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
don't spam the ARC.log if the report repeats it self and ARC is idle. outsource the running jobs report into a separate YAML, only update it when needed, and drop a heartbeat line into ARC's log file.
addresses #694