Skip to content

Commit ee9e134

Browse files
committed
moving instructions to executed_instructions
1 parent f827068 commit ee9e134

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

trainer/src/trainer.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import copy
3030
import traceback
3131
import multiprocessing
32+
import shutil
3233

3334
import numpy as np
3435
import torch
@@ -148,18 +149,20 @@ def fix_config_paths(self, old_config):
148149
new_config[k] = v
149150
return new_config
150151

152+
153+
151154
def check_for_instructions(self):
155+
executed_dir = os.path.join(self.sync_dir, 'executed_instructions')
156+
os.makedirs(executed_dir, exist_ok=True)
152157
try:
153158
for fname in ls(self.instruction_dir):
154159
fpath = os.path.join(self.instruction_dir, fname)
155160
if not os.path.exists(fpath):
156-
continue # File was deleted (or incomplete), skip
161+
continue # File was deleted or incomplete, skip
157162
if self.execute_instruction(fname):
158-
instruction_path = os.path.join(self.instruction_dir, fname)
159163
if self.instruction_deleted_hook:
160-
self.instruction_deleted_hook(instruction_path)
161-
os.remove(instruction_path)
162-
164+
self.instruction_deleted_hook(fpath)
165+
shutil.move(fpath, os.path.join(executed_dir, fname))
163166

164167
except Exception as e:
165168
print('Exception checking for instruction', e)

0 commit comments

Comments
 (0)