def getUserSimulations(user): mongoDB, connection = connect("Pleiades") result = mongoDB.jobs.find({"owner": user}) disconnect(connection) return result
def retrieve_from_id(oid): """ Gets a single result for a given id """ db, con = connect('results') result = db.entries.find_one( { '_id' : ObjectId(oid) } ) disconnect(con) return result
def getRunningSamplesCount(simulationID): mongoDB, connection = connect("Pleiades") regex = simulationID + "_.*" print regex running_samples = mongoDB.running.find({"task_id": re.compile(regex, re.IGNORECASE)}).count() disconnect(connection) return running_samples
def retrieve(query): """ Takes the search string, converts it to a mongo query and returns the results """ def entry(i): return { i[u'_id']: { 'Results: ' : '<a href="/cidb/download/' + str(i[u'_id']) + '/">Download</a>', 'Simulation' : i[u'data'] #TODO: add load code } } db, con = connect('results') results = db.entries.find(buildQuery(query, db.tags)) disconnect(con) return [ entry(i) for i in results ]
def getRunningSimulationsCount(simulationID): mongoDB, connection = connect("Pleiades") jobID = simulationID[:simulationID.rfind("_")] regex = jobID + "_.*" running_samples = mongoDB.running.find({"task_id": re.compile(regex, re.IGNORECASE)}) running_sims = [] for sample in running_samples: sim_id = sample["task_id"][:sample["task_id"].rfind("_")] if not sim_id in running_sims: running_sims.append(sim_id) disconnect(connection) return len(running_sims)
def getUserResultObjects(user): mongoDB, connection = connect("Pleiades") result = mongoDB.results.find({"owner": user}) disconnect(connection) return result