<commit_before>import virtool.db.utils
import virtool.processes
import virtool.utils


async def register(db, process_type, file_size=None):
    process_id = await virtool.db.utils.get_new_id(db.processes)

    document = {
        "_id": process_id,
        "count": 0,
        "created_at": virtool.utils.timestamp(),
        "file_size": file_size,
        "progress": 0,
        "step": virtool.processes.FIRST_STEPS[process_type],
        "type": process_type
    }

    await db.processes.insert_one(document)

    return virtool.utils.base_processor(document)


async def update(db, process_id, count=None, progress=None, step=None, file_progress=None, file_size=None, errors=None):
    update_dict = dict()

    if count is not None:
        update_dict["count"] = count

    if progress is not None:
        update_dict["progress"] = progress

    if step:
        update_dict["step"] = step

    if file_progress:
        update_dict["file_progress"] = file_progress

    if file_size:
        update_dict["file_size"] = file_size

    if errors is not None:
        update_dict["errors"] = errors<commit_msg>Add resumable, context, and complete fields to process documents<commit_after>import virtool.db.utils
import virtool.processes
import virtool.utils


async def register(db, process_type, file_size=None):
    process_id = await virtool.db.utils.get_new_id(db.processes)

    document = {
        "_id": process_id,
        "complete": False,
        "count": 0,
        "created_at": virtool.utils.timestamp(),
        "file_size": file_size,
        "progress": 0,
        "resumable": False,
        "context": context or dict(),
        "step": virtool.processes.FIRST_STEPS[process_type],
        "type": process_type
    }

    await db.processes.insert_one(document)

    return virtool.utils.base_processor(document)


async def update(db, process_id, count=None, progress=None, step=None, file_progress=None, file_size=None, errors=None):
    update_dict = dict()

    if count is not None:
        update_dict["count"] = count

    if progress is not None:
        update_dict["progress"] = progress

    if step:
        update_dict["step"] = step

    if file_progress:
        update_dict["file_progress"] = file_progress

    if file_size:
        update_dict["file_size"] = file_size

    if errors is not None:
        update_dict["errors"] = errors
{'fraction_non_alphanumeric': 0.10831234256926953, 'fraction_numerical': 0.0016792611251049538, 'mean_word_length': 3.1157167530224523, 'pattern_counts': {'":': 17, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4899449', 'n_tokens_mistral': 752, 'n_tokens_neox': 723, 'n_words': 171}