forked from Cloud-CV/EvalAI
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Deployment] Add submission clearing for EC2 (Cloud-CV#4183)
* [Deployment] Add submission clearing for EC2 * Update delete_old_submissions.py * Fix flake8 issues
- Loading branch information
1 parent
aeec2a5
commit 5cedd72
Showing
2 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
import shutil | ||
import time | ||
|
||
# Define the directory path | ||
tmp_directory = '/tmp' | ||
|
||
# Calculate the cutoff time (60 seconds ago) | ||
cutoff_time = time.time() - 60 # 60 seconds | ||
|
||
# List all directories in /tmp starting with 'tmp' | ||
tmp_folders = [d for d in os.listdir(tmp_directory) if os.path.isdir(os.path.join(tmp_directory, d)) and d.startswith('tmp')] | ||
|
||
for folder in tmp_folders: | ||
folder_path = os.path.join(tmp_directory, folder) | ||
|
||
# Check if the folder was created more than 60 seconds ago | ||
folder_creation_time = os.path.getctime(folder_path) | ||
if folder_creation_time < cutoff_time: | ||
shutil.rmtree(folder_path) | ||
print(f"Deleted folder: {folder_path}") | ||
else: | ||
print(f"Skipped folder: {folder_path} (created less than 60 seconds ago)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters