In [68]:
import os
import sys
import subprocess
In [38]:
os.getcwd()
Out[38]:
In [26]:
subprocess.Popen('ls', shell=True, stdout=subprocess.PIPE).stdout.read()
Out[26]:
In [29]:
p = subprocess.Popen('ls', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
for line in p.readlines():
print(line)
In [37]:
!git rev-parse --short HEAD
In [61]:
weight_dir = "../data_out3/"
file_name = "weights_fake"
commit = !git rev-parse --short HEAD
In [62]:
newfile = os.path.join(weight_dir, file_name + "_" + commit[0])
In [63]:
newfile
Out[63]:
In [67]:
"keras" in !git status --porcelain
In [72]:
this_script = os.path.split(sys.argv[0])[1]
In [73]:
!git diff --quiet this_script
In [75]:
p = subprocess.Popen('git status', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
for line in p.readlines():
print(line)
In [ ]:
import os, sys, subprocess
this_script = os.path.split(sys.argv[0])[1]
cmd = ['git diff --quiet', this_script]
changed = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
#changed = subprocess.Popen('git diff --quiet cdiscount_model_49_classes.py', shell=True, stdout=subprocess.PIPE)
wait = changed.communicate()[0]
if changed.returncode:
print("Updates to", this_script, "need to be git committed before running. Exiting...")
sys.exit()
else:
weight_dir = "../data_out3/Xception_weights"
file_name = "Xception49_Epoch{epoch:02d}-ValAcc{val_acc:.3f}"
commit = subprocess.Popen('git rev-parse --short HEAD', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')[:-1]
newfile = os.path.join(weight_dir, file_name + '_' + commit + '.hdf5')
print("Weights will be saved to:\n", " ", newfile)