<commit_before>from time import time
from app import db
import argparse
from jobs import update_registry
from util import elapsed

# needs to be imported so the definitions get loaded into the registry
import jobs_defs


"""
examples of calling this:

# update everything
python update.py Package.test --limit 10 --chunk 5 --no-rq

# update one thing
python update.py Package.test --id cran:BioGeoBEARS  --no-rq

"""


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run stuff.")

    # for everything
    parser.add_argument('fn', type=str, help="what function you want to run")
    parser.add_argument('--rq', action="store_true", help="do jobs in this thread")

    # just for updating lots
    parser.add_argument('--limit', "-l", nargs="?", type=int, help="how many jobs to do")
    parser.add_argument('--chunk', "-ch", nargs="?", type=int, help="how many to take off db at once")

    # just for updating one
    parser.add_argument('--id', nargs="?", type=str, help="id of the one thing you want to update")

    # parse and run
    parsed = parser.parse_args()
    update = update_registry.get(parsed.fn)

    start = time()
    update.run(
        rq=parsed.rq,
        obj_id=parsed.id,  # is empty unless updating just one row
        num_jobs=parsed.limit,
        chunk_size=parsed.chunk
    )

    db.session.remove()
    print "finished update in {}sec".format(elapsed(start))<commit_msg>move from no_rq to rq, default is rq=False<commit_after>from time import time
from app import db
import argparse
from jobs import update_registry
from util import elapsed

# needs to be imported so the definitions get loaded into the registry
import jobs_defs


"""
examples of calling this:

# update everything
python update.py Package.test --limit 10 --chunk 5 --no-rq

# update one thing
python update.py Package.test --id cran:BioGeoBEARS  --no-rq

"""


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run stuff.")

    # for everything
    parser.add_argument('fn', type=str, help="what function you want to run")
    parser.add_argument('--rq', action="store_true", default=False, help="do jobs in this thread")

    # just for updating lots
    parser.add_argument('--limit', "-l", nargs="?", type=int, help="how many jobs to do")
    parser.add_argument('--chunk', "-ch", nargs="?", type=int, help="how many to take off db at once")

    # just for updating one
    parser.add_argument('--id', nargs="?", type=str, help="id of the one thing you want to update")

    # parse and run
    parsed = parser.parse_args()
    update = update_registry.get(parsed.fn)

    start = time()
    update.run(
        rq=parsed.rq,
        obj_id=parsed.id,  # is empty unless updating just one row
        num_jobs=parsed.limit,
        chunk_size=parsed.chunk
    )

    db.session.remove()
    print "finished update in {}sec".format(elapsed(start))
{'fraction_non_alphanumeric': 0.12164948453608247, 'fraction_numerical': 0.002061855670103093, 'mean_word_length': 3.471582181259601, 'pattern_counts': {'":': 2, '<': 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': '1907587', 'n_tokens_mistral': 901, 'n_tokens_neox': 872, 'n_words': 299}