Example #1
0
def read_failed_tasks(graph, file_name):
    tasks = pd.read_excel(file_name)
    for i in range(len(tasks)):
        sample_id = tasks.loc[i, 'sample_id']
        booth_id = tasks.loc[i, 'booth_id']
        station_name = tasks.loc[i, 'sta']
        loc_str = tasks.loc[i, 'loc']
        loc = loc_str[1:len(loc_str) - 1].split(',')
        loc = [float(i) for i in loc]
        day = tasks.loc[i, 'day']
        begin_time = int(tasks.loc[i, 'begin'] / 100)
        boro = tasks.loc[i, 'boro']
        routes_str = tasks.loc[i, 'routes']
        routes = routes_str.split(',')
        comments = tasks.loc[i, 'comments_for_checker']
        new_gate = Gate(name=station_name,
                        loc=loc,
                        day=day,
                        sample_id=sample_id,
                        begin_time=begin_time,
                        boro=boro,
                        routes=routes,
                        comments=comments,
                        booth_id=booth_id,
                        task_type=constants.TASK_TYPE[1])
        for g in graph:
            if g.day == day:
                daytype = constants.DAY.index(day)
                available_checkers = g.availability_book[daytype][
                    new_gate.begin_time]
                if available_checkers != 0:
                    new_gate.availability_priority_holder = 1 / available_checkers
                else:
                    new_gate.availability_priority_holder = 1
                if available_checkers == 1:
                    new_gate.availability_priority_holder = 2
                g.add_vertex(new_gate)
    for g in graph:
        g.normalize_distance_priority()
        g.normalize_availability_priority()