Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, base, surfix = '', freq = "daily", cacheline = 200, flushnow = 0):
self.base = base
self.surfix = surfix
self.freq = freq
pathtool.mkdir (base)
self.file = "%s/%s.log" % (self.base, self.surfix)
base_logger.__init__ (self, codecs.open (self.file, "a", "utf8"), cacheline, flushnow)
self.cv = multiprocessing.Condition (multiprocessing.RLock())
self.using = 0
self.numlog = 0
self.maintern ()
self.rotate_when = self.get_next_rotate (self.freq)
def __init__ (self, name, working_dir, lockpath = None, win32service = None):
self.name = name
self.working_dir = working_dir
self.lockpath = lockpath or working_dir
self.win32service = win32service
setproctitle (name)
pathtool.mkdir (working_dir)
if lockpath:
pathtool.mkdir (lockpath)
os.chdir (working_dir)
def export (self, path, predict_def, inputs, outputs):
if self.name:
path = os.path.join (path, self.name.strip ())
pathtool.mkdir (path)
version = self.get_latest (path) + 1
with self.graph.as_default ():
#tf.app.flags.DEFINE_integer('model_version', version, 'version number of the model.')
#tf.app.flags.DEFINE_string('work_dir', '/tmp', 'Working directory.')
#FLAGS = tf.app.flags.FLAGS
builder = tf.saved_model.builder.SavedModelBuilder("{}/{}/".format (path, version))
prediction_signature = (
tf.saved_model.signature_def_utils.build_signature_def(
inputs=dict ([(k, tf.saved_model.utils.build_tensor_info (v)) for k,v in inputs.items ()]),
outputs=dict ([(k, tf.saved_model.utils.build_tensor_info (v)) for k,v in outputs.items ()]),
method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME))
builder.add_meta_graph_and_variables(
self.sess, [tf.saved_model.tag_constants.SERVING],
def save (self, path, filename = None):
if self.name:
path = os.path.join (path, self.name.strip ())
pathtool.mkdir (path)
if filename:
path = os.path.join (path, filename)
with self.graph.as_default ():
self.saver.save(self.sess, path, global_step = self.global_step)
def __init__ (self, logpath, varpath, consol):
self.logpath = logpath
self.varpath = varpath
self.consol = consol
self.last_maintern = 0
self.flock = None
self.shutdown_in_progress = False
logpath and pathtool.mkdir (logpath)
varpath and pathtool.mkdir (varpath)
if not self.consol: # service mode
sys.stderr = open (os.path.join (varpath, "stderr.log"), "a")
self.make_logger ()
self.setup ()
def make_service (service_class, logpath, varpath, consol, *args, **kargs):
pathtool.mkdir (varpath)
if logpath:
pathtool.mkdir (logpath)
return service_class (logpath, varpath, consol, *args, **kargs)
def __init__ (self, logpath, varpath, consol):
self.logpath = logpath
self.varpath = varpath
self.consol = consol
self.last_maintern = 0
self.flock = None
self.shutdown_in_progress = False
logpath and pathtool.mkdir (logpath)
varpath and pathtool.mkdir (varpath)
if not self.consol: # service mode
sys.stderr = open (os.path.join (varpath, "stderr.log"), "a")
self.make_logger ()
self.setup ()
def __init__ (self, name, working_dir, lockpath = None, win32service = None):
self.name = name
self.working_dir = working_dir
self.lockpath = lockpath or working_dir
self.win32service = win32service
setproctitle (name)
pathtool.mkdir (working_dir)
if lockpath:
pathtool.mkdir (lockpath)
os.chdir (working_dir)
def make_service (service_class, logpath, varpath, consol, *args, **kargs):
pathtool.mkdir (varpath)
if logpath:
pathtool.mkdir (logpath)
return service_class (logpath, varpath, consol, *args, **kargs)