Skip to content

Commit

Permalink
update cleanup function
Browse files Browse the repository at this point in the history
Signed-off-by: helenxie-bit <[email protected]>
  • Loading branch information
helenxie-bit committed Aug 30, 2024
1 parent ed10574 commit 50ed9e8
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions sdk/python/test/e2e/test_e2e_pytorchjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,32 +359,13 @@ def clean_up_resources():
print("Disk usage before removing unnecessary files:")
subprocess.run(["df", "-hT"], check=True)

# List all volumes and inspect them
print("Listing all Docker volumes:")
subprocess.run(["docker", "volume", "ls"], check=True)

# Prune unused volumes
print("Pruning unused Docker volumes...")
subprocess.run(["docker", "volume", "prune", "-f"], check=True)

# Check for stopped containers
print("Checking for stopped containers:")
subprocess.run(["docker", "ps", "-a"], check=True)

# Remove all stopped containers
print("Removing stopped containers...")
subprocess.run(["docker", "rm", "$(docker ps -a -q)"], shell=True, check=True)
subprocess.run(["docker", "system", "prune", "-a", "--volumes", "-f"], check=True)

# Display disk usage before cleanup
print("Disk usage before removing unnecessary files:")
# Display disk usage after cleanup
print("Disk usage after removing unnecessary files:")
subprocess.run(["df", "-hT"], check=True)

# Remove unnecessary docker files from the correct directory
print("Freeing up disk space by removing unnecessary files...")
subprocess.run([
"sudo", "rm", "-rf",
"/var/lib/docker"
], check=True)

except subprocess.CalledProcessError as e:
print(f"Error during Docker cleanup: {e}")

0 comments on commit 50ed9e8

Please sign in to comment.