def remove_dataset_to_project(project_id, file_name): """Remove dataset from project """ project_file_path = get_project_file_path(project_id) fp_lock = get_lock_path(project_id) with SQLiteLock(fp_lock, blocking=True, lock_name="active", project_id=project_id): # open the projects file with open(project_file_path, "r") as f_read: project_dict = json.load(f_read) # remove the path from the project file data_fn = project_dict["dataset_path"] del project_dict["dataset_path"] with open(project_file_path, "w") as f_write: json.dump(project_dict, f_write) # files to remove data_path = get_data_file_path(project_id, data_fn) pool_path = get_pool_path(project_id) labeled_path = get_labeled_path(project_id) os.remove(str(data_path)) os.remove(str(pool_path)) os.remove(str(labeled_path))
def read_pool(project_id): pool_fp = get_pool_path(project_id) try: with open(pool_fp, "r") as f: pool = json.load(f) pool = [int(x) for x in pool] except FileNotFoundError: pool = None return pool
def write_pool(project_id, pool): pool_fp = get_pool_path(project_id) with open(pool_fp, "w") as f: json.dump(pool, f)