from helpers import pymongo_worker_threads as workers
import aggregate_calculate as agr
import pymongo
import sys

client = pymongo.MongoClient(host="da0.eecs.utk.edu")

# MB:

# Take command line arguments
src = sys.argv[1]
multiplier = int(sys.argv[2])
name = sys.argv[3]
wait_to_join = False
if sys.argv[4].lower() == 'true': wait_to_join = True

source = client['ossfinder'][src]
target = client['ossfinder']['rel_aggregate2']

# Call the module function with the correct params named
workers.do_work(source_collection=source,
                worker_function=agr.aggregate_calculate,
                find_args={},
                worker_args={
                    'target': target,
                    'multiplier': multiplier,
                    'name': name
                },
                wait_to_join=wait_to_join)
Ejemplo n.º 2
0
                        relationships.update_one({'_id': rel['_id']},
                                                 {"$inc": {
                                                     "watchers": 1
                                                 }})
                    #if the relationship doesn't exist, create it
                    else:
                        rel = {
                            'repo_a': watchers[user][i],
                            'repo_b': watchers[user][j],
                            'watchers': 1
                        }
                        out = str(['C', watchers[user][i], watchers[user][j]])
                        print(out)
                        output.write(out)
                        relationships.save(rel)


worker_args = {
    'relationships': relationships,
    'users': users,
    'output': output
}

# Call the module function with the correct params named
workers.do_work(source_collection=watchers,
                worker_function=worker_function,
                find_args={},
                worker_args=worker_args,
                num_docs_per_thread=10000,
                wait_to_join=False)
Ejemplo n.º 3
0
    output.write(info)
    n_inserted = 0
    for doc in chunk:
        full_name = doc['owner'] + '/' + doc['repo']
        if full_name in repo_full_names:
            doc['full_name'] = full_name
            target.insert(doc)
            n_inserted += 1

    info = str(['watchers', n_inserted])
    print(info)
    output.write(info)


# These are the arguments that have to get passed into worker_function
# by the do_work function. These are the fork and knife that you put in
# your lunch box.
worker_args = {
    'target': target,
    'repo_full_names': repo_full_names,
    'output': output
}

# Finally we call the do_work function, passing in all of the named arguments that we defined above.
# Note, that when passing worker_args = worker_args, the second worker_args refers to the variable
# defined above.
workers.do_work(source_collection=source,
                worker_function=worker_function,
                worker_args=worker_args,
                num_docs_per_thread=10000)