From fe3aa5af47b1cd69e589c52a32100edd768a8450 Mon Sep 17 00:00:00 2001 From: Ardi Mirzaei Date: Wed, 24 Jan 2024 06:28:34 +1100 Subject: [PATCH 1/3] Fix leaderboard not loading #219 Missing series load, and handling of nonetype for no forecasts. --- dash/common.py | 12 ++++++++---- dash/pages/leaderboard.py | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dash/common.py b/dash/common.py index 442b8bc..23edddb 100644 --- a/dash/common.py +++ b/dash/common.py @@ -694,10 +694,14 @@ def get_leaderboard_df(series_list, CV_score_function="MSE"): chosen_methods = [] for series_title, forecast_data in forecast_series_dicts.items(): - model_name = select_best_model( - forecast_data, CV_score_function=CV_score_function - ) - chosen_methods.append(model_name) + try: + model_name = select_best_model( + forecast_data, CV_score_function=CV_score_function + ) + chosen_methods.append(model_name) + except Exception as e: + print(f'{[series_title]} had the following error: {e}') # Usually missing forecasts + pass stats_raw = pd.DataFrame({"Method": chosen_methods}) diff --git a/dash/pages/leaderboard.py b/dash/pages/leaderboard.py index 128e15b..dcc39c2 100644 --- a/dash/pages/leaderboard.py +++ b/dash/pages/leaderboard.py @@ -79,6 +79,9 @@ def update_leaderboard_df(CV_score): construct the best model leaderboard based upon user selected scoring function """ # Build leaderboard with chosen CV scoring function + data_sources_json_file = open("../shared_config/data_sources.json") + series_list = json.load(data_sources_json_file) + counts = get_leaderboard_df(series_list, CV_score) win_proportion = ( From 7d3758b77cee1c0116ff1031e013e194f8060e6c Mon Sep 17 00:00:00 2001 From: ardimirzaei <45409241+ardimirzaei@users.noreply.github.com> Date: Wed, 24 Jan 2024 06:47:48 +1100 Subject: [PATCH 2/3] Update README.md fix errors in displaying badge shields --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fac3a5..1249a97 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/forecastlab/forecast_dash/Build%20and%20deploy%20Python%20app%20-%20staging-forecast-lab/staging?label=Build) ![BlackResults)](https://img.shields.io/github/workflow/status/forecastlab/forecast_dash/CI/master?label=Clean%20Code) ![Check Data Sources](https://img.shields.io/github/workflow/status/forecastlab/forecast_dash/Check%20Data%20Sources/staging?label=Data%20Sources) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/forecastlab/forecast_dash) ![GitHub contributors](https://img.shields.io/github/contributors/forecastlab/forecast_dash) +![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/forecastlab/forecast_dash/Docker_build_check.yml?branch=staging&label=Build) ![BlackResults)](https://img.shields.io/github/actions/workflow/status/forecastlab/forecast_dash/ci.yml?branch=staging&label=Clean%20Code) ![Check Data Sources](https://img.shields.io/github/actions/workflow/status/forecastlab/forecast_dash/datasources.yml?branch=staging&label=Data%20Sources) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/forecastlab/forecast_dash) ![GitHub contributors](https://img.shields.io/github/contributors/forecastlab/forecast_dash) # USYD Forecasting Lab From 268183e5eeb7579fba3d137c20bdcf0bac385e7c Mon Sep 17 00:00:00 2001 From: Ardi Mirzaei Date: Wed, 24 Jan 2024 06:54:01 +1100 Subject: [PATCH 3/3] black linting --- dash/common.py | 6 ++++-- dash/pages/home.py | 20 +++++++++++++++----- dash/pages/search.py | 4 +--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/dash/common.py b/dash/common.py index 23edddb..91fa67e 100644 --- a/dash/common.py +++ b/dash/common.py @@ -399,7 +399,7 @@ def select_best_model(data_dict, CV_score_function="MSE"): def get_thumbnail_figure(data_dict, lg=12): if data_dict == None: return {} - + watermark_config = ( watermark_information() ) # Grab the watermark text and fontsize information @@ -700,7 +700,9 @@ def get_leaderboard_df(series_list, CV_score_function="MSE"): ) chosen_methods.append(model_name) except Exception as e: - print(f'{[series_title]} had the following error: {e}') # Usually missing forecasts + print( + f"{[series_title]} had the following error: {e}" + ) # Usually missing forecasts pass stats_raw = pd.DataFrame({"Method": chosen_methods}) diff --git a/dash/pages/home.py b/dash/pages/home.py index cdc521b..b58d390 100644 --- a/dash/pages/home.py +++ b/dash/pages/home.py @@ -110,7 +110,8 @@ def _featured_latest_news(feature_series_title): dbc.Col( [ html.H2( - "US " + "inflation shows strong signs of stabilisation".title(), + "US " + + "inflation shows strong signs of stabilisation".title(), ), html.A( html.H4("View all US forecasts"), @@ -127,7 +128,9 @@ def _featured_latest_news(feature_series_title): [ dcc.Graph( figure=get_thumbnail_figure( - get_forecast_data("US Personal Consumption Expenditures: Chain-type Price Index (% Change, 1 Year)"), + get_forecast_data( + "US Personal Consumption Expenditures: Chain-type Price Index (% Change, 1 Year)" + ), lg=8, ), config={"displayModeBar": False}, @@ -223,7 +226,9 @@ def _uk_snapshot(): [ dcc.Graph( figure=get_thumbnail_figure( - get_forecast_data("UK Inflation (RPI)"), + get_forecast_data( + "UK Inflation (RPI)" + ), lg=8, ), config={"displayModeBar": False}, @@ -276,6 +281,7 @@ def _link_search(): ] ) + def _au_snapshot(): return [ dbc.Row( @@ -283,7 +289,9 @@ def _au_snapshot(): dbc.Col( [ html.H2( - "Have " + "AU" +" house prices reached the bottom?".title() + "Have " + + "AU" + + " house prices reached the bottom?".title() ), html.A( html.H4("View all Australian forecasts"), @@ -300,7 +308,9 @@ def _au_snapshot(): [ dcc.Graph( figure=get_thumbnail_figure( - get_forecast_data("Australian (Sydney) Change in House Prices"), + get_forecast_data( + "Australian (Sydney) Change in House Prices" + ), lg=8, ), config={"displayModeBar": False}, diff --git a/dash/pages/search.py b/dash/pages/search.py index e171689..7b4afde 100644 --- a/dash/pages/search.py +++ b/dash/pages/search.py @@ -391,9 +391,7 @@ def filter_results(**kwargs): for item_title in unique_series_titles[0:show_num]: try: - series_data = get_forecast_data( - item_title - ) + series_data = get_forecast_data(item_title) if series_data == None: raise FileNotFoundError