Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Tweak Flickr time division settings, add logs (#1041)

Staci Mullins550ae4e3dc73
diff --git a/openverse_catalog/dags/providers/provider_api_scripts/flickr.py b/openverse_catalog/dags/providers/provider_api_scripts/flickr.py
index 74235295d..70cc4f5a1 100644
--- a/openverse_catalog/dags/providers/provider_api_scripts/flickr.py
+++ b/openverse_catalog/dags/providers/provider_api_scripts/flickr.py
@@ -55,9 +55,9 @@ class FlickrDataIngester(TimeDelineatedProviderDataIngester):
# we cap `max_records` artificially low to accommodate this.
max_unique_records = 4_000 # Actual maximum, above which we should raise an error
max_records = 3_000 # Attempt to break ingestion into time slices of this size
- division_threshold = 20_000
- min_divisions = 12
- max_divisions = 60
+ division_threshold = 10_000
+ min_divisions = 6
+ max_divisions = 12
# When we pull more records than the API reports, we don't want to raise an error
# and halt ingestion. Instead, this DAG adds its own separate handling to cut off
# ingestion when max_records is reached, and continue to the next time interval. See
diff --git a/openverse_catalog/dags/providers/provider_api_scripts/provider_data_ingester.py b/openverse_catalog/dags/providers/provider_api_scripts/provider_data_ingester.py
index c75a2e7c5..b7007ebb6 100644
--- a/openverse_catalog/dags/providers/provider_api_scripts/provider_data_ingester.py
+++ b/openverse_catalog/dags/providers/provider_api_scripts/provider_data_ingester.py
@@ -143,8 +143,9 @@ class ProviderDataIngester(ABC):
# Allow overriding the date with a %Y-%m-%d string from the dagrun conf.
date_override = conf.get("date")
if date_override and datetime.strptime(date_override, "%Y-%m-%d"):
- logger.info(f"Using date {date_override} from dagrun conf.")
self.date = date_override
+ if self.date:
+ logger.info(f"Using date {self.date}.")
# Used to skip over errors and continue ingestion. When enabled, errors
# are not reported until ingestion has completed.
diff --git a/openverse_catalog/dags/providers/provider_api_scripts/time_delineated_provider_data_ingester.py b/openverse_catalog/dags/providers/provider_api_scripts/time_delineated_provider_data_ingester.py
index be61e0fb7..9e54ee503 100644
--- a/openverse_catalog/dags/providers/provider_api_scripts/time_delineated_provider_data_ingester.py
+++ b/openverse_catalog/dags/providers/provider_api_scripts/time_delineated_provider_data_ingester.py
@@ -177,6 +177,11 @@ class TimeDelineatedProviderDataIngester(ProviderDataIngester):
if record_count < self.division_threshold
else self.max_divisions
)
+ logger.info(
+ f"Record count {record_count} is greater than maximum of"
+ f" {self.max_records}. Ingesting data in {num_divisions} slices for the"
+ f" hour starting at {start_hour}."
+ )
minute_slices = self._get_timestamp_query_params_list(
start_hour, end_hour, num_divisions
)