Dash app dropdown order different on local vs. Heroku

19 views Asked by At

I built and maintain a data insights application for professional open water swimmers called Open Water Insights, which is a multipage Dash app. One of the pages is meant to simply show the results of a race chosen from a dropdown. I want the order of the races in the dropdown to appear with the most recent first, and I've gotten this to work just fine on my local with the following callback, where the custom_label() function just grabs a few data points from the results csv file and builds a user-friendly string to show as the label in the dropdown. All the csv files in the results directory are named starting with YYYY_MM_DD, so when race_choices list is created, they are in alphabetical and therefore chronological order:

@app.callback(Output('results-race-dropdown', 'options'),
              [Input('results-gender-picker', 'value')])
def list_races(gender_choice):
    results_path = 'app_data/' + gender_choice + '/results'
    race_choices = os.listdir(results_path)
    race_choices.reverse()

    return [{'label': custom_label('app_data/' + gender_choice + '/results/' + i, 'event', 'location', 'distance', 'date'), 'value': i} for i in race_choices]

When running the app locally, everything works as expected:

app running locally

However, once deployed to Heroku, the items in the list are completely out of order with no clear pattern of how they are ordered.

app running on heroku

It seems that when the results files are pushed to and saved on the Heroku server, they are not alphabetized (and therefore ordered chronologically). And additional weird thing is that on another page called Athlete Profiles, I have a dropdown with the names of all athletes, and that dropdown appears alphabetically on local and heroku with no issues.

Here is a link to my GitHub if that helps. Any advice here would be appreciated, thank you!

1

There are 1 answers

0
makomeyer On

Ah, this was simpler than I thought. I just added a method to sort the list in reverse order. Sorry for the simple question!