class_docstr: It is a MongoDB based manager that help you to manage data, network architecture, parameters and logging.
  
  Parameters
  -------------
  ip : str
      Localhost or IP address.
  port : int
      Port number.
  dbname : str
      Database name.
  username : str or None
      User name, set to None if you do not need authentication.
  password : str
      Password.
  project_name : str or None
      Experiment key for this entire project, similar with the repository name of Github.
  
  Attributes
  ------------
  ip, port, dbname and other input parameters : see above
      See above.
  project_name : str
      The given project name, if no given, set to the script name.
  db : mongodb client
      See ``pymongo.MongoClient``.
class_docstr_tok: ["It","is","a","MongoDB","based","manager","that","help","you","to","manage","data",",","network","architecture",",","parameters","and","logging",".","Parameters","--","--","--","--","--","--","-","ip",":","str","Localhost","or","IP","address",".","port",":","int","Port","number",".","dbname",":","str","Database","name",".","username",":","str","or","None","User","name",",","set","to","None","if","you","do","not","need","authentication",".","password",":","str","Password",".","project_name",":","str","or","None","Experiment","key","for","this","entire","project",",","similar","with","the","repository","name","of","Github",".","Attributes","--","--","--","--","--","--","ip",",","port",",","dbname","and","other","input","parameters",":","see","above","See","above",".","project_name",":","str","The","given","project","name",",","if","no","given",",","set","to","the","script","name",".","db",":","mongodb","client","See","``","pymongo.MongoClient","``","."]
docstr: Finds and runs a pending task.
  
  Parameters
  -----------
  task_name : str
      The task name.
  kwargs : other parameters
      Users customized parameters such as description, version number.
  
  Examples
  ---------
  Wait until all tasks finish in user's local console
  
  >>> while not db.check_unfinished_task():
  >>>     time.sleep(1)
  >>> print("all tasks finished")
  >>> sess = tf.InteractiveSession()
  >>> net = db.find_top_model(sess=sess, sort=[("test_accuracy", -1)])
  >>> print("the best accuracy {} is from model {}".format(net._test_accuracy, net._name))
  
  Returns
  --------
  boolean : True for success, False for fail.
docstr_tok: ["Finds","and","runs","a","pending","task",".","Parameters","--","--","--","--","--","-","task_name",":","str","The","task","name",".","kwargs",":","other","parameters","Users","customized","parameters","such","as","description",",","version","number",".","Examples","--","--","--","--","-","Wait","until","all","tasks","finish","in","user","'s","local","console",">",">",">","while","not","db.check_unfinished_task","(",")",":",">",">",">","time.sleep","(","1",")",">",">",">","print","(","``","all","tasks","finished","''",")",">",">",">","sess","=","tf.InteractiveSession","(",")",">",">",">","net","=","db.find_top_model","(","sess=sess",",","sort=","[","(","``","test_accuracy","''",",","-1",")","]",")",">",">",">","print","(","``","the","best","accuracy","{","}","is","from","model","{","}","''",".format","(","net._test_accuracy",",","net._name",")",")","Returns","--","--","--","--","boolean",":","True","for","success",",","False","for","fail","."]
code: def check_unfinished_task(self, task_name=None, **kwargs):
      """Finds and runs a pending task.
  
      Parameters
      -----------
      task_name : str
          The task name.
      kwargs : other parameters
          Users customized parameters such as description, version number.
  
      Examples
      ---------
      Wait until all tasks finish in user's local console
  
      >>> while not db.check_unfinished_task():
      >>>     time.sleep(1)
      >>> print("all tasks finished")
      >>> sess = tf.InteractiveSession()
      >>> net = db.find_top_model(sess=sess, sort=[("test_accuracy", -1)])
      >>> print("the best accuracy {} is from model {}".format(net._test_accuracy, net._name))
  
      Returns
      --------
      boolean : True for success, False for fail.
  
      """
  
      if not isinstance(task_name, str):  # is None:
          raise Exception("task_name should be string")
      self._fill_project_info(kwargs)
  
      kwargs.update(
          {"$or": [{"status": "pending"}, {"status": "running"}]}
      )
  
      # ## find task
      # task = self.db.Task.find_one(kwargs)
      task = self.db.Task.find(kwargs)
  
      task_id_list = task.distinct("_id")
      n_task = len(task_id_list)
  
      if n_task == 0:
          logging.info(
              "[Database] No unfinished task - task_name: {}".format(
                  task_name
              )
          )
          return False
      else:
          logging.info(
              "[Database] Find {} unfinished task - task_name: {}".format(
                  n_task, task_name
              )
          )
          return True
  
imports: import os
  import pickle
  import sys
  import time
  from datetime import datetime
  import numpy
  import tensorflow
  import gridfs
  import pymongo
  from tensorlayer import logging
  from tensorlayer.files import assign_weights, del_folder, exists_or_mkdir, load_hdf5_to_weights, save_weights_to_hdf5, static_graph2net
label_desc: Use image node_id 22 for calling the TensorHub obj's underlying member method code with example usage: obj.check_unfinished_task(task_name) and returns: False, True