Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Remove `trim_and_deduplicate_tags` DAG after successful run (no longer needed) (#4557)
sarayourfriend17e7f3d91460
diff --git a/catalog/dags/maintenance/trim_and_deduplicate_tags.py b/catalog/dags/maintenance/trim_and_deduplicate_tags.pydeleted file mode 100644index 87976298b..000000000--- a/catalog/dags/maintenance/trim_and_deduplicate_tags.py+++ /dev/null@@ -1,88 +0,0 @@-"""-See the issue for context and motivation: https://github.com/WordPress/openverse/issues/4199--This DAG triggers a run of the batched update DAG. It generates a new list of tags by-trimming all existing tags and re-inserting only the distinct tags of the resulting list of tags.-"""--from datetime import datetime, timedelta-from textwrap import dedent--from airflow.decorators import dag-from airflow.operators.trigger_dagrun import TriggerDagRunOperator--from common.constants import DAG_DEFAULT_ARGS, MEDIA_TYPES-from database.batched_update.constants import DAG_ID as BATCHED_UPDATE_DAG_ID---DAG_ID = "trim_and_deduplicate_tags"---@dag(- dag_id=DAG_ID,- schedule=None,- start_date=datetime(2024, 6, 3),- tags=["database"],- doc_md=__doc__,- max_active_runs=1,- default_args=DAG_DEFAULT_ARGS,-)-def trim_and_deduplicate_tags():- TriggerDagRunOperator.partial(- task_id=DAG_ID,- trigger_dag_id=BATCHED_UPDATE_DAG_ID,- wait_for_completion=True,- max_active_tis_per_dag=2,- map_index_template="""{{ task.conf['table_name'] }}""",- retries=0,- ).expand(- conf=[- {- "query_id": f"{DAG_ID}_{media_type}",- "table_name": media_type,- "select_query": (- "WHERE "- + (- ""- if media_type == "audio"- # We've identified these image providers in particular definitely have tags that need trimming, so we can narrow the query starting there at least- else (- "provider IN ('flickr', 'geographorguk', 'thingiverse', 'animaldiversity', 'clevelandmuseum', 'digitaltmuseum') AND "- )- )- + (- f"""EXISTS (SELECT 1 FROM jsonb_array_elements({media_type}.tags) AS t WHERE t->>'name' ILIKE ' %' OR t->>'name' ILIKE '% ')"""- )- ),- "update_query": (- "SET updated_on = NOW(), "- + dedent(- f"""- tags = (- SELECT- jsonb_agg(- jsonb_set(- deduped.tag,- '{{name}}',- to_jsonb(deduped.trimmed_name)- )- )- FROM (- SELECT DISTINCT ON (trimmed_name, tag->'provider')- trim(tag->>'name') trimmed_name,- tag- FROM jsonb_array_elements({media_type}.tags || '[]'::jsonb) tag- ) deduped- )- """- )- ),- "update_timeout": int(timedelta(hours=5).total_seconds()),- "dry_run": False,- }- for media_type in MEDIA_TYPES- ]- )---trim_and_deduplicate_tags()diff --git a/documentation/catalog/reference/DAGs.md b/documentation/catalog/reference/DAGs.mdindex 79545b547..009efd624 100644--- a/documentation/catalog/reference/DAGs.md+++ b/documentation/catalog/reference/DAGs.md@@ -55,7 +55,6 @@ The following are DAGs grouped by their primary tag:| [`recreate_image_popularity_calculation`](#recreate_media_type_popularity_calculation) | `None` || [`report_pending_reported_media`](#report_pending_reported_media) | `@weekly` || [`staging_database_restore`](#staging_database_restore) | `@monthly` |-| [`trim_and_deduplicate_tags`](#trim_and_deduplicate_tags) | `None` |### Elasticsearch@@ -177,7 +176,6 @@ The following is documentation associated with each DAG (where available):1. [`smk_workflow`](#smk_workflow)1. [`staging_database_restore`](#staging_database_restore)1. [`stocksnap_workflow`](#stocksnap_workflow)-1. [`trim_and_deduplicate_tags`](#trim_and_deduplicate_tags)1. [`wikimedia_commons_workflow`](#wikimedia_commons_workflow)1. [`wikimedia_reingestion_workflow`](#wikimedia_commons_workflow)1. [`wordpress_workflow`](#wordpress_workflow)@@ -1087,17 +1085,6 @@ authorization required. API is undocumented.-----### `trim_and_deduplicate_tags`--See the issue for context and motivation:-https://github.com/WordPress/openverse/issues/4199--This DAG triggers a run of the batched update DAG. It generates a new list of-tags by trimming all existing tags and re-inserting only the distinct tags of-the resulting list of tags.-------### `wikimedia_commons_workflow`**Content Provider:** Wikimedia Commons