args = parser.parse_args()
    fn = args.timeline_filename
    logging.info("Loading file or prefix %s" % fn)
    sel_file_list = common.read_files_with_prefix(fn)

    ts_db = edb.get_timeseries_db()
    ats_db = edb.get_analysis_timeseries_db()
    udb = edb.get_uuid_db()
    psdb = edb.get_pipeline_state_db()
    db_array = [ts_db, ats_db, udb, psdb]

    for i, filename in enumerate(sel_file_list):
        if "pipelinestate" in filename:
            continue

        logging.info("=" * 50)
        logging.info("Deleting data from file %s" % filename)

        entries = json.load(gzip.open(filename), object_hook = bju.object_hook)

        # Obtain uuid and rerun information from entries
        curr_uuid_list, needs_rerun = common.analyse_timeline(entries)
        if len(curr_uuid_list) > 1:
            logging.warning("Found %d users, %s in filename, aborting! " % 
                (len(curr_uuid_list), curr_uuid_list))
            raise RuntimeException("Found %d users, %s in filename, expecting 1, %s" %
                (len(curr_uuid_list), curr_uuid_list, common.split_user_id(filename)))
        curr_uuid = curr_uuid_list[0]
        if not args.info_only:
            common.purge_entries_for_user(curr_uuid, args.pipeline_purge, db_array)
Exemplo n.º 2
0
        if "pipelinestate" in filename:
            continue
        logging.info("=" * 50)
        logging.info("Loading data from file %s" % filename)

        entries = json.load(gzip.open(filename), object_hook=bju.object_hook)

        # Obtain uuid and rerun information from entries
        curr_uuid_list, needs_rerun = common.analyse_timeline(entries)
        if len(curr_uuid_list) > 1:
            logging.warning("Found %d users, %s in filename, aborting! " %
                            (len(curr_uuid_list), curr_uuid_list))
            raise RuntimeException(
                "Found %d users, %s in filename, expecting 1, %s" %
                (len(curr_uuid_list), curr_uuid_list,
                 common.split_user_id(filename)))
        curr_uuid = curr_uuid_list[0]
        all_user_list.append(curr_uuid)
        all_rerun_list.append(needs_rerun)

        load_ranges = get_load_ranges(entries)
        if not args.info_only:
            ts = esta.TimeSeries.get_time_series(curr_uuid)
            for j, curr_range in enumerate(load_ranges):
                if args.verbose is not None and j % args.verbose == 0:
                    logging.info("About to load range %s -> %s" %
                                 (curr_range[0], curr_range[1]))
                wrapped_entries = [
                    ecwe.Entry(e) for e in entries[curr_range[0]:curr_range[1]]
                ]
                for entry in wrapped_entries:
    ts_db = edb.get_timeseries_db()
    ats_db = edb.get_analysis_timeseries_db()
    udb = edb.get_uuid_db()

    for i, filename in enumerate(sel_file_list):
        logging.info("=" * 50)
        logging.info("Deleting data from file %s" % filename)

        entries = json.load(gzip.open(filename), object_hook = bju.object_hook)

        # Obtain uuid and rerun information from entries
        curr_uuid_list, needs_rerun = common.analyse_timeline(entries)
        if len(curr_uuid_list) > 1:
            logging.warning("Found %d users, %s in filename, aborting! " % 
                (len(curr_uuid_list), curr_uuid_list))
            raise RuntimeException("Found %d users, %s in filename, expecting 1, %s" %
                (len(curr_uuid_list), curr_uuid_list, common.split_user_id(filename)))
        curr_uuid = curr_uuid_list[0]
        if not args.info_only:
            logging.info("For uuid = %s, deleting entries from the timeseries" % curr_uuid)
            timeseries_del_result = ts_db.remove({"user_id": curr_uuid})
            logging.info("result = %s" % timeseries_del_result)

            logging.info("For uuid = %s, deleting entries from the analysis_timeseries" % curr_uuid)
            analysis_timeseries_del_result = ats_db.remove({"user_id": curr_uuid})
            logging.info("result = %s" % analysis_timeseries_del_result)

            logging.info("For uuid %s, deleting entries from the user_db" % curr_uuid)
            user_db_del_result = udb.remove({"uuid": curr_uuid})
            logging.info("result = %s" % user_db_del_result)