def get_project(name, db=None): # get a client if needed if db == None: db = core.atlas_db() core.check_count('projects', name, 1, db) # delete project return db.projects.find_one({'name': name})
def path(data, dataset): db = core.atlas_db() data_info = utils.get_data(data, dataset) dataset_info = utils.get_dataset(dataset) # not sure how to decide which dataset to pick datastore_info = util.get_datastore(dataset_info['datastore'][0]) return datastore_info['poth'] + dataset_info['path'] + data_info['path']
def get_datastore(name, db=None): # get a client if needed if db == None: db = core.atlas_db() # see if the project exists core.check_count('datastores', name, 1, db) # delete project return db.datastores.find_one({'name': name})
def get_data_unique(unique_name, db=None): # get a client if needed if db == None: db = core.atlas_db() # see if the project exists core.check_count('data', unique_name, 1, db, data=True) # delete project return db.data.find_one({'unique_name': unique_name})
def delete_dataset(name, db=None): # get a client if needed if db == None: db = core.atlas_db() # see if the project exists core.check_count('datasets', name, 1, db) # delete project db.datasets.delete_one({'name': name}) return True
def writing(data, data_object): # for now just save the data_info db = core.atlas_db() # check current count, just warn unique_name = core.make_unique_name(data['name'], data['dataset']) count = db[coll].count_documents({'unique_name': unique_name}) data['unique_name'] = unique_name db['data'].insert_one(data) # returns the path so you can use it return path(data, data['dataset'])
def create_datastore(path, db=None): if db == None: db = core.atlas_db() ds_data = core.load_yaml(path) if ds_data['type'] != 'datastore': print("Wrong type of data, expected 'datastore', got '" + ds_data['type'] + "'") return None # see if the project exists core.check_count('datastores', ds_data['name'], 0, db) # write the project data db.datastores.insert_one(ds_data) return "created datastore"
def create_data(path, db=None): if db == None: db = core.atlas_db() data = core.load_yaml(path) if data['type'] != 'data': print("Wrong type of data, expected 'data', got '" + data['type'] + "'") return None # see if the project exists unique_name = core.make_unique_name(data['name'], data['dataset']) core.check_count('datasets', unique_name, 0, db, data=True) data['unique_name'] = unique_name # write the project data db.data.insert_one(data) return "created data record"
def create_project(path, db=None, path_is_dir=False): if db == None: db = core.atlas_db() # create the path to the file, only look for YAML now if path_is_dir: project_file_path = path + core.ATLAS_DIR + core.PROJECT_FILE_YAML else: project_file_path = path project_data = core.load_yaml(project_file_path) if ds_data['type'] != 'project': print("Wrong type of data, expected 'datastore', got '" + ds_data['type'] + "'") return None core.check_count('projects', project_data['name'], 0, db) # write the project data db.projects.insert_one(project_data) return "created project"