-
Notifications
You must be signed in to change notification settings - Fork 0
Use per-future observed CPU/GPU metrics in runtime persistence #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0a74052
619e122
6546ad9
cd159b8
1365697
fffdd36
2c29205
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,7 @@ def send_data( | |||||||||||||
| redis_client: RedisClient | None = None, | ||||||||||||||
| database_url="", | ||||||||||||||
| ): | ||||||||||||||
| """UPSERT rows and attach allocated cpu/gpu from resources_by_agent.""" | ||||||||||||||
| """UPSERT rows with observed CPU and configured GPU resource values.""" | ||||||||||||||
| if not rows: | ||||||||||||||
| return | ||||||||||||||
| resources_by_agent = resources_by_agent or {} | ||||||||||||||
|
|
@@ -77,6 +77,8 @@ def send_data( | |||||||||||||
| ) | ||||||||||||||
| start = float(raw.get("created_at") or 0) | ||||||||||||||
| end = float(raw.get("finished_at") or time.time()) | ||||||||||||||
| cpu_resource = float(raw.get("cpu_resource") or res.get("cpu", 0)) | ||||||||||||||
| gpu_resource = float(res.get("gpu", 0)) | ||||||||||||||
|
Comment on lines
+80
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win Normalize resource values before persistence.
Proposed fix- cpu_resource = float(raw.get("cpu_resource") or res.get("cpu", 0))
- gpu_resource = float(res.get("gpu", 0))
+ cpu_resource = max(
+ float(raw.get("cpu_resource") or res.get("cpu", 0)), 0.0
+ )
+ gpu_resource = max(float(res.get("gpu", 0)), 0.0)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| conn.execute( | ||||||||||||||
| _UPSERT, | ||||||||||||||
|
|
@@ -86,8 +88,8 @@ def send_data( | |||||||||||||
| "workflow": workflow, | ||||||||||||||
| "agent": agent, | ||||||||||||||
| "execution_time": end - start, | ||||||||||||||
|
Saaketh0 marked this conversation as resolved.
|
||||||||||||||
| "cpu_resource": float(res.get("cpu", 0)), | ||||||||||||||
| "gpu_resource": float(res.get("gpu", 0)), | ||||||||||||||
| "cpu_resource": cpu_resource, | ||||||||||||||
| "gpu_resource": gpu_resource, | ||||||||||||||
| "created_at": str(start), | ||||||||||||||
| "updated_at": str(end), | ||||||||||||||
| }, | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Publish completion metrics atomically.
pull_data()scans any populatedfuture:*hash, whilesend_data()falls back to configured CPU whencpu_resourceis absent. Lines 468 and 474 use separate Redis commands, so ingestion can observefinished_atwithout the observed CPU and persist the static fallback.Use one
hset_multiplecompletion write, or make ingestion ignore hashes untilfinished_atis present and retry partial records.Proposed fix
🤖 Prompt for AI Agents