def create_task(self, task_name=None, script=None, hyper_parameters=None, saved_result_keys=None, **kwargs):
if not isinstance(task_name, str):  <EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if not isinstance(script, str):  <EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if hyper_parameters is None:<EOL><INDENT>hyper_parameters = {}<EOL><DEDENT>if saved_result_keys is None:<EOL><INDENT>saved_result_keys = []<EOL><DEDENT>self._fill_project_info(kwargs)<EOL>kwargs.update({'<STR_LIT:time>': datetime.utcnow()})<EOL>kwargs.update({'<STR_LIT>': hyper_parameters})<EOL>kwargs.update({'<STR_LIT>': saved_result_keys})<EOL>_script = open(script, '<STR_LIT:rb>').read()<EOL>kwargs.update({'<STR_LIT:status>': '<STR_LIT>', '<STR_LIT>': _script, '<STR_LIT:result>': {}})<EOL>self.db.Task.insert_one(kwargs)<EOL>logging.info("<STR_LIT>".format(task_name, script))<EOL>
Uploads a task to the database, timestamp will be added automatically.

        Parameters
        -----------
        task_name : str
            The task name.
        script : str
            File name of the python script.
        hyper_parameters : dictionary
            The hyper parameters pass into the script.
        saved_result_keys : list of str
            The keys of the task results to keep in the database when the task finishes.
        kwargs : other parameters
            Users customized parameters such as description, version number.

        Examples
        -----------
        Uploads a task
        >>> db.create_task(task_name='mnist', script='example/tutorial_mnist_simple.py', description='simple tutorial')

        Finds and runs the latest task
        >>> db.run_top_task(sess=sess, sort=[("time", pymongo.DESCENDING)])
        >>> db.run_top_task(sess=sess, sort=[("time", -1)])

        Finds and runs the oldest task
        >>> db.run_top_task(sess=sess, sort=[("time", pymongo.ASCENDING)])
        >>> db.run_top_task(sess=sess, sort=[("time", 1)])