Forked from
DM / dm-docs
261 commits behind, 293 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
experimentCollection.py 1.17 KiB
#!/usr/bin/env python
from dm.common.utility.loggingManager import LoggingManager
from dm.common.exceptions.invalidArgument import InvalidArgument
from dm.common.exceptions.objectAlreadyExists import ObjectAlreadyExists
from dm.common.exceptions.objectNotFound import ObjectNotFound
from dm.common.exceptions.dbError import DbError
from dmMongoCollection import DmMongoCollection
class ExperimentCollection(DmMongoCollection):
"""Class responsible for updating experiment collection in mongo db."""
UNIQUE_KEYS_LIST = [ 'name' ]
def __init__(self, dbClient):
DmMongoCollection.__init__(self, 'experiments', dbClient)
#######################################################################
# Testing
if __name__ == '__main__':
from dmMongoClient import DmMongoClient
mongo = DmMongoClient('dm')
experimentCollection = ExperimentCollection(mongo)
experimentInfo = {'name' : 'exp-001', 'owner' : 'sv'}
#print experimentCollection.add(experimentInfo)
print experimentCollection.updateByName(experimentInfo)
print experimentCollection.findByName('exp-001')
print experimentCollection.findByQueryDict({'experiment' : 'exp-001'}, {'owner' : 1})