Skip to content

Commit

Permalink
cleanup script
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Zotti authored and Ryan Zotti committed Aug 14, 2016
1 parent e9749e4 commit 41f28dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
5 changes: 5 additions & 0 deletions cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from util import cleanup

cleanup_dir = '/Users/ryanzotti/Documents/repos/Self_Driving_RC_Car/tf_visual_data/runs/'
cleanup(cleanup_dir)
print("Cleanup completed successfully.")
5 changes: 4 additions & 1 deletion train_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,7 @@ def max_pool_2x2(x):
# Save the trained model to a file
saver = tf.train.Saver()
save_path = saver.save(sess, "/Users/ryanzotti/Documents/repos/Self-Driving-Car/trained_model/model.ckpt")
#print("validation accuracy %g" % accuracy.eval(feed_dict={x: validation_predictors, y_: validation_targets, keep_prob: 1.0}))
#print("validation accuracy %g" % accuracy.eval(feed_dict={x: validation_predictors, y_: validation_targets, keep_prob: 1.0}))

# Marks unambiguous successful completion to prevent deletion by cleanup script
shell_command('touch '+tfboard_run_dir+'/SUCCESS')
22 changes: 16 additions & 6 deletions util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess

from os import listdir
from os.path import isfile

def dir_count(dir):
shell_cmd = 'ls -ltr {dir} | wc -l'.format(dir=dir)
Expand All @@ -21,15 +22,24 @@ def mkdir_tfboard_run_dir(tf_basedir,):
mkdir(new_run_dir)
return new_run_dir


def cp(a,b):
shell_cmd = 'cp {from_here} {to_there}'.format(from_here=a,to_there=b)
cmd_result = subprocess.check_output(shell_cmd, shell=True).strip()

def shell_command(cmd):
cmd_result = subprocess.check_output(cmd, shell=True).strip()
return cmd_result


def cleanup(dir):
if 'tf_visual_data/runs/' in dir:
sub_dirs = listdir(dir)
for sub_dir in sub_dirs:
if sub_dir is not isfile(sub_dir):
files = listdir(dir+'/'+sub_dir)
if "SUCCESS" not in files:
shell_command('rm -rf ' + dir + sub_dir)
else:
pass # do not accidentally delete entire file system!


if __name__ == '__main__':
tensorboard_basedir = '/Users/ryanzotti/Documents/repos/Self_Driving_RC_Car/tf_visual_data/runs/'
cleanup(tensorboard_basedir)
mkdir_tfboard_run_dir(tensorboard_basedir)

0 comments on commit 41f28dd

Please sign in to comment.