Delete process_stuck.py
Browse files- process_stuck.py +0 -34
process_stuck.py
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import argparse
|
| 3 |
-
|
| 4 |
-
ap = argparse.ArgumentParser()
|
| 5 |
-
ap.add_argument("task_name")
|
| 6 |
-
ap.add_argument("task_config")
|
| 7 |
-
ap.add_argument("index", type=int, help="Index of the episode to delete")
|
| 8 |
-
args = ap.parse_args()
|
| 9 |
-
|
| 10 |
-
target_path = os.path.join("data", args.task_name, args.task_config)
|
| 11 |
-
txt_path = os.path.join(target_path, "seed.txt")
|
| 12 |
-
dir_path = os.path.join(target_path, "data")
|
| 13 |
-
replace_id = args.index
|
| 14 |
-
|
| 15 |
-
with open(txt_path, "r") as f:
|
| 16 |
-
nums = list(map(int, f.read().split()))
|
| 17 |
-
|
| 18 |
-
final_id = len(nums) - 1
|
| 19 |
-
|
| 20 |
-
last_seed = nums[-1]
|
| 21 |
-
|
| 22 |
-
nums[replace_id] = last_seed
|
| 23 |
-
nums.pop()
|
| 24 |
-
|
| 25 |
-
with open(txt_path, "w") as f:
|
| 26 |
-
f.write(" ".join(map(str, nums)))
|
| 27 |
-
|
| 28 |
-
target_file = os.path.join(dir_path, f"episode{replace_id}.pkl")
|
| 29 |
-
if os.path.exists(target_file):
|
| 30 |
-
os.remove(target_file)
|
| 31 |
-
|
| 32 |
-
last_file = os.path.join(dir_path, f"episode{final_id}.pkl")
|
| 33 |
-
if os.path.exists(last_file):
|
| 34 |
-
os.rename(last_file, target_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|