def get(self): args = datasetsGetParser.parse_args() project_id = args.get('project_id') has_project_access, auth_message = project_auth(project_id) if not has_project_access: return auth_message datasets = db_access.get_datasets(project_id, include_preloaded=True) data_list = [] for d in datasets: dataset_data = { k: d[k] for k in [ 'title', 'file_name', 'id', 'description', 'info_url', 'tags', 'preloaded' ] } dataset_data['details'] = db_access.get_dataset_properties( project_id, d.get('id')) data_list.append(dataset_data) return jsonify({'status': 'success', 'datasets': data_list})
def get(self): args = preloadedDatasetsGetParser.parse_args() project_id = args.get('project_id') get_structure = args.get('get_structure') preloaded_datasets = db_access.get_preloaded_datasets(**args) selected_preloaded_dataset_ids = [] if project_id: selected_preloaded_datasets = db_access.get_project_preloaded_datasets( project_id) selected_preloaded_dataset_ids = [ d['id'] for d in selected_preloaded_datasets ] data_list = [] for d in preloaded_datasets: dataset_data = { k: d[k] for k in [ 'title', 'file_name', 'id', 'description', 'info_url', 'tags' ] } if dataset_data['id'] in selected_preloaded_dataset_ids: dataset_data['selected'] = True else: dataset_data['selected'] = False dataset_data['details'] = db_access.get_dataset_properties( project_id, d.get('id')) data_list.append(dataset_data) return jsonify({'status': 'success', 'datasets': data_list})
def get_dataset_sample(dataset_id, project_id, start=0, inc=100): end = start + inc # Upper bound excluded df = get_data(dataset_id=dataset_id, project_id=project_id) sample = map(list, df.iloc[start:end].values) result = db_access.get_dataset_properties(project_id, dataset_id) result['sample'] = sample return result
def save_dataset_properties(properties_result, dataset_id, project_id): properties = properties_result['result'] existing_dataset_properties = db_access.get_dataset_properties( project_id, dataset_id) if existing_dataset_properties: logger.info("Updating field property of dataset %s", dataset_id) dataset_properties = db_access.update_dataset_properties( project_id, dataset_id, **properties) else: logger.info("Inserting field property of dataset %s", dataset_id) dataset_properties = db_access.insert_dataset_properties( project_id, dataset_id, **properties) return {'desc': 'Done saving dataset properties', 'result': None}
def get_dataset_sample(dataset_id, project_id, start=0, inc=100): end = start + inc # Upper bound excluded df = get_data(dataset_id=dataset_id, project_id=project_id) #sample = map(list, df.iloc[start:end].values) sample = df.iloc[start:end].values.tolist() #print('get_dataset_sample') #print('df', df) #print('df.iloc[start:end].values', df.iloc[start:end].values) #print('sample', sample) result = db_access.get_dataset_properties(project_id, dataset_id) #result['sample'] = sample result['sample'] = sample return result
def get(self): args = datasetsGetParser.parse_args() project_id = args.get('project_id') has_project_access, auth_message = project_auth(project_id) if not has_project_access: return auth_message datasets = db_access.get_datasets(project_id, include_preloaded=True) data_list = [] for d in datasets: dataset_data = { k: d[k] for k in [ 'title', 'file_name', 'id', 'description', 'info_url', 'tags', 'preloaded' ]} dataset_data['details'] = db_access.get_dataset_properties(project_id, d.get('id')) data_list.append(dataset_data) return jsonify({'status': 'success', 'datasets': data_list})
def get(self): args = preloadedDatasetsGetParser.parse_args() project_id = args.get('project_id') get_structure = args.get('get_structure') preloaded_datasets = db_access.get_preloaded_datasets(**args) selected_preloaded_dataset_ids = [] if project_id: selected_preloaded_datasets = db_access.get_project_preloaded_datasets(project_id) selected_preloaded_dataset_ids = [ d['id'] for d in selected_preloaded_datasets ] data_list = [] for d in preloaded_datasets: dataset_data = { k: d[k] for k in [ 'title', 'file_name', 'id', 'description', 'info_url', 'tags' ]} if dataset_data['id'] in selected_preloaded_dataset_ids: dataset_data['selected'] = True else: dataset_data['selected'] = False dataset_data['details'] = db_access.get_dataset_properties(project_id, d.get('id')) data_list.append(dataset_data) return jsonify({'status': 'success', 'datasets': data_list})