Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Update popularity refresh schedule and timeouts (#2819)
Staci Mullins7298b2973023
diff --git a/catalog/DAGs.md b/catalog/DAGs.mdindex 47bb18787..ca9201e24 100644--- a/catalog/DAGs.md+++ b/catalog/DAGs.md@@ -76,8 +76,8 @@ The following are DAGs grouped by their primary tag:| DAG ID | Schedule Interval || ------------------------------------------------------- | ----------------- |-| [`audio_popularity_refresh`](#audio_popularity_refresh) | `None` |-| [`image_popularity_refresh`](#image_popularity_refresh) | `None` |+| [`audio_popularity_refresh`](#audio_popularity_refresh) | `@monthly` |+| [`image_popularity_refresh`](#image_popularity_refresh) | `@monthly` |## Providerdiff --git a/catalog/dags/popularity/popularity_refresh_types.py b/catalog/dags/popularity/popularity_refresh_types.pyindex 7d946493c..76d3b4631 100644--- a/catalog/dags/popularity/popularity_refresh_types.py+++ b/catalog/dags/popularity/popularity_refresh_types.py@@ -47,14 +47,9 @@ class PopularityRefresh:media_type: strdefault_args: dict | None = field(default_factory=dict)start_date: datetime = datetime(2023, 1, 1)- # The default schedule is initially set to None while we assess the performance- # of refreshes. The schedule will be updated in- # https://github.com/WordPress/openverse/issues/2092- schedule: str | None = None- # Initial timeouts are generous; they should be updated after assessing the- # performance in https://github.com/WordPress/openverse/issues/2092- refresh_popularity_timeout: timedelta = timedelta(days=30)- refresh_popularity_batch_timeout: timedelta = timedelta(hours=1)+ schedule: str | None = "@monthly"+ refresh_popularity_timeout: timedelta = timedelta(days=14)+ refresh_popularity_batch_timeout: timedelta = timedelta(minutes=5)refresh_metrics_timeout: timedelta = timedelta(hours=1)poke_interval: int = REFRESH_POKE_INTERVAL@@ -71,5 +66,6 @@ POPULARITY_REFRESH_CONFIGS = [media_type="audio",# Poke every minute, instead of every thirty minutespoke_interval=int(os.getenv("DATA_REFRESH_POKE_INTERVAL", 60)),+ refresh_popularity_timeout=timedelta(days=1),),]diff --git a/catalog/tests/dags/common/popularity/test_dag_factory.py b/catalog/tests/dags/common/popularity/test_dag_factory.pyindex 3e1d9befc..ba173a24d 100644--- a/catalog/tests/dags/common/popularity/test_dag_factory.py+++ b/catalog/tests/dags/common/popularity/test_dag_factory.py@@ -1,3 +1,4 @@+from datetime import timedeltafrom unittest import mockimport pytest@@ -89,7 +90,12 @@ def test_get_providers_update_confs(providers, media_type, expected_confs):return_value=providers,):actual_confs = get_providers_update_confs.function(- POSTGRES_CONN_ID, PopularityRefresh(media_type=media_type), TEST_DAY+ POSTGRES_CONN_ID,+ PopularityRefresh(+ media_type=media_type,+ refresh_popularity_batch_timeout=timedelta(hours=1),+ ),+ TEST_DAY,)assert actual_confs == expected_confs