summaryrefslogtreecommitdiffstats
path: root/lib/utils.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-18 16:02:58 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-18 16:02:58 +0800
commit073f8d930c94a2209ddab12f2cd44f4ae05bbffd (patch)
treef1065351ffa067ca5cff8bdfc2a128905ddf48fc /lib/utils.py
parentfa2643cf811583b489209ca51e5ecade1cc1a080 (diff)
downloadtrainer-073f8d930c94a2209ddab12f2cd44f4ae05bbffd.tar.gz
trainer-073f8d930c94a2209ddab12f2cd44f4ae05bbffd.tar.xz
trainer-073f8d930c94a2209ddab12f2cd44f4ae05bbffd.zip
add status check to segment.py
Diffstat (limited to 'lib/utils.py')
-rw-r--r--lib/utils.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/utils.py b/lib/utils.py
index 9024c7e..447637a 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -1,5 +1,16 @@
import os
import json
+from myconfig import MyConfig
+
+
+config = MyConfig()
+
+#Exceptions
+class EpochError(Exception):
+ def __init__(self, value):
+ self.value = value
+ def __str__(self):
+ return repr(self.value)
#Utils
@@ -29,10 +40,24 @@ def store_status(outfile, obj):
return
def check_epoch(obj, passname):
- pass
+ epochname = passname + 'Epoch'
+ if not epochname in obj:
+ return False
+ object_epoch = int(obj[epochname])
+ config_epoch = int(config.getEpochs()[epochname])
+ if object_epoch > config_epoch:
+ raise EpochError('Un-excepted larger epoch en-countered.\n' + \
+ 'Please increace the epoch in myconfig.py\n' )
+
+ if object_epoch < config_epoch:
+ return False
+ if object_epoch == config_epoch:
+ return True
+ return None
def sign_epoch(obj, passname):
- pass
+ epochname = passname + 'Epoch'
+ obj[epochname] = config.getEpochs()[epochname]
#test case
if __name__ == '__main__':