Add comprehensive cleanup for local worker upon successful job run and upload#31
Add comprehensive cleanup for local worker upon successful job run and upload#31
Conversation
|
@nolan1999 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
…run and upload Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
7b9f3c0 to
c402c93
Compare
Coverage Report
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…leanup verification Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
I've rewritten the tests to test the actual
All tests mock the necessary dependencies and verify that Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR implements comprehensive cleanup for local workers after successful job completion and upload, addressing a critical resource management issue.
Problem
The existing cleanup implementation had several gaps:
shutil.rmtree(path_job)was outside the try-except block and could fail if variables weren't definedSolution
Enhanced Container Cleanup
container.stop()andcontainer.remove()calls after job completionRobust Exception Handling
finallyblock to ensure it executes regardless of exceptionsDefensive Programming
job_id,container, andpath_jobexistence before attempting cleanupImproved Logging
Example
Before this change, after processing multiple jobs:
$ docker ps -a CONTAINER ID IMAGE STATUS abc123 job-image:v1 Exited def456 job-image:v2 Exited ghi789 job-image:v3 Exited # Containers accumulate...After this change:
$ docker ps -a # Clean - no leftover containersTesting
Added comprehensive unit tests in
tests/unit/test_cleanup.pythat verify:Fixes #4.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.