Skip to content

MODE_INFERENCE errors on unexpected OSM route tags (xmas:train) #1124

@JGreenlee

Description

@JGreenlee

While resetting and re-running the pipeline for a staging user, MODE_INFERENCE failed due to:

2025-03-31T02:54:28.798-07:00 2025-03-31 09:54:28,798:DEBUG:139759875860288:unique_modes = {'TRAIN', 'XMAS:TRAIN'}
2025-03-31T02:54:28.799-07:00 2025-03-31 09:54:28,798:ERROR:139759875860288:unique_modes = {'TRAIN', 'XMAS:TRAIN'}, but we support only {'BUS', 'TRAIN', 'SUBWAY', 'TRAM', 'LIGHT_RAIL'}
2025-03-31T02:54:28.799-07:00 2025-03-31 09:54:28,799:ERROR:139759875860288:Error while inferring modes, timestamp is unchanged
2025-03-31T02:54:28.799-07:00 Traceback (most recent call last):
2025-03-31T02:54:28.799-07:00 File "/usr/src/app/emission/analysis/classification/inference/mode/rule_engine.py", line 24, in predict_mode
2025-03-31T02:54:28.799-07:00    mip.runPredictionPipeline(user_id, time_query)
2025-03-31T02:54:28.799-07:00 File "/usr/src/app/emission/analysis/classification/inference/mode/rule_engine.py", line 55, in runPredictionPipeline
2025-03-31T02:54:28.799-07:00.   self.predictedProb = self.predictModesStep()
2025-03-31T02:54:28.799-07:00 File "/usr/src/app/emission/analysis/classification/inference/mode/rule_engine.py", line 74, in predictModesStep
2025-03-31T02:54:28.799-07:00.   predictedProb.append(get_prediction(i, section_entry))
2025-03-31T02:54:28.799-07:00 File "/usr/src/app/emission/analysis/classification/inference/mode/rule_engine.py", line 113, in get_prediction
2025-03-31T02:54:28.799-07:00.   return get_motorized_prediction(i, section_entry)
2025-03-31T02:54:28.799-07:00 File "/usr/src/app/emission/analysis/classification/inference/mode/rule_engine.py", line 140, in get_motorized_prediction
2025-03-31T02:54:28.799-07:00.   predicted_transit_mode = _get_transit_prediction(i, section_entry)
2025-03-31T02:54:28.799-07:00 File "/usr/src/app/emission/analysis/classification/inference/mode/rule_engine.py", line 180, in _get_transit_prediction
2025-03-31T02:54:28.799-07:00.   collapsed_transit_mode = collapse_modes(section_entry, predicted_transit_modes)
2025-03-31T02:54:28.799-07:00.File "/usr/src/app/emission/analysis/classification/inference/mode/rule_engine.py", line 228, in collapse_modes
2025-03-31T02:54:28.799-07:00.   assert False
2025-03-31T02:54:28.799-07:00.AssertionError

Additional logs showed XMAS:TRAIN comes from a relation called "Holiday Train":

2025-03-31T02:54:28.765-07:00 2025-03-31 09:54:28,765:DEBUG:139759875860288:About to find matches in lists: [7287706, 9845465, 7287704, 7287705, 9833548, 9844350, 9844351, 9845476, 1056
2025-03-31T02:54:28.765-07:00 [2768041, 6088583, 9605484, 9605700, 12246240, 18087448, 18087450, 18393734, 18393735, 18393736, 18393737, 9604089, 9605482, 9605696, 9606121, 12246241, 18087449, 18087451, 18384359, 18393730, 18393731, 18393732, 18393733, 3441377, 8588026, 8589572, 9762426, 9762427, 9762428, 3441376, 8589500, 8589571, 9753196, 9760254, 9765612, 9765613, 9765614, 8589501, 8589502, 8589503, 8589504, 8589505, 9769085, 9769172, 9769173, 9769174, 9769175, 9769176, 13506047, 13506056, 13506047, 13506056]
2025-03-31T02:54:28.798-07:00 2025-03-31 09:54:28,798:DEBUG:139759875860288:matching routes = [(2768041, '6XX'), (6088583, '4XX'), (9605484, '1XX'), (9605700, '5XX'), (12246240, '6XX'), (18087448, '1XX'), (18087450, '1XX'), (18393734, 'Weekend Post-Game'), (18393735, 'Weekend Post-Game'), (18393736, 'Weekend Pre-Game'), (18393737, 'Weekend Pre-Game'), (9604089, '6XX'), (9605482, '1XX'), (9605696, '5XX'), (9606121, '4XX'), (12246241, '6XX'), (18087449, '1XX'), (18087451, '1XX'), (18384359, 'Holiday Train'), (18393730, 'Weekend Post-Game'), (18393731, 'Weekend Pre-Game'), (18393732, 'Weekend Post-Game'), (18393733, 'Weekend Pre-Game')]
2025-03-31T02:54:28.798-07:00 2025-03-31 09:54:28,798:DEBUG:139759875860288:len(start_routes) = 44, len(end_routes) = 52, len(rel_id_matches) = 23
2025-03-31T02:54:28.798-07:00 2025-03-31 09:54:28,798:DEBUG:139759875860288:Got predicted transit mode ['train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'train', 'xmas:train', 'train', 'train', 'train', 'train']
2025-03-31T02:54:28.798-07:00 2025-03-31 09:54:28,798:DEBUG:139759875860288:train_mapped_modes = ['TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'XMAS:TRAIN', 'TRAIN', 'TRAIN', 'TRAIN', 'TRAIN']
2025-03-31T02:54:28.798-07:00 2025-03-31 09:54:28,798:DEBUG:139759875860288:unique_modes = {'TRAIN', 'XMAS:TRAIN'}

And is ultimately due to the presence of a "route" tag of xmas:train on this relation: https://www.openstreetmap.org/relation/18384359

so basically, I took Caltrain not during the holiday season

So we looked up all routes that run between that start and stop. And one of those was the holiday train so we were able to collapse all the other types of trains (express, local, weekday, weekend) into one, but since this was flagged as xmas:train, it wasn't collapsed and broke our inference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions