Skip to content

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

πŸ”„ Synced file(s) with WordPress/openverse (#921)

Openverse (Bot)3979fc27b269
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 980cda441..cffdd1d81 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -6,28 +6,35 @@ title: "<Replace this with actual title>"
---
## Description
+
<!-- Concisely describe the bug. Compare your experience with what you expected to happen. -->
<!-- For example: "I clicked the 'submit' button and instead of seeing a thank you message, I saw a blank page." -->
## Reproduction
+
<!-- Provide detailed steps to reproduce the bug. -->
+
1. <!-- Step 1 ... -->
2. <!-- Step 2 ... -->
3. <!-- Step 3 ... -->
4. See error.
## Screenshots
+
<!-- Add screenshots to show the problem; or delete the section entirely. -->
## Environment
+
<!-- Please complete this, unless you are certain the problem is not environment specific. -->
- - Device: <!-- (_eg._ iPhone Xs; laptop) -->
- - OS: <!-- (_eg._ iOS 13.5; Fedora 32) -->
- - Browser: <!-- (_eg._ Safari; Firefox) -->
- - Version: <!-- (_eg._ 13; 73) -->
- - Other info: <!-- (_eg._ display resolution, ease-of-access settings) -->
+
+- Device: <!-- (_eg._ iPhone Xs; laptop) -->
+- OS: <!-- (_eg._ iOS 13.5; Fedora 32) -->
+- Browser: <!-- (_eg._ Safari; Firefox) -->
+- Version: <!-- (_eg._ 13; 73) -->
+- Other info: <!-- (_eg._ display resolution, ease-of-access settings) -->
## Additional context
+
<!-- Add any other context about the problem here; or delete the section entirely. -->
<!-- If you would like to work on this, please comment below separately. -->
diff --git a/.github/ISSUE_TEMPLATE/code_quality.md b/.github/ISSUE_TEMPLATE/code_quality.md
index 1d2cc9ef5..968b32f67 100644
--- a/.github/ISSUE_TEMPLATE/code_quality.md
+++ b/.github/ISSUE_TEMPLATE/code_quality.md
@@ -6,17 +6,23 @@ title: "<Replace this with the actual title>"
---
## Current Situation
+
<!-- Describe the part of the code you think should improve -->
## Suggested Improvement
+
<!-- Describe your proposed change -->
## Benefit
+
<!-- Describe the benefit of the change (E.g., increase test coverage, reduce running time, etc.) -->
## Additional context
+
<!-- Add any other context suggestion here. -->
## Implementation
+
<!-- Replace the [ ] with [x] to check the box. -->
+
- [ ] πŸ™‹ I would be interested in implementing this feature.
diff --git a/.github/ISSUE_TEMPLATE/discussion.md b/.github/ISSUE_TEMPLATE/discussion.md
index 79344d2c4..ca91bba13 100644
--- a/.github/ISSUE_TEMPLATE/discussion.md
+++ b/.github/ISSUE_TEMPLATE/discussion.md
@@ -6,13 +6,16 @@ title: "<Replace this with actual title>"
---
<!-- Consider how soon we need the discussion resolved vs. giving everyone an opportunity to participate. -->
+
## Due date: yyyy-mm-dd
<!-- Suggest two members of @WordPress/openverse to review the discussion. -->
+
## Assigned reviewers
- [ ] TBD
- [ ] TBD
<!-- Start the conversation. Please @ anyone relevant and try to ask questions to help facilate discussion. -->
+
## Description
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 0acab425c..ab7047947 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -6,15 +6,19 @@ title: "<Replace this with actual title>"
---
## Problem
+
<!-- Describe a problem solved by this feature; or delete the section entirely. -->
## Description
+
<!-- Describe the feature and how it solves the problem. -->
## Alternatives
+
<!-- Describe any alternative solutions or features you have considered. How is this feature better? -->
## Additional context
+
<!-- Add any other context about the feature here; or delete the section entirely. -->
<!-- If you would like to work on this, please comment below separately. -->
diff --git a/.github/ISSUE_TEMPLATE/infrastructure_improvement.md b/.github/ISSUE_TEMPLATE/infrastructure_improvement.md
index 3df751580..d8ba11331 100644
--- a/.github/ISSUE_TEMPLATE/infrastructure_improvement.md
+++ b/.github/ISSUE_TEMPLATE/infrastructure_improvement.md
@@ -6,20 +6,27 @@ title: "<Replace this with the actual title>"
---
## Current Situation
+
<!-- Describe the part of the infrastructure you think should improve -->
## Suggested Improvement
+
<!-- Describe what you want to happen -->
## Benefit
+
<!-- Fully describe the benefit of the change (E.g., improve speed, robustness, etc.) -->
## Alternatives
+
<!-- Describe any alternative solutions you have considered -->
## Additional context
+
<!-- Add any other context about the feature request. -->
## Implementation
+
<!-- Replace the [ ] with [x] to check the box. -->
+
- [ ] πŸ™‹ I would be interested in implementing this feature.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index accf40a74..dc5a5773b 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,28 +1,39 @@
## Fixes
+
<!-- If PR doesn't fully resolve the issue, replace 'Fixes' below with 'Related to'. -->
<!-- If there is no issue being resolved, please consider opening one before creating this pull request. -->
+
Fixes #[issue number] by @[issue author]
## Description
+
<!-- Concisely describe what the pull request does. -->
<!-- Add screenshots, videos, or other media to show the problem and the solution when appropriate. -->
## Testing Instructions
+
<!-- Give steps for the reviewer to verify that this PR fixes the problem; or delete this section entirely. -->
## Checklist
+
<!-- Replace the [ ] with [x] to check the boxes. -->
-- [ ] My pull request has a descriptive title (not a vague title like `Update index.md`).
-- [ ] My pull request targets the *default* branch of the repository (`main`) or a parent feature branch.
+
+- [ ] My pull request has a descriptive title (not a vague title like
+ `Update index.md`).
+- [ ] My pull request targets the _default_ branch of the repository (`main`) or
+ a parent feature branch.
- [ ] My commit messages follow [best practices][best_practices].
- [ ] My code follows the established code style of the repository.
- [ ] I added or updated tests for the changes I made (if applicable).
- [ ] I added or updated documentation (if applicable).
-- [ ] I tried running the project locally and verified that there are no visible errors.
+- [ ] I tried running the project locally and verified that there are no visible
+ errors.
-[best_practices]:https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines
+[best_practices]:
+ https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines
## Developer Certificate of Origin
+
<!-- You must read and understand the following attestation. -->
<details>
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 0dab1766e..9910a36d7 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -27,6 +27,8 @@ jobs:
uses: actions/checkout@v3
- uses: extractions/setup-just@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Python version
id: python-version
@@ -56,6 +58,8 @@ jobs:
uses: actions/checkout@v3
- uses: extractions/setup-just@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Python version
id: python-version
@@ -98,6 +102,28 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Get Python version
+ id: python-version
+ run: echo "value=$(just py-version)" >> "$GITHUB_OUTPUT"
+
+ - name: Setup Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: "${{ steps.python-version.outputs.value }}"
+
+ - name: Cache pre-commit envs
+ uses: actions/cache@v3
+ with:
+ path: ~/.cache/pre-commit
+ key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
+
+ - name: Install pre-commit
+ # This is required for the DAG doc check step only. If that step gets split out,
+ # this and the above steps setting up python are not needed for tests.
+ run: pip install pre-commit
- name: Change permissions for Docker steps
run: chmod -R 777 openverse_catalog/ tests/
diff --git a/.github/workflows/pr_label_check.yml b/.github/workflows/pr_label_check.yml
index 4eaf6808f..d8dd7c16d 100644
--- a/.github/workflows/pr_label_check.yml
+++ b/.github/workflows/pr_label_check.yml
@@ -13,24 +13,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check aspect label
- uses: agilepathway/[email protected]
+ uses: docker://agilepathway/pull-request-label-checker:v1.2.9
with:
one_of: "πŸ’» aspect: code,πŸ“„ aspect: text,πŸ€– aspect: dx,πŸ•Ή aspect: interface,♿️ aspect: a11y"
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
check_goal_label:
name: Check goal label
runs-on: ubuntu-latest
steps:
- name: Check goal label
- uses: agilepathway/[email protected]
+ uses: docker://agilepathway/pull-request-label-checker:v1.2.9
with:
one_of: "🌟 goal: addition,πŸ›  goal: fix,✨ goal: improvement,🧰 goal: internal improvement"
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
check_priority_label:
name: Check priority label
runs-on: ubuntu-latest
steps:
- name: Check priority label
- uses: agilepathway/[email protected]
+ uses: docker://agilepathway/pull-request-label-checker:v1.2.9
with:
one_of: "🟩 priority: low,🟨 priority: medium,🟧 priority: high,πŸŸ₯ priority: critical"
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4ba3de21b..89540ab63 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -67,7 +67,6 @@ repos:
rev: v2.6.0
hooks:
- id: prettier
- exclude: \.md$ # TODO: https://github.com/WordPress/openverse/issues/333
additional_dependencies:
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 5a77323cc..d68c1b7de 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -1,11 +1,25 @@
-This project comes under the WordPress [Etiquette](https://wordpress.org/about/etiquette/):
+This project comes under the WordPress
+[Etiquette](https://wordpress.org/about/etiquette/):
-In the WordPress open source project, we realize that our biggest asset is the community that we foster. The project, as a whole, follows these basic philosophical principles from The Cathedral and The Bazaar.
+In the WordPress open source project, we realize that our biggest asset is the
+community that we foster. The project, as a whole, follows these basic
+philosophical principles from The Cathedral and The Bazaar.
-- Contributions to the WordPress open source project are for the benefit of the WordPress community as a whole, not specific businesses or individuals. All actions taken as a contributor should be made with the best interests of the community in mind.
-- Participation in the WordPress open source project is open to all who wish to join, regardless of ability, skill, financial status, or any other criteria.
-- The WordPress open source project is a volunteer-run community. Even in cases where contributors are sponsored by companies, that time is donated for the benefit of the entire open source community.
-- Any member of the community can donate their time and contribute to the project in any form including design, code, documentation, community building, etc. For more information, go to make.wordpress.org.
-- The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included, by keeping communication free of discrimination, incitement to violence, promotion of hate, and unwelcoming behavior.
+- Contributions to the WordPress open source project are for the benefit of the
+ WordPress community as a whole, not specific businesses or individuals. All
+ actions taken as a contributor should be made with the best interests of the
+ community in mind.
+- Participation in the WordPress open source project is open to all who wish to
+ join, regardless of ability, skill, financial status, or any other criteria.
+- The WordPress open source project is a volunteer-run community. Even in cases
+ where contributors are sponsored by companies, that time is donated for the
+ benefit of the entire open source community.
+- Any member of the community can donate their time and contribute to the
+ project in any form including design, code, documentation, community building,
+ etc. For more information, go to make.wordpress.org.
+- The WordPress open source community cares about diversity. We strive to
+ maintain a welcoming environment where everyone can feel included, by keeping
+ communication free of discrimination, incitement to violence, promotion of
+ hate, and unwelcoming behavior.
The team involved will block any user who causes any breach in this.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f4a8aa844..533ebe6a9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,23 +1,25 @@
# Contributing to Openverse
-Thank you for your interest in contributing to Openverse! This document is
-a set of guidelines to help you contribute to this project.
+Thank you for your interest in contributing to Openverse! This document is a set
+of guidelines to help you contribute to this project.
-Please refer to [CONTRIBUTING.md](https://github.com/WordPress/openverse/blob/main/CONTRIBUTING.md) for a
-detailed understanding of the contribution guidelines.
+Please refer to
+[CONTRIBUTING.md](https://github.com/WordPress/openverse/blob/main/CONTRIBUTING.md)
+for a detailed understanding of the contribution guidelines.
## Code of Conduct
-By participating in this project, you are expected to uphold our [Code of
-Conduct](./CODE_OF_CONDUCT.md).
+By participating in this project, you are expected to uphold our
+[Code of Conduct](./CODE_OF_CONDUCT.md).
## Project Documentation
-The [README](./README.md) in the root of the repository should contain or link to
-project documentation. If you cannot find the documentation you're
-looking for, please file a GitHub issue with details of what
-you'd like to see documented.
+The [README](./README.md) in the root of the repository should contain or link
+to project documentation. If you cannot find the documentation you're looking
+for, please file a GitHub issue with details of what you'd like to see
+documented.
## Questions or Thoughts?
-Feel free to [join us on Slack](https://make.wordpress.org/chat/) and discuss the project with the engineers and community members on #openverse.
+Feel free to [join us on Slack](https://make.wordpress.org/chat/) and discuss
+the project with the engineers and community members on #openverse.
diff --git a/DAGs.md b/DAGs.md
index 60b4b3e99..a85f366e3 100644
--- a/DAGs.md
+++ b/DAGs.md
@@ -2,349 +2,307 @@
_Note: this document is auto-generated and should not be manually edited_
-This document describes the DAGs available along with pertinent DAG information and
-the DAG's documentation.
+This document describes the DAGs available along with pertinent DAG information
+and the DAG's documentation.
The DAGs are shown in two forms:
- - [DAGs by Type](#dags-by-type)
- - [Individual DAG documentation](#dag-documentation)
+- [DAGs by Type](#dags-by-type)
+- [Individual DAG documentation](#dag-documentation)
# DAGs by Type
The following are DAGs grouped by their primary tag:
- 1. [Data Refresh](#data_refresh)
- 1. [Database](#database)
- 1. [Maintenance](#maintenance)
- 1. [Oauth](#oauth)
- 1. [Provider](#provider)
- 1. [Provider Reingestion](#provider-reingestion)
+1. [Data Refresh](#data_refresh)
+1. [Database](#database)
+1. [Maintenance](#maintenance)
+1. [Oauth](#oauth)
+1. [Provider](#provider)
+1. [Provider Reingestion](#provider-reingestion)
## Data Refresh
-| DAG ID | Schedule Interval |
-| --- | --- |
-| [`audio_data_refresh`](#audio_data_refresh) | `@weekly` |
-| [`image_data_refresh`](#image_data_refresh) | `@weekly` |
-
-
+| DAG ID | Schedule Interval |
+| ------------------------------------------- | ----------------- |
+| [`audio_data_refresh`](#audio_data_refresh) | `@weekly` |
+| [`image_data_refresh`](#image_data_refresh) | `@weekly` |
## Database
-| DAG ID | Schedule Interval |
-| --- | --- |
-| `image_expiration_workflow` | `None` |
-| [`recreate_audio_popularity_calculation`](#recreate_audio_popularity_calculation) | `None` |
-| [`recreate_image_popularity_calculation`](#recreate_image_popularity_calculation) | `None` |
-| [`report_pending_reported_media`](#report_pending_reported_media) | `@weekly` |
-
-
+| DAG ID | Schedule Interval |
+| --------------------------------------------------------------------------------- | ----------------- |
+| `image_expiration_workflow` | `None` |
+| [`recreate_audio_popularity_calculation`](#recreate_audio_popularity_calculation) | `None` |
+| [`recreate_image_popularity_calculation`](#recreate_image_popularity_calculation) | `None` |
+| [`report_pending_reported_media`](#report_pending_reported_media) | `@weekly` |
## Maintenance
-| DAG ID | Schedule Interval |
-| --- | --- |
-| [`airflow_log_cleanup`](#airflow_log_cleanup) | `@weekly` |
-| [`check_silenced_dags`](#check_silenced_dags) | `@weekly` |
-| [`pr_review_reminders`](#pr_review_reminders) | `0 0 * * 1-5` |
-
-
+| DAG ID | Schedule Interval |
+| --------------------------------------------- | ----------------- |
+| [`airflow_log_cleanup`](#airflow_log_cleanup) | `@weekly` |
+| [`check_silenced_dags`](#check_silenced_dags) | `@weekly` |
+| [`pr_review_reminders`](#pr_review_reminders) | `0 0 * * 1-5` |
## Oauth
-| DAG ID | Schedule Interval |
-| --- | --- |
-| [`oauth2_authorization`](#oauth2_authorization) | `None` |
-| [`oauth2_token_refresh`](#oauth2_token_refresh) | `0 */12 * * *` |
-
-
+| DAG ID | Schedule Interval |
+| ----------------------------------------------- | ----------------- |
+| [`oauth2_authorization`](#oauth2_authorization) | `None` |
+| [`oauth2_token_refresh`](#oauth2_token_refresh) | `0 */12 * * *` |
## Provider
-| DAG ID | Schedule Interval | Dated | Media Type(s) |
-| --- | --- | --- | --- |
-| `brooklyn_museum_workflow` | `@monthly` | `False` | image |
-| `cleveland_museum_workflow` | `@monthly` | `False` | image |
-| [`europeana_workflow`](#europeana_workflow) | `@daily` | `True` | image |
-| [`finnish_museums_workflow`](#finnish_museums_workflow) | `@daily` | `True` | image |
-| [`flickr_workflow`](#flickr_workflow) | `@daily` | `True` | image |
-| [`freesound_workflow`](#freesound_workflow) | `@monthly` | `False` | audio |
-| [`inaturalist_workflow`](#inaturalist_workflow) | `@monthly` | `False` | image |
-| [`jamendo_workflow`](#jamendo_workflow) | `@monthly` | `False` | audio |
-| [`metropolitan_museum_workflow`](#metropolitan_museum_workflow) | `@daily` | `True` | image |
-| `museum_victoria_workflow` | `@monthly` | `False` | image |
-| `nypl_workflow` | `@monthly` | `False` | image |
-| [`phylopic_workflow`](#phylopic_workflow) | `@daily` | `True` | image |
-| [`rawpixel_workflow`](#rawpixel_workflow) | `@monthly` | `False` | image |
-| [`science_museum_workflow`](#science_museum_workflow) | `@monthly` | `False` | image |
-| [`smithsonian_workflow`](#smithsonian_workflow) | `@weekly` | `False` | image |
-| [`smk_workflow`](#smk_workflow) | `@monthly` | `False` | image |
-| [`stocksnap_workflow`](#stocksnap_workflow) | `@monthly` | `False` | image |
-| [`wikimedia_commons_workflow`](#wikimedia_commons_workflow) | `@daily` | `True` | image, audio |
-| [`wordpress_workflow`](#wordpress_workflow) | `@monthly` | `False` | image |
-
-
+| DAG ID | Schedule Interval | Dated | Media Type(s) |
+| --------------------------------------------------------------- | ----------------- | ------- | ------------- |
+| `brooklyn_museum_workflow` | `@monthly` | `False` | image |
+| `cleveland_museum_workflow` | `@monthly` | `False` | image |
+| [`europeana_workflow`](#europeana_workflow) | `@daily` | `True` | image |
+| [`finnish_museums_workflow`](#finnish_museums_workflow) | `@daily` | `True` | image |
+| [`flickr_workflow`](#flickr_workflow) | `@daily` | `True` | image |
+| [`freesound_workflow`](#freesound_workflow) | `@monthly` | `False` | audio |
+| [`inaturalist_workflow`](#inaturalist_workflow) | `@monthly` | `False` | image |
+| [`jamendo_workflow`](#jamendo_workflow) | `@monthly` | `False` | audio |
+| [`metropolitan_museum_workflow`](#metropolitan_museum_workflow) | `@daily` | `True` | image |
+| `museum_victoria_workflow` | `@monthly` | `False` | image |
+| `nypl_workflow` | `@monthly` | `False` | image |
+| [`phylopic_workflow`](#phylopic_workflow) | `@daily` | `True` | image |
+| [`rawpixel_workflow`](#rawpixel_workflow) | `@monthly` | `False` | image |
+| [`science_museum_workflow`](#science_museum_workflow) | `@monthly` | `False` | image |
+| [`smithsonian_workflow`](#smithsonian_workflow) | `@weekly` | `False` | image |
+| [`smk_workflow`](#smk_workflow) | `@monthly` | `False` | image |
+| [`stocksnap_workflow`](#stocksnap_workflow) | `@monthly` | `False` | image |
+| [`wikimedia_commons_workflow`](#wikimedia_commons_workflow) | `@daily` | `True` | image, audio |
+| [`wordpress_workflow`](#wordpress_workflow) | `@monthly` | `False` | image |
## Provider Reingestion
-| DAG ID | Schedule Interval |
-| --- | --- |
-| [`europeana_reingestion_workflow`](#europeana_reingestion_workflow) | `@weekly` |
-| [`flickr_reingestion_workflow`](#flickr_reingestion_workflow) | `@weekly` |
-| [`metropolitan_museum_reingestion_workflow`](#metropolitan_museum_reingestion_workflow) | `@weekly` |
-| [`phylopic_reingestion_workflow`](#phylopic_reingestion_workflow) | `@weekly` |
-| [`wikimedia_reingestion_workflow`](#wikimedia_reingestion_workflow) | `@weekly` |
-
+| DAG ID | Schedule Interval |
+| --------------------------------------------------------------------------------------- | ----------------- |
+| [`europeana_reingestion_workflow`](#europeana_reingestion_workflow) | `@weekly` |
+| [`flickr_reingestion_workflow`](#flickr_reingestion_workflow) | `@weekly` |
+| [`metropolitan_museum_reingestion_workflow`](#metropolitan_museum_reingestion_workflow) | `@weekly` |
+| [`phylopic_reingestion_workflow`](#phylopic_reingestion_workflow) | `@weekly` |
+| [`wikimedia_reingestion_workflow`](#wikimedia_reingestion_workflow) | `@weekly` |
# DAG documentation
The following is documentation associated with each DAG (where available):
- 1. [`airflow_log_cleanup`](#airflow_log_cleanup)
- 1. [`audio_data_refresh`](#audio_data_refresh)
- 1. [`check_silenced_dags`](#check_silenced_dags)
- 1. [`europeana_reingestion_workflow`](#europeana_reingestion_workflow)
- 1. [`europeana_workflow`](#europeana_workflow)
- 1. [`finnish_museums_workflow`](#finnish_museums_workflow)
- 1. [`flickr_reingestion_workflow`](#flickr_reingestion_workflow)
- 1. [`flickr_workflow`](#flickr_workflow)
- 1. [`freesound_workflow`](#freesound_workflow)
- 1. [`image_data_refresh`](#image_data_refresh)
- 1. [`inaturalist_workflow`](#inaturalist_workflow)
- 1. [`jamendo_workflow`](#jamendo_workflow)
- 1. [`metropolitan_museum_reingestion_workflow`](#metropolitan_museum_reingestion_workflow)
- 1. [`metropolitan_museum_workflow`](#metropolitan_museum_workflow)
- 1. [`oauth2_authorization`](#oauth2_authorization)
- 1. [`oauth2_token_refresh`](#oauth2_token_refresh)
- 1. [`phylopic_reingestion_workflow`](#phylopic_reingestion_workflow)
- 1. [`phylopic_workflow`](#phylopic_workflow)
- 1. [`pr_review_reminders`](#pr_review_reminders)
- 1. [`rawpixel_workflow`](#rawpixel_workflow)
- 1. [`recreate_audio_popularity_calculation`](#recreate_audio_popularity_calculation)
- 1. [`recreate_image_popularity_calculation`](#recreate_image_popularity_calculation)
- 1. [`report_pending_reported_media`](#report_pending_reported_media)
- 1. [`science_museum_workflow`](#science_museum_workflow)
- 1. [`smithsonian_workflow`](#smithsonian_workflow)
- 1. [`smk_workflow`](#smk_workflow)
- 1. [`stocksnap_workflow`](#stocksnap_workflow)
- 1. [`wikimedia_commons_workflow`](#wikimedia_commons_workflow)
- 1. [`wikimedia_reingestion_workflow`](#wikimedia_reingestion_workflow)
- 1. [`wordpress_workflow`](#wordpress_workflow)
-
+1. [`airflow_log_cleanup`](#airflow_log_cleanup)
+1. [`audio_data_refresh`](#audio_data_refresh)
+1. [`check_silenced_dags`](#check_silenced_dags)
+1. [`europeana_reingestion_workflow`](#europeana_reingestion_workflow)
+1. [`europeana_workflow`](#europeana_workflow)
+1. [`finnish_museums_workflow`](#finnish_museums_workflow)
+1. [`flickr_reingestion_workflow`](#flickr_reingestion_workflow)
+1. [`flickr_workflow`](#flickr_workflow)
+1. [`freesound_workflow`](#freesound_workflow)
+1. [`image_data_refresh`](#image_data_refresh)
+1. [`inaturalist_workflow`](#inaturalist_workflow)
+1. [`jamendo_workflow`](#jamendo_workflow)
+1. [`metropolitan_museum_reingestion_workflow`](#metropolitan_museum_reingestion_workflow)
+1. [`metropolitan_museum_workflow`](#metropolitan_museum_workflow)
+1. [`oauth2_authorization`](#oauth2_authorization)
+1. [`oauth2_token_refresh`](#oauth2_token_refresh)
+1. [`phylopic_reingestion_workflow`](#phylopic_reingestion_workflow)
+1. [`phylopic_workflow`](#phylopic_workflow)
+1. [`pr_review_reminders`](#pr_review_reminders)
+1. [`rawpixel_workflow`](#rawpixel_workflow)
+1. [`recreate_audio_popularity_calculation`](#recreate_audio_popularity_calculation)
+1. [`recreate_image_popularity_calculation`](#recreate_image_popularity_calculation)
+1. [`report_pending_reported_media`](#report_pending_reported_media)
+1. [`science_museum_workflow`](#science_museum_workflow)
+1. [`smithsonian_workflow`](#smithsonian_workflow)
+1. [`smk_workflow`](#smk_workflow)
+1. [`stocksnap_workflow`](#stocksnap_workflow)
+1. [`wikimedia_commons_workflow`](#wikimedia_commons_workflow)
+1. [`wikimedia_reingestion_workflow`](#wikimedia_reingestion_workflow)
+1. [`wordpress_workflow`](#wordpress_workflow)
## `airflow_log_cleanup`
-
A maintenance workflow that you can deploy into Airflow to periodically clean
out the task logs to avoid those getting too big. By default, this will also
clean child process logs from the 'scheduler' directory.
-Can remove all log files by setting "maxLogAgeInDays" to -1.
-If you want to test the DAG in the Airflow Web UI, you can also set
-enableDelete to `false`, and then you will see a list of log folders
-that can be deleted, but will not actually delete them.
+Can remove all log files by setting "maxLogAgeInDays" to -1. If you want to test
+the DAG in the Airflow Web UI, you can also set enableDelete to `false`, and
+then you will see a list of log folders that can be deleted, but will not
+actually delete them.
This should all go on one line:
+
```
airflow dags trigger --conf
'{"maxLogAgeInDays":-1, "enableDelete": "false"}' airflow_log_cleanup
```
+
`--conf` options:
+
- maxLogAgeInDays:<INT> - Optional
- enableDelete:<BOOLEAN> - Optional
-
## `audio_data_refresh`
### Data Refresh DAG Factory
-This file generates our data refresh DAGs using a factory function.
-For the given media type these DAGs will first refresh the popularity data,
-then initiate a data refresh on the data refresh server and await the
-success or failure of that task.
+
+This file generates our data refresh DAGs using a factory function. For the
+given media type these DAGs will first refresh the popularity data, then
+initiate a data refresh on the data refresh server and await the success or
+failure of that task.
Popularity data for each media type is collated in a materialized view. Before
initiating a data refresh, the DAG will first refresh the view in order to
-update popularity data for records that have been ingested since the last refresh.
-On the first run of the month, the DAG will also refresh the underlying tables,
-including the percentile values and any new popularity metrics. The DAG can also
-be run with the `force_refresh_metrics` option to run this refresh after the first
-of the month.
+update popularity data for records that have been ingested since the last
+refresh. On the first run of the month, the DAG will also refresh the underlying
+tables, including the percentile values and any new popularity metrics. The DAG
+can also be run with the `force_refresh_metrics` option to run this refresh
+after the first of the month.
Once this step is complete, the data refresh can be initiated. A data refresh
occurs on the data refresh server in the openverse-api project. This is a task
-which imports data from the upstream Catalog database into the API, copies contents
-to a new Elasticsearch index, and finally makes the index "live". This process is
-necessary to make new content added to the Catalog by our provider DAGs available
-to the API. You can read more in the [README](
-https://github.com/WordPress/openverse-api/blob/main/ingestion_server/README.md
-) Importantly, the data refresh TaskGroup is also configured to handle concurrency
+which imports data from the upstream Catalog database into the API, copies
+contents to a new Elasticsearch index, and finally makes the index "live". This
+process is necessary to make new content added to the Catalog by our provider
+DAGs available to the API. You can read more in the
+[README](https://github.com/WordPress/openverse-api/blob/main/ingestion_server/README.md)
+Importantly, the data refresh TaskGroup is also configured to handle concurrency
requirements of the data refresh server.
-You can find more background information on this process in the following
-issues and related PRs:
-
-- [[Feature] Data refresh orchestration DAG](
-https://github.com/WordPress/openverse-catalog/issues/353)
-- [[Feature] Merge popularity calculations and data refresh into a single DAG](
-https://github.com/WordPress/openverse-catalog/issues/453)
+You can find more background information on this process in the following issues
+and related PRs:
+- [[Feature] Data refresh orchestration DAG](https://github.com/WordPress/openverse-catalog/issues/353)
+- [[Feature] Merge popularity calculations and data refresh into a single DAG](https://github.com/WordPress/openverse-catalog/issues/453)
## `check_silenced_dags`
-
Checks for DAGs that have silenced Slack alerts which may need to be turned back
on.
-When a DAG has known failures, it can be ommitted from Slack error reporting by adding
-an entry to the `SILENCED_SLACK_NOTIFICATIONS` Airflow variable. This is a dictionary
-where thekey is the `dag_id` of the affected DAG, and the value is a list of
-SilencedSlackNotifications (which map silenced notifications to GitHub URLs) for that
-DAG.
+When a DAG has known failures, it can be ommitted from Slack error reporting by
+adding an entry to the `SILENCED_SLACK_NOTIFICATIONS` Airflow variable. This is
+a dictionary where thekey is the `dag_id` of the affected DAG, and the value is
+a list of SilencedSlackNotifications (which map silenced notifications to GitHub
+URLs) for that DAG.
The `check_silenced_dags` DAG iterates over the entries in the
-`SILENCED_SLACK_NOTIFICATIONS` configuration and verifies that the associated GitHub
-issues are still open. If an issue has been closed, it is assumed that the DAG should
-have Slack reporting reenabled, and an alert is sent to prompt manual update of the
-configuration. This prevents developers from forgetting to reenable Slack reporting
-after the issue has been resolved.
+`SILENCED_SLACK_NOTIFICATIONS` configuration and verifies that the associated
+GitHub issues are still open. If an issue has been closed, it is assumed that
+the DAG should have Slack reporting reenabled, and an alert is sent to prompt
+manual update of the configuration. This prevents developers from forgetting to
+reenable Slack reporting after the issue has been resolved.
The DAG runs weekly.
-
## `europeana_reingestion_workflow`
+Content Provider: Europeana
-Content Provider: Europeana
-
-ETL Process: Use the API to identify all CC licensed images.
-
-Output: TSV file containing the images and the
- respective meta-data.
+ETL Process: Use the API to identify all CC licensed images.
-Notes: https://www.europeana.eu/api/v2/search.json
+Output: TSV file containing the images and the respective meta-data.
+Notes: https://www.europeana.eu/api/v2/search.json
## `europeana_workflow`
+Content Provider: Europeana
-Content Provider: Europeana
-
-ETL Process: Use the API to identify all CC licensed images.
-
-Output: TSV file containing the images and the
- respective meta-data.
+ETL Process: Use the API to identify all CC licensed images.
-Notes: https://www.europeana.eu/api/v2/search.json
+Output: TSV file containing the images and the respective meta-data.
+Notes: https://www.europeana.eu/api/v2/search.json
## `finnish_museums_workflow`
+Content Provider: Finnish Museums
-Content Provider: Finnish Museums
+ETL Process: Use the API to identify all CC licensed images.
-ETL Process: Use the API to identify all CC licensed images.
-
-Output: TSV file containing the images and the
- respective meta-data.
-
-Notes: https://api.finna.fi/swagger-ui/
- https://www.finna.fi/Content/help-syntax?lng=en-gb
- The Finnish Museums provider script is a dated DAG that
- ingests all records that were last updated in the previous
- day. Because of this, it is not necessary to run a separate
- reingestion DAG, as updated data will be processed during
- regular ingestion.
+Output: TSV file containing the images and the respective meta-data.
+Notes: https://api.finna.fi/swagger-ui/
+https://www.finna.fi/Content/help-syntax?lng=en-gb The Finnish Museums provider
+script is a dated DAG that ingests all records that were last updated in the
+previous day. Because of this, it is not necessary to run a separate reingestion
+DAG, as updated data will be processed during regular ingestion.
## `flickr_reingestion_workflow`
+Content Provider: Flickr
-Content Provider: Flickr
-
-ETL Process: Use the API to identify all CC licensed images.
+ETL Process: Use the API to identify all CC licensed images.
-Output: TSV file containing the images and the
- respective meta-data.
-
-Notes: https://www.flickr.com/help/terms/api
- Rate limit: 3600 requests per hour.
+Output: TSV file containing the images and the respective meta-data.
+Notes: https://www.flickr.com/help/terms/api Rate limit: 3600 requests per hour.
## `flickr_workflow`
+Content Provider: Flickr
-Content Provider: Flickr
-
-ETL Process: Use the API to identify all CC licensed images.
+ETL Process: Use the API to identify all CC licensed images.
-Output: TSV file containing the images and the
- respective meta-data.
-
-Notes: https://www.flickr.com/help/terms/api
- Rate limit: 3600 requests per hour.
+Output: TSV file containing the images and the respective meta-data.
+Notes: https://www.flickr.com/help/terms/api Rate limit: 3600 requests per hour.
## `freesound_workflow`
+Content Provider: Freesound
-Content Provider: Freesound
-
-ETL Process: Use the API to identify all CC-licensed images.
-
-Output: TSV file containing the image, the respective
- meta-data.
+ETL Process: Use the API to identify all CC-licensed images.
-Notes: https://freesound.org/apiv2/search/text'
- No rate limit specified.
- This script can be run either to ingest the full dataset or
- as a dated DAG.
+Output: TSV file containing the image, the respective meta-data.
+Notes: https://freesound.org/apiv2/search/text' No rate limit specified. This
+script can be run either to ingest the full dataset or as a dated DAG.
## `image_data_refresh`
### Data Refresh DAG Factory
-This file generates our data refresh DAGs using a factory function.
-For the given media type these DAGs will first refresh the popularity data,
-then initiate a data refresh on the data refresh server and await the
-success or failure of that task.
+
+This file generates our data refresh DAGs using a factory function. For the
+given media type these DAGs will first refresh the popularity data, then
+initiate a data refresh on the data refresh server and await the success or
+failure of that task.
Popularity data for each media type is collated in a materialized view. Before
initiating a data refresh, the DAG will first refresh the view in order to
-update popularity data for records that have been ingested since the last refresh.
-On the first run of the month, the DAG will also refresh the underlying tables,
-including the percentile values and any new popularity metrics. The DAG can also
-be run with the `force_refresh_metrics` option to run this refresh after the first
-of the month.
+update popularity data for records that have been ingested since the last
+refresh. On the first run of the month, the DAG will also refresh the underlying
+tables, including the percentile values and any new popularity metrics. The DAG
+can also be run with the `force_refresh_metrics` option to run this refresh
+after the first of the month.
Once this step is complete, the data refresh can be initiated. A data refresh
occurs on the data refresh server in the openverse-api project. This is a task
-which imports data from the upstream Catalog database into the API, copies contents
-to a new Elasticsearch index, and finally makes the index "live". This process is
-necessary to make new content added to the Catalog by our provider DAGs available
-to the API. You can read more in the [README](
-https://github.com/WordPress/openverse-api/blob/main/ingestion_server/README.md
-) Importantly, the data refresh TaskGroup is also configured to handle concurrency
+which imports data from the upstream Catalog database into the API, copies
+contents to a new Elasticsearch index, and finally makes the index "live". This
+process is necessary to make new content added to the Catalog by our provider
+DAGs available to the API. You can read more in the
+[README](https://github.com/WordPress/openverse-api/blob/main/ingestion_server/README.md)
+Importantly, the data refresh TaskGroup is also configured to handle concurrency
requirements of the data refresh server.
-You can find more background information on this process in the following
-issues and related PRs:
-
-- [[Feature] Data refresh orchestration DAG](
-https://github.com/WordPress/openverse-catalog/issues/353)
-- [[Feature] Merge popularity calculations and data refresh into a single DAG](
-https://github.com/WordPress/openverse-catalog/issues/453)
+You can find more background information on this process in the following issues
+and related PRs:
+- [[Feature] Data refresh orchestration DAG](https://github.com/WordPress/openverse-catalog/issues/353)
+- [[Feature] Merge popularity calculations and data refresh into a single DAG](https://github.com/WordPress/openverse-catalog/issues/453)
## `inaturalist_workflow`
+Provider: iNaturalist
-Provider: iNaturalist
+Output: TSV file containing the media metadata.
-Output: TSV file containing the media metadata.
-
-Notes: [The iNaturalist API is not intended for data scraping.]
- (https://api.inaturalist.org/v1/docs/)
+Notes: [The iNaturalist API is not intended for data scraping.]
+(https://api.inaturalist.org/v1/docs/)
[But there is a full dump intended for sharing on S3.]
(https://github.com/inaturalist/inaturalist-open-data/tree/documentation/Metadata)
@@ -358,41 +316,30 @@ Notes: [The iNaturalist API is not intended for data scraping.]
(https://github.com/inaturalist/inaturalist-open-data/blob/main/Metadata/structure.sql)
except for adding ancestry tags to the taxa table.
-
## `jamendo_workflow`
+Content Provider: Jamendo
-Content Provider: Jamendo
-
-ETL Process: Use the API to identify all CC-licensed audio.
-
-Output: TSV file containing the audio meta-data.
+ETL Process: Use the API to identify all CC-licensed audio.
-Notes: https://api.jamendo.com/v3.0/tracks/
- 35,000 requests per month for non-commercial apps
- Jamendo Music has more than 500,000 tracks shared by
- 40,000 artists from over 150 countries all over
- the world.
- Audio quality: uploaded as WAV/ FLAC/ AIFF
- bit depth: 16/24
- sample rate: 44.1 or 48 kHz
- channels: 1/2
+Output: TSV file containing the audio meta-data.
+Notes: https://api.jamendo.com/v3.0/tracks/ 35,000 requests per month for
+non-commercial apps Jamendo Music has more than 500,000 tracks shared by 40,000
+artists from over 150 countries all over the world. Audio quality: uploaded as
+WAV/ FLAC/ AIFF bit depth: 16/24 sample rate: 44.1 or 48 kHz channels: 1/2
## `metropolitan_museum_reingestion_workflow`
+Content Provider: Metropolitan Museum of Art
-Content Provider: Metropolitan Museum of Art
+ETL Process: Use the API to identify all CC0 artworks.
-ETL Process: Use the API to identify all CC0 artworks.
+Output: TSV file containing the image, their respective meta-data.
-Output: TSV file containing the image, their respective
- meta-data.
-
-Notes: https://metmuseum.github.io/#search
- "Please limit requests to 80 requests per second." May need to
- bump up the delay (e.g. to 3 seconds), to avoid of blocking
- during local development testing.
+Notes: https://metmuseum.github.io/#search "Please limit requests to 80 requests
+per second." May need to bump up the delay (e.g. to 3 seconds), to avoid of
+blocking during local development testing.
Some analysis to improve data quality was conducted using a
separate csv file here: https://github.com/metmuseum/openaccess
@@ -406,22 +353,17 @@ Notes: https://metmuseum.github.io/#search
connect with just date and license.
https://collectionapi.metmuseum.org/public/collection/v1/search?isPublicDomain=true&metadataDate=2022-08-07
-
-
## `metropolitan_museum_workflow`
+Content Provider: Metropolitan Museum of Art
-Content Provider: Metropolitan Museum of Art
+ETL Process: Use the API to identify all CC0 artworks.
-ETL Process: Use the API to identify all CC0 artworks.
+Output: TSV file containing the image, their respective meta-data.
-Output: TSV file containing the image, their respective
- meta-data.
-
-Notes: https://metmuseum.github.io/#search
- "Please limit requests to 80 requests per second." May need to
- bump up the delay (e.g. to 3 seconds), to avoid of blocking
- during local development testing.
+Notes: https://metmuseum.github.io/#search "Please limit requests to 80 requests
+per second." May need to bump up the delay (e.g. to 3 seconds), to avoid of
+blocking during local development testing.
Some analysis to improve data quality was conducted using a
separate csv file here: https://github.com/metmuseum/openaccess
@@ -435,8 +377,6 @@ Notes: https://metmuseum.github.io/#search
connect with just date and license.
https://collectionapi.metmuseum.org/public/collection/v1/search?isPublicDomain=true&metadataDate=2022-08-07
-
-
## `oauth2_authorization`
### OAuth Provider Authorization
@@ -445,18 +385,16 @@ Notes: https://metmuseum.github.io/#search
**Created**: 2021-10-13
-
-
-Iterates through all the OAuth2 providers and attempts to authorize them using tokens
-found in the in the `OAUTH2_AUTH_KEYS` Variable. Once authorization has been
-completed successfully, the auth token is removed from that Variable. The authorization
-will create an access/refresh token pair in the `OAUTH2_ACCESS_TOKENS` Variable.
+Iterates through all the OAuth2 providers and attempts to authorize them using
+tokens found in the in the `OAUTH2_AUTH_KEYS` Variable. Once authorization has
+been completed successfully, the auth token is removed from that Variable. The
+authorization will create an access/refresh token pair in the
+`OAUTH2_ACCESS_TOKENS` Variable.
**Current Providers**:
- Freesound
-
## `oauth2_token_refresh`
### OAuth Provider Token Refresh
@@ -465,214 +403,175 @@ will create an access/refresh token pair in the `OAUTH2_ACCESS_TOKENS` Variable.
**Created**: 2021-10-13
-
-Iterates through all OAuth2 providers and attempts to refresh the access token using
-the refresh token stored in the `OAUTH2_ACCESS_TOKENS` Variable. This DAG will
-update the tokens stored in the Variable upon successful refresh.
+Iterates through all OAuth2 providers and attempts to refresh the access token
+using the refresh token stored in the `OAUTH2_ACCESS_TOKENS` Variable. This DAG
+will update the tokens stored in the Variable upon successful refresh.
**Current Providers**:
- Freesound
-
## `phylopic_reingestion_workflow`
+Content Provider: PhyloPic
-Content Provider: PhyloPic
-
-ETL Process: Use the API to identify all CC licensed images.
-
-Output: TSV file containing the image,
- their respective meta-data.
+ETL Process: Use the API to identify all CC licensed images.
-Notes: http://phylopic.org/api/
- No rate limit specified.
+Output: TSV file containing the image, their respective meta-data.
+Notes: http://phylopic.org/api/ No rate limit specified.
## `phylopic_workflow`
+Content Provider: PhyloPic
-Content Provider: PhyloPic
-
-ETL Process: Use the API to identify all CC licensed images.
-
-Output: TSV file containing the image,
- their respective meta-data.
+ETL Process: Use the API to identify all CC licensed images.
-Notes: http://phylopic.org/api/
- No rate limit specified.
+Output: TSV file containing the image, their respective meta-data.
+Notes: http://phylopic.org/api/ No rate limit specified.
## `pr_review_reminders`
-
-Iterates through open PRs in our repositories and pings assigned reviewers
-who have not yet approved the PR or explicitly requested changes.
+Iterates through open PRs in our repositories and pings assigned reviewers who
+have not yet approved the PR or explicitly requested changes.
This DAG runs daily and pings on the following schedule based on priority label:
-| priority | days |
-| --- | --- |
-| critical | 1 day |
-| high | >2 days |
-| medium | >4 days |
-| low | >7 days |
+| priority | days |
+| -------- | ------- |
+| critical | 1 day |
+| high | >2 days |
+| medium | >4 days |
+| low | >7 days |
-The DAG does not ping on Saturday and Sunday and accounts for weekend days
-when determining how much time has passed since the review.
+The DAG does not ping on Saturday and Sunday and accounts for weekend days when
+determining how much time has passed since the review.
Unfortunately the DAG does not know when someone is on vacation. It is up to the
author of the PR to re-assign review if one of the randomly selected reviewers
is unavailable for the time period during which the PR should be reviewed.
-
## `rawpixel_workflow`
+Content Provider: Rawpixel
-Content Provider: Rawpixel
-
-ETL Process: Use the API to identify all CC-licensed images.
-
-Output: TSV file containing the image meta-data.
+ETL Process: Use the API to identify all CC-licensed images.
-Notes: Rawpixel has given Openverse beta access to their API.
- This API is undocumented, and we will need to contact Rawpixel
- directly if we run into any issues.
- The public API max results range is limited to 100,000 results,
- although the API key we've been given can circumvent this limit.
- https://www.rawpixel.com/api/v1/search?tags=$publicdomain&page=1&pagesize=100
+Output: TSV file containing the image meta-data.
+Notes: Rawpixel has given Openverse beta access to their API. This API is
+undocumented, and we will need to contact Rawpixel directly if we run into any
+issues. The public API max results range is limited to 100,000 results, although
+the API key we've been given can circumvent this limit.
+https://www.rawpixel.com/api/v1/search?tags=$publicdomain&page=1&pagesize=100
## `recreate_audio_popularity_calculation`
-
This file generates Apache Airflow DAGs that, for the given media type,
completely wipe out the PostgreSQL relations and functions involved in
-calculating our standardized popularity metric. It then recreates relations
-and functions to make the calculation, and performs an initial calculation.
-The results are available in the materialized view for that media type.
-
-These DAGs are not on a schedule, and should only be run manually when new
-SQL code is deployed for the calculation.
+calculating our standardized popularity metric. It then recreates relations and
+functions to make the calculation, and performs an initial calculation. The
+results are available in the materialized view for that media type.
+These DAGs are not on a schedule, and should only be run manually when new SQL
+code is deployed for the calculation.
## `recreate_image_popularity_calculation`
-
This file generates Apache Airflow DAGs that, for the given media type,
completely wipe out the PostgreSQL relations and functions involved in
-calculating our standardized popularity metric. It then recreates relations
-and functions to make the calculation, and performs an initial calculation.
-The results are available in the materialized view for that media type.
-
-These DAGs are not on a schedule, and should only be run manually when new
-SQL code is deployed for the calculation.
+calculating our standardized popularity metric. It then recreates relations and
+functions to make the calculation, and performs an initial calculation. The
+results are available in the materialized view for that media type.
+These DAGs are not on a schedule, and should only be run manually when new SQL
+code is deployed for the calculation.
## `report_pending_reported_media`
### Report Pending Reported Media DAG
+
This DAG checks for any user-reported media pending manual review, and alerts
via Slack.
-Media may be reported for mature content or copyright infringement, for
-example. Once reported, these require manual review through the Django Admin to
-determine whether further action (such as deindexing the record) needs to be
-taken. If a record has been reported multiple times, it only needs to be
-reviewed once and so is only counted once in the reporting by this DAG.
-
+Media may be reported for mature content or copyright infringement, for example.
+Once reported, these require manual review through the Django Admin to determine
+whether further action (such as deindexing the record) needs to be taken. If a
+record has been reported multiple times, it only needs to be reviewed once and
+so is only counted once in the reporting by this DAG.
## `science_museum_workflow`
+Content Provider: Science Museum
-Content Provider: Science Museum
-
-ETL Process: Use the API to identify all CC-licensed images.
-
-Output: TSV file containing the image, the respective
- meta-data.
+ETL Process: Use the API to identify all CC-licensed images.
-Notes: https://github.com/TheScienceMuseum/collectionsonline/wiki/Collections-Online-API # noqa
- Rate limited, no specific rate given.
+Output: TSV file containing the image, the respective meta-data.
+Notes:
+https://github.com/TheScienceMuseum/collectionsonline/wiki/Collections-Online-API #
+noqa Rate limited, no specific rate given.
## `smithsonian_workflow`
+Content Provider: Smithsonian
-Content Provider: Smithsonian
-
-ETL Process: Use the API to identify all CC licensed images.
-
-Output: TSV file containing the images and the respective meta-data.
+ETL Process: Use the API to identify all CC licensed images.
-Notes: https://api.si.edu/openaccess/api/v1.0/search
+Output: TSV file containing the images and the respective meta-data.
+Notes: https://api.si.edu/openaccess/api/v1.0/search
## `smk_workflow`
+Content Provider: Statens Museum for Kunst (National Gallery of Denmark)
-Content Provider: Statens Museum for Kunst (National Gallery of Denmark)
+ETL Process: Use the API to identify all openly licensed media.
-ETL Process: Use the API to identify all openly licensed media.
-
-Output: TSV file containing the media metadata.
-
-Notes: https://www.smk.dk/en/article/smk-api/
+Output: TSV file containing the media metadata.
+Notes: https://www.smk.dk/en/article/smk-api/
## `stocksnap_workflow`
+Content Provider: StockSnap
-Content Provider: StockSnap
-
-ETL Process: Use the API to identify all CC-licensed images.
+ETL Process: Use the API to identify all CC-licensed images.
-Output: TSV file containing the image, the respective meta-data.
-
-Notes: https://stocksnap.io/api/load-photos/date/desc/1
- https://stocksnap.io/faq
- All images are licensed under CC0.
- No rate limits or authorization required.
- API is undocumented.
+Output: TSV file containing the image, the respective meta-data.
+Notes: https://stocksnap.io/api/load-photos/date/desc/1 https://stocksnap.io/faq
+All images are licensed under CC0. No rate limits or authorization required. API
+is undocumented.
## `wikimedia_commons_workflow`
+Content Provider: Wikimedia Commons
-Content Provider: Wikimedia Commons
-
-ETL Process: Use the API to identify all CC-licensed images.
+ETL Process: Use the API to identify all CC-licensed images.
-Output: TSV file containing the image, the respective
- meta-data.
-
-Notes: https://commons.wikimedia.org/wiki/API:Main_page
- No rate limit specified.
+Output: TSV file containing the image, the respective meta-data.
+Notes: https://commons.wikimedia.org/wiki/API:Main_page No rate limit specified.
## `wikimedia_reingestion_workflow`
+Content Provider: Wikimedia Commons
-Content Provider: Wikimedia Commons
-
-ETL Process: Use the API to identify all CC-licensed images.
+ETL Process: Use the API to identify all CC-licensed images.
-Output: TSV file containing the image, the respective
- meta-data.
-
-Notes: https://commons.wikimedia.org/wiki/API:Main_page
- No rate limit specified.
+Output: TSV file containing the image, the respective meta-data.
+Notes: https://commons.wikimedia.org/wiki/API:Main_page No rate limit specified.
## `wordpress_workflow`
+Content Provider: WordPress Photo Directory
-Content Provider: WordPress Photo Directory
-
-ETL Process: Use the API to identify all openly licensed media.
+ETL Process: Use the API to identify all openly licensed media.
-Output: TSV file containing the media metadata.
+Output: TSV file containing the media metadata.
-Notes: https://wordpress.org/photos/wp-json/wp/v2
- Provide photos, media, users and more related resources.
- No rate limit specified.
+Notes: https://wordpress.org/photos/wp-json/wp/v2 Provide photos, media, users
+and more related resources. No rate limit specified.
diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md
index e37b847cf..5930fe5a1 100644
--- a/DEPLOYMENT.md
+++ b/DEPLOYMENT.md
@@ -1,25 +1,31 @@
# Catalog Deployments
-The Openverse Catalog consists of two core components: a **Postgres** instance and an **Airflow** instance.
-This document describes the environments & deployment procedures for both components.
+The Openverse Catalog consists of two core components: a **Postgres** instance
+and an **Airflow** instance. This document describes the environments &
+deployment procedures for both components.
# Airflow
> **URL**: https://airflow.openverse.engineering
-Airflow has two different deployment mechanisms: **service deployments** and **DAG deployments**.
-Service deployments occur when the Airflow service itself or any dependencies needs to be updated.
-DAG deployments occur when DAG definitions or operational code has changed.
+Airflow has two different deployment mechanisms: **service deployments** and
+**DAG deployments**. Service deployments occur when the Airflow service itself
+or any dependencies needs to be updated. DAG deployments occur when DAG
+definitions or operational code has changed.
## Service deployments
-The Catalog's Airflow instance is hosted via AWS's Elastic Compute Cloud (EC2) service.
-The EC2 instance is managed by Terraform.
-If a change is made to the service initialization bash script, Terraform will recognize this change and can deploy a new EC2 instance with the updated configuration.
-This change does not occur automatically and will need to be manually initiated.
+The Catalog's Airflow instance is hosted via AWS's Elastic Compute Cloud (EC2)
+service. The EC2 instance is managed by Terraform. If a change is made to the
+service initialization bash script, Terraform will recognize this change and can
+deploy a new EC2 instance with the updated configuration. This change does not
+occur automatically and will need to be manually initiated.
-Currently the webserver, scheduler, and worker(s) are all run within a single docker container on the EC2 instance as defined by [the Airflow `Dockerfile` and related files](./docker/airflow).
-The [`docker-compose.yml`](./docker-compose.yml) is used to spin up Airflow in production.
+Currently the webserver, scheduler, and worker(s) are all run within a single
+docker container on the EC2 instance as defined by
+[the Airflow `Dockerfile` and related files](./docker/airflow). The
+[`docker-compose.yml`](./docker-compose.yml) is used to spin up Airflow in
+production.
**Note**: Service deployments are only necessary in the following conditions:
@@ -27,40 +33,59 @@ The [`docker-compose.yml`](./docker-compose.yml) is used to spin up Airflow in p
- An environment variable needs to be added/removed/changed
- A change to the infrastructure has been made (e.g. networking/routing changes)
-For DAG updates and code-only changes, see the [DAG deployments section](#dag-deployments).
+For DAG updates and code-only changes, see the
+[DAG deployments section](#dag-deployments).
### Deployment workflow
-The "πŸ”’" icon below notes that the action must be performed by a core maintainer with infrastructure access.
+The "πŸ”’" icon below notes that the action must be performed by a core maintainer
+with infrastructure access.
1. [Cut a new release on GitHub](https://github.com/WordPress/openverse-catalog/releases).
-2. After the release GitHub action has run, [check that the new Docker tag corresponding to the release exists on ghcr.io](https://github.com/wordpress/openverse-catalog/pkgs/container/openverse-catalog).
-3. Ensure that there are [no actively running DAGs](https://airflow.openverse.engineering/dagrun/list/?_flt_3_state=running).
+2. After the release GitHub action has run,
+ [check that the new Docker tag corresponding to the release exists on ghcr.io](https://github.com/wordpress/openverse-catalog/pkgs/container/openverse-catalog).
+3. Ensure that there are
+ [no actively running DAGs](https://airflow.openverse.engineering/dagrun/list/?_flt_3_state=running).
4. πŸ”’ Update the `docker_image_tag` in Terraform's configuration.
-5. πŸ”’ Initiate the deployment via `just plan prod catalog-airflow` (and subsequently `just apply prod catalog-airflow` if the plan looks correct).
+5. πŸ”’ Initiate the deployment via `just plan prod catalog-airflow` (and
+ subsequently `just apply prod catalog-airflow` if the plan looks correct).
## DAG deployments
-Due to the [nature of Airflow](https://airflow.apache.org/docs/apache-airflow/stable/dag-serialization.html), changes made to DAG definitions or operational code (e.g. any files that are used by the DAG) will be immediately picked up on the next task run for a DAG.
-This means that we can update the python code in-place and the next DAG run or task in a currently running DAG will use the updated code.
-In these cases, a new EC2 instance _does not_ need to be deployed.
+Due to the
+[nature of Airflow](https://airflow.apache.org/docs/apache-airflow/stable/dag-serialization.html),
+changes made to DAG definitions or operational code (e.g. any files that are
+used by the DAG) will be immediately picked up on the next task run for a DAG.
+This means that we can update the python code in-place and the next DAG run or
+task in a currently running DAG will use the updated code. In these cases, a new
+EC2 instance _does not_ need to be deployed.
-The [`dag-sync.sh`](./dag-sync.sh) script is used in production to regularly update the repository (and thus the DAG files) on the running EC2 instance.
+The [`dag-sync.sh`](./dag-sync.sh) script is used in production to regularly
+update the repository (and thus the DAG files) on the running EC2 instance.
### Deployment workflow
-Since this process happens automatically, the only precursor to a DAG deployment is merging the relevant PR into `main`.
+Since this process happens automatically, the only precursor to a DAG deployment
+is merging the relevant PR into `main`.
-_**Note**: New DAGs are not automatically enabled and will need to be turned on once deployed._
+_**Note**: New DAGs are not automatically enabled and will need to be turned on
+once deployed._
# Postgres
-The Catalog is also backed by a Postgres instance, which serves as the primary data warehouse for all ingested media data.
+The Catalog is also backed by a Postgres instance, which serves as the primary
+data warehouse for all ingested media data.
-This instance is hosted on AWS using [RDS](https://aws.amazon.com/rds/).
-The instance can be accessed using [`pgcli`](https://www.pgcli.com/) or a similar client with the jumphost defined in the infrastructure repository.
-For more information on this process see the [documentation on connecting to the jumphost](https://github.com/WordPress/openverse-infrastructure/blob/main/docs/CONNECTING-TO-JUMPHOST.md) (note that you will need additional access to view this document, please reach out to the maintainers if you're interested).
+This instance is hosted on AWS using [RDS](https://aws.amazon.com/rds/). The
+instance can be accessed using [`pgcli`](https://www.pgcli.com/) or a similar
+client with the jumphost defined in the infrastructure repository. For more
+information on this process see the
+[documentation on connecting to the jumphost](https://github.com/WordPress/openverse-infrastructure/blob/main/docs/CONNECTING-TO-JUMPHOST.md)
+(note that you will need additional access to view this document, please reach
+out to the maintainers if you're interested).
## Migrations
-Any migrations to the Catalog database must either be performed by hand or as part of a DAG's normal operation (see: [iNaturalist](openverse_catalog/dags/providers/provider_api_scripts/inaturalist.py)).
+Any migrations to the Catalog database must either be performed by hand or as
+part of a DAG's normal operation (see:
+[iNaturalist](openverse_catalog/dags/providers/provider_api_scripts/inaturalist.py)).
diff --git a/README.md b/README.md
index 3aca71b5f..b2aea924c 100644
--- a/README.md
+++ b/README.md
@@ -10,8 +10,8 @@ This repository contains the methods used to identify over 1.4 billion Creative
Commons licensed works. The challenge is that these works are dispersed
throughout the web and identifying them requires a combination of techniques.
-Currently, we only pull data from APIs which serve Creative Commons licensed media.
-In the past, we have also used web crawl data as a source.
+Currently, we only pull data from APIs which serve Creative Commons licensed
+media. In the past, we have also used web crawl data as a source.
## API Data
@@ -21,10 +21,11 @@ the internet.
### API Workflows
-To view more information about all the available workflows (DAGs) within the project,
-see [DAGs.md](DAGs.md).
+To view more information about all the available workflows (DAGs) within the
+project, see [DAGs.md](DAGs.md).
-See each provider API script's notes in their respective [handbook][ov-handbook] entry.
+See each provider API script's notes in their respective [handbook][ov-handbook]
+entry.
[ov-handbook]: https://make.wordpress.org/openverse/handbook/openverse-handbook/
@@ -41,14 +42,14 @@ The data is available in three file formats:
- WET: extracted plaintext from each webpage.
- WAT: extracted html metadata, e.g. HTTP headers and hyperlinks, etc.
-For more information about these formats, please see the
-[Common Crawl documentation][ccrawl_doc].
+For more information about these formats, please see the [Common Crawl
+documentation][ccrawl_doc].
-Openverse Catalog used AWS Data Pipeline service to automatically create an Amazon EMR
-cluster of 100 c4.8xlarge instances that parsed the WAT archives to identify
-all domains that link to creativecommons.org. Due to the volume of data, Apache
-Spark was also used to streamline the processing. The output of this methodology was a
-series of parquet files that contain:
+Openverse Catalog used AWS Data Pipeline service to automatically create an
+Amazon EMR cluster of 100 c4.8xlarge instances that parsed the WAT archives to
+identify all domains that link to creativecommons.org. Due to the volume of
+data, Apache Spark was also used to streamline the processing. The output of
+this methodology was a series of parquet files that contain:
- the domains and its respective content path and query string (i.e. the exact
webpage that links to creativecommons.org)
@@ -68,12 +69,13 @@ This method was retired in 2021.
## Development setup for Airflow and API puller scripts
There are a number of scripts in the directory
-[`openverse_catalog/dags/provider_api_scripts`][api_scripts] eventually
-loaded into a database to be indexed for searching in the Openverse API. These run in a
+[`openverse_catalog/dags/provider_api_scripts`][api_scripts] eventually loaded
+into a database to be indexed for searching in the Openverse API. These run in a
different environment than the PySpark portion of the project, and so have their
own dependency requirements.
-For instructions geared specifically towards production deployments, see [DEPLOYMENT.md](DEPLOYMENT.md)
+For instructions geared specifically towards production deployments, see
+[DEPLOYMENT.md](DEPLOYMENT.md)
[api_scripts]: openverse_catalog/dags/providers/provider_api_scripts
@@ -82,7 +84,8 @@ For instructions geared specifically towards production deployments, see [DEPLOY
You'll need `docker` and `docker-compose` installed on your machine, with
versions new enough to use version `3` of Docker Compose `.yml` files.
-You will also need the [`just`](https://github.com/casey/just#installation) command runner installed.
+You will also need the [`just`](https://github.com/casey/just#installation)
+command runner installed.
### Setup
@@ -94,8 +97,8 @@ source venv/bin/activate
just install
```
-The containers will be built when starting the stack up for the first time.
-If you'd like to build them prior to that, run:
+The containers will be built when starting the stack up for the first time. If
+you'd like to build them prior to that, run:
```shell
just build
@@ -112,10 +115,14 @@ just dotenv
This will generate a `.env` file which is used by the containers.
The `.env` file is split into four sections:
+
1. Airflow Settings - these can be used to tweak various Airflow properties
-2. API Keys - set these if you intend to test one of the provider APIs referenced
-3. Connection/Variable info - this will not likely need to be modified for local development, though the values will need to be changed in production
-4. Other config - misc. configuration settings, some of which are useful for local dev
+2. API Keys - set these if you intend to test one of the provider APIs
+ referenced
+3. Connection/Variable info - this will not likely need to be modified for local
+ development, though the values will need to be changed in production
+4. Other config - misc. configuration settings, some of which are useful for
+ local dev
The `.env` file does not need to be modified if you only want to run the tests.
@@ -141,15 +148,18 @@ and some networking setup so that they can communicate. Note:
- `openverse_catalog_postgres_1` is running PostgreSQL, and is setup with some
databases and tables to emulate the production environment. It also provides a
database for Airflow to store its running state.
-- The directory containing all modules files (including DAGs, dependencies, and other
- tooling) will be mounted to the directory `/opt/airflow/openverse_catalog`
- in the container `openverse_catalog_webserver_1`. On production, only the DAGs folder
- will be mounted, e.g. `/opt/airflow/openverse_catalog/dags`.
+- The directory containing all modules files (including DAGs, dependencies, and
+ other tooling) will be mounted to the directory
+ `/opt/airflow/openverse_catalog` in the container
+ `openverse_catalog_webserver_1`. On production, only the DAGs folder will be
+ mounted, e.g. `/opt/airflow/openverse_catalog/dags`.
The various services can be accessed using these links:
-- Airflow: `localhost:9090` (The default username and password are both `airflow`.)
-- Minio Console: `localhost:5011` (The default username and password are `test_key` and `test_secret`)
+- Airflow: `localhost:9090` (The default username and password are both
+ `airflow`.)
+- Minio Console: `localhost:5011` (The default username and password are
+ `test_key` and `test_secret`)
- Postgres: `localhost:5434` (using a database connector)
At this stage, you can run the tests via:
@@ -170,7 +180,8 @@ If you'd like, it's possible to login to the webserver container via:
just shell
```
-If you just need to run an airflow command, you can use the `airflow` recipe. Arguments passed to airflow must be quoted:
+If you just need to run an airflow command, you can use the `airflow` recipe.
+Arguments passed to airflow must be quoted:
```shell
just airflow "config list"
@@ -182,7 +193,8 @@ To follow the logs of the running container:
just logs
```
-To begin an interactive [`pgcli` shell](https://www.pgcli.com/) on the database container, run:
+To begin an interactive [`pgcli` shell](https://www.pgcli.com/) on the database
+container, run:
```shell
just db-shell
@@ -200,7 +212,9 @@ To reset the test DB (wiping out all databases, schemata, and tables), run
just down -v
```
-`docker volume prune` can also be useful if you've already stopped the running containers, but be warned that it will remove all volumes associated with stopped containers, not just openverse-catalog ones.
+`docker volume prune` can also be useful if you've already stopped the running
+containers, but be warned that it will remove all volumes associated with
+stopped containers, not just openverse-catalog ones.
To fully recreate everything from the ground up, you can use:
@@ -208,10 +222,9 @@ To fully recreate everything from the ground up, you can use:
just recreate
```
-> **Note**:
-> Any recipes or scripts which output files to the container's mounted volumes will
-> need to be run as the root user. This can be done with the `DC_USER=root`
-> environment variable for `just` recipes. For example, see the
+> **Note**: Any recipes or scripts which output files to the container's mounted
+> volumes will need to be run as the root user. This can be done with the
+> `DC_USER=root` environment variable for `just` recipes. For example, see the
> [generate-dag-docs recipe](https://github.com/WordPress/openverse-catalog/blob/c9be67e483e49e9eda7cd21b52bcde8857cd3922/justfile#L126).
[justfile]: justfile
@@ -245,22 +258,31 @@ openverse-catalog
## Publishing
-The docker image for the catalog (Airflow) is published to ghcr.io/WordPress/openverse-catalog.
+The docker image for the catalog (Airflow) is published to
+ghcr.io/WordPress/openverse-catalog.
## Contributing
-Pull requests are welcome! Feel free to [join us on Slack][wp_slack] and discuss the
-project with the engineers and community members on #openverse.
+Pull requests are welcome! Feel free to [join us on Slack][wp_slack] and discuss
+the project with the engineers and community members on #openverse.
## Acknowledgments
-Openverse, previously known as CC Search, was conceived and built at [Creative Commons](https://creativecommons.org). We thank them for their commitment to open source and openly licensed content, with particular thanks to previous team members @ryanmerkley, @janetpkr, @lizadaly, @sebworks, @pa-w, @kgodey, @annatuma, @mathemancer, @aldenstpage, @brenoferreira, and @sclachar, along with their [community of volunteers](https://opensource.creativecommons.org/community/community-team/).
+Openverse, previously known as CC Search, was conceived and built at
+[Creative Commons](https://creativecommons.org). We thank them for their
+commitment to open source and openly licensed content, with particular thanks to
+previous team members @ryanmerkley, @janetpkr, @lizadaly, @sebworks, @pa-w,
+@kgodey, @annatuma, @mathemancer, @aldenstpage, @brenoferreira, and @sclachar,
+along with their
+[community of volunteers](https://opensource.creativecommons.org/community/community-team/).
## License
- [`LICENSE`](LICENSE) (Expat/[MIT][mit] License)
-[mit]: http://www.opensource.org/licenses/MIT "The MIT License | Open Source Initiative"
+[mit]:
+ http://www.opensource.org/licenses/MIT
+ "The MIT License | Open Source Initiative"
[wp_slack]: https://make.wordpress.org/chat/
[cc]: https://creativecommons.org
[cc_community]: https://opensource.creativecommons.org/community/community-team/
diff --git a/justfile b/justfile
index 5a2035ce6..5a02d90fa 100644
--- a/justfile
+++ b/justfile
@@ -127,6 +127,10 @@ generate-dag-docs fail_on_diff="false":
DC_USER=root just run 'python openverse_catalog/utilities/dag_doc_gen/dag_doc_generation.py \&\& chmod 666 /opt/airflow/openverse_catalog/utilities/dag_doc_gen/DAGs.md'
# Move the file to the top level, since that level is not mounted into the container
mv openverse_catalog/utilities/dag_doc_gen/DAGs.md DAGs.md
+ echo -n "Running linting..."
+ # Linting step afterwards is necessary since the generated output differs greatly from what prettier expects
+ just lint &>/dev/null || true
+ echo "Done!"
if {{ fail_on_diff }}; then
set +e
git diff --exit-code DAGs.md
diff --git a/openverse_catalog/dags/common/popularity/README.md b/openverse_catalog/dags/common/popularity/README.md
index cf9771ca7..c90d679ef 100644
--- a/openverse_catalog/dags/common/popularity/README.md
+++ b/openverse_catalog/dags/common/popularity/README.md
@@ -1,16 +1,29 @@
# Popularity
-This code allows for the calculation of image popularity within a provider. For example, this allows us to boost Flickr results that have more views than others.
+This code allows for the calculation of image popularity within a provider. For
+example, this allows us to boost Flickr results that have more views than
+others.
## What this code does
1. Dump the popularity metrics for each row into a TSV.
-2. Compute the 85th percentile for each metric, which is required for the popularity calculation. This is a heavyweight database calculation, so we cache it for a really long time.
+2. Compute the 85th percentile for each metric, which is required for the
+ popularity calculation. This is a heavyweight database calculation, so we
+ cache it for a really long time.
3. Iterate through the TSV calculating the popularity for each row.
-4. UPDATE all rows, setting the `normalized_popularity` key in the `meta_data` column.
+4. UPDATE all rows, setting the `normalized_popularity` key in the `meta_data`
+ column.
## To start calculating popularity data for a provider
-1. In your provider script, store the popularity metric you'd like to track in the `meta_data` column. See [stocksnap](https://github.com/WordPress/openverse-catalog/blob/6c172033e42a91bcd8f9bf78fd6b933a70bd88bf/openverse_catalog/dags/provider_api_scripts/stocksnap.py#L175-L185) as an example.
-2. Add the provider name and metric to the `IMAGE_POPULARITY_METRICS` constant in the [popularity/sql.py](sql.py) file.
-3. Add the new provider and metric to the `INSERT INTO public.image_popularity_metrics` statement in [0004_openledger_image_view.sql](../../../../docker/local_postgres/0004_openledger_image_view.sql#L45). For now all percentiles should be set to `.85`, this may be adjusted in the future.
+1. In your provider script, store the popularity metric you'd like to track in
+ the `meta_data` column. See
+ [stocksnap](https://github.com/WordPress/openverse-catalog/blob/6c172033e42a91bcd8f9bf78fd6b933a70bd88bf/openverse_catalog/dags/provider_api_scripts/stocksnap.py#L175-L185)
+ as an example.
+2. Add the provider name and metric to the `IMAGE_POPULARITY_METRICS` constant
+ in the [popularity/sql.py](sql.py) file.
+3. Add the new provider and metric to the
+ `INSERT INTO public.image_popularity_metrics` statement in
+ [0004_openledger_image_view.sql](../../../../docker/local_postgres/0004_openledger_image_view.sql#L45).
+ For now all percentiles should be set to `.85`, this may be adjusted in the
+ future.
diff --git a/openverse_catalog/dags/oauth2/README.md b/openverse_catalog/dags/oauth2/README.md
index 40cdfced0..8e2d83eb9 100644
--- a/openverse_catalog/dags/oauth2/README.md
+++ b/openverse_catalog/dags/oauth2/README.md
@@ -2,39 +2,51 @@
## TL;DR
-- Provider secrets (e.g. `client_id`, etc.) are stored in the `OAUTH2_PROVIDER_SECRETS` Variable.
+- Provider secrets (e.g. `client_id`, etc.) are stored in the
+ `OAUTH2_PROVIDER_SECRETS` Variable.
- Authorization tokens (one time use) are stored in `OAUTH2_AUTH_KEYS`.
- Access/refresh token pairs are stored in `OAUTH2_ACCESS_TOKENS`.
-- The Authorization DAG can be run as needed to authorize (or re-authorize) providers.
-- The Token Refresh DAG is run every 12 hours and refreshes all tokens currently stored.
-- Use the [`OAuth2DelayedRequester`](../common/requester.py) in a provider API script that requires OAuth2
+- The Authorization DAG can be run as needed to authorize (or re-authorize)
+ providers.
+- The Token Refresh DAG is run every 12 hours and refreshes all tokens currently
+ stored.
+- Use the [`OAuth2DelayedRequester`](../common/requester.py) in a provider API
+ script that requires OAuth2
## Overview
-The functions and DAGs defined in this module provide a mechanism for generating and maintaining the tokens necessary for interacting with sources that require OAuth2 authentication.
+The functions and DAGs defined in this module provide a mechanism for generating
+and maintaining the tokens necessary for interacting with sources that require
+OAuth2 authentication.
OAuth2 providers are authenticated through a three-step mechanism:
+
1. Initiate authorization
2. Use authorization to create authentication tokens
3. (sometime later) Refresh the authentication tokens as needed
-The authentication tokens that are created as a result of step 2 above can be used in subsequent requests to the service to access resources that are only made available to authenticated clients.
-The expiration time for an access token differs by service.
-If a token expires before it is refreshed, the authorization step will need to be restarted from step 1.
+The authentication tokens that are created as a result of step 2 above can be
+used in subsequent requests to the service to access resources that are only
+made available to authenticated clients. The expiration time for an access token
+differs by service. If a token expires before it is refreshed, the authorization
+step will need to be restarted from step 1.
## Variables
We are using three Airflow variables to store the information related to OAuth2:
+
- `OAUTH2_PROVIDER_SECRETS`
- `OAUTH2_AUTH_KEYS`
- `OAUTH2_ACCESS_TOKENS`
### `OAUTH2_PROVIDER_SECRETS`
-This Variable holds the provider secrets which are necessary for initiating authorization.
-At minimum, this must have a `client_id` value per-provider, and different providers may require more information.
+This Variable holds the provider secrets which are necessary for initiating
+authorization. At minimum, this must have a `client_id` value per-provider, and
+different providers may require more information.
**Format**:
+
```json
{
"provider1": {
@@ -53,11 +65,13 @@ At minimum, this must have a `client_id` value per-provider, and different provi
### `OAUTH2_AUTH_KEYS`
-This Variable holds any authorization keys that are needed to generate an access/refresh token pair for a provider.
-It will typically remain empty until one (or more) providers need new keys.
-Once this Variable has been populated, the Authorization DAG can be run.
+This Variable holds any authorization keys that are needed to generate an
+access/refresh token pair for a provider. It will typically remain empty until
+one (or more) providers need new keys. Once this Variable has been populated,
+the Authorization DAG can be run.
**Format**:
+
```json
{
"provider1": "<auth_key_1>",
@@ -68,15 +82,17 @@ Once this Variable has been populated, the Authorization DAG can be run.
### `OAUTH2_ACCESS_TOKENS`
This variable holds the access/refresh token pairs for all authorized providers.
-These values are updated automatically and **should not** need to be touched/modified directly.
-The Authorization DAG and Token Refresh DAG will populate it.
+These values are updated automatically and **should not** need to be
+touched/modified directly. The Authorization DAG and Token Refresh DAG will
+populate it.
**Format**:
+
```json
{
"provider1": {
"access_token": "<p_1_access>",
- "refresh_token": "<p_1_refresh>",
+ "refresh_token": "<p_1_refresh>"
},
"provider2": {
"access_token": "<p_2_access>",
@@ -91,26 +107,30 @@ The Authorization DAG and Token Refresh DAG will populate it.
**File:** [`authorize_dag.py`](authorize_dag.py)
-This DAG will use any available authorization tokens to generate an access/refresh token pair for a provider.
-It is run as-needed once the appropriate Variable has been updated.
+This DAG will use any available authorization tokens to generate an
+access/refresh token pair for a provider. It is run as-needed once the
+appropriate Variable has been updated.
### Token Refresh DAG
**File:** [`token_refresh_dag.py`](token_refresh_dag.py)
-This DAG refreshes the access/token pairs for all providers.
-In order to prevent tokens from expiring, it is scheduled every 12 hours.
+This DAG refreshes the access/token pairs for all providers. In order to prevent
+tokens from expiring, it is scheduled every 12 hours.
-If a provider is defined but it does not have any access/token pairs entered, the task for that provider will be skipped.
-If a provider's keys have expired, the refresh (and the task) will fail.
+If a provider is defined but it does not have any access/token pairs entered,
+the task for that provider will be skipped. If a provider's keys have expired,
+the refresh (and the task) will fail.
## Authorization URLs
-Each provider uses a different base URL for initiating the authorization process.
-This library can assist with generating a `client_id`-specific URL for each provider.
-In order to create an authorization URL, the provider's secrets must be present (see [above](#oauth2_provider_secrets)).
+Each provider uses a different base URL for initiating the authorization
+process. This library can assist with generating a `client_id`-specific URL for
+each provider. In order to create an authorization URL, the provider's secrets
+must be present (see [above](#oauth2_provider_secrets)).
Example:
+
```python
In [1]: import oauth2
@@ -124,9 +144,11 @@ Out[3]:
### Known Authorization URLs:
-1. [Freesound](https://freesound.org/docs/api/authentication.html#oauth2-authentication): https://freesound.org/apiv2/oauth2/authorize/
+1. [Freesound](https://freesound.org/docs/api/authentication.html#oauth2-authentication):
+ https://freesound.org/apiv2/oauth2/authorize/
## Integration with Provider API Scripts
-Once everything is set up for an OAuth2 provider, the [`OAuth2DelayedRequester`](../common/requester.py) can be used instead of the `DelayedRequester` for the provider API script.
-No other changes are necessary!
+Once everything is set up for an OAuth2 provider, the
+[`OAuth2DelayedRequester`](../common/requester.py) can be used instead of the
+`DelayedRequester` for the provider API script. No other changes are necessary!
diff --git a/openverse_catalog/dags/retired/README.md b/openverse_catalog/dags/retired/README.md
index d2a0c4fef..5563ff620 100644
--- a/openverse_catalog/dags/retired/README.md
+++ b/openverse_catalog/dags/retired/README.md
@@ -1,4 +1,6 @@
# Retired DAGs
-This folder contains DAGs that were either one-offs or are no longer relevant to current processes, but are useful to keep around for potential future use-cases.
-DAGs in this folder are excluded from Airflow's DAG parsing and will not be shown in the UI.
+This folder contains DAGs that were either one-offs or are no longer relevant to
+current processes, but are useful to keep around for potential future use-cases.
+DAGs in this folder are excluded from Airflow's DAG parsing and will not be
+shown in the UI.
diff --git a/openverse_catalog/docs/adding_a_new_provider.md b/openverse_catalog/docs/adding_a_new_provider.md
index e2b4860a9..c3d3c2e23 100644
--- a/openverse_catalog/docs/adding_a_new_provider.md
+++ b/openverse_catalog/docs/adding_a_new_provider.md
@@ -2,35 +2,56 @@
## Overview
-The Openverse Catalog collects data from the APIs of sites that share openly-licensed media, and saves them in our Catalog database. This process is automated by [Airflow DAGs](https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html) generated for each provider. A simple provider DAG looks like this:
+The Openverse Catalog collects data from the APIs of sites that share
+openly-licensed media, and saves them in our Catalog database. This process is
+automated by
+[Airflow DAGs](https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html)
+generated for each provider. A simple provider DAG looks like this:
![Example DAG](assets/provider_dags/simple_dag.png)
At a high level the steps are:
-1. `generate_filename`: Generates the named of a TSV (tab-separated values) text file that will be used for saving the data to the disk in later steps
-2. `pull_data`: Pulls records from the provider API, collects just the data we need, and commits it to local storage in TSVs.
-3. `load_data`: Loads the data from TSVs into the Catalog database, updating old records and discarding duplicates.
+1. `generate_filename`: Generates the named of a TSV (tab-separated values) text
+ file that will be used for saving the data to the disk in later steps
+2. `pull_data`: Pulls records from the provider API, collects just the data we
+ need, and commits it to local storage in TSVs.
+3. `load_data`: Loads the data from TSVs into the Catalog database, updating old
+ records and discarding duplicates.
4. `report_load_completion`: Reports a summary of added and updated records.
-When a provider supports multiple media types (for example, `audio` *and* `images`), the `pull` step consumes data of all types, but separate `load` steps are generated:
+When a provider supports multiple media types (for example, `audio` _and_
+`images`), the `pull` step consumes data of all types, but separate `load` steps
+are generated:
![Example Multi-Media DAG](assets/provider_dags/multi_media_dag.png)
## Adding a New Provider
-Adding a new provider to Openverse means adding a new provider DAG. Fortunately, our DAG factories automate most of this process. To generate a fully functioning provider DAG, you need to:
+Adding a new provider to Openverse means adding a new provider DAG. Fortunately,
+our DAG factories automate most of this process. To generate a fully functioning
+provider DAG, you need to:
1. Implement a `ProviderDataIngester`
2. Add a `ProviderWorkflow` configuration class
### Implementing a `ProviderDataIngester` class
-We call the code that pulls data from our provider APIs "Provider API scripts". You can find examples in [`provider_api_scripts` folder](../dags/providers/provider_api_scripts). This code will be run during the `pull` steps of the provider DAG.
+We call the code that pulls data from our provider APIs "Provider API scripts".
+You can find examples in
+[`provider_api_scripts` folder](../dags/providers/provider_api_scripts). This
+code will be run during the `pull` steps of the provider DAG.
-At a high level, a provider script should iteratively request batches of records from the provider API, extract data in the format required by Openverse, and commit it to local storage. Much of this logic is implemented in a [`ProviderDataIngester` base class](../dags/providers/provider_api_scripts/provider_data_ingester.py) (which also provides additional testing features *<TODO: link to documentation for testing features like ingestion_limit, skip_ingestion_errors etc>*). To add a new provider, extend this class and implement its abstract methods.
+At a high level, a provider script should iteratively request batches of records
+from the provider API, extract data in the format required by Openverse, and
+commit it to local storage. Much of this logic is implemented in a
+[`ProviderDataIngester` base class](../dags/providers/provider_api_scripts/provider_data_ingester.py)
+(which also provides additional testing features _<TODO: link to documentation
+for testing features like ingestion_limit, skip_ingestion_errors etc>_). To add
+a new provider, extend this class and implement its abstract methods.
-We provide a [script](../dags/templates/create_provider_ingester.py) that can be used to generate the files you'll need and get you started:
+We provide a [script](../dags/templates/create_provider_ingester.py) that can be
+used to generate the files you'll need and get you started:
```
# PROVIDER_NAME: The name of the provider
@@ -53,6 +74,7 @@ We provide a [script](../dags/templates/create_provider_ingester.py) that can be
```
You should see output similar to this:
+
```
Creating files in /Users/staci/projects/openverse-projects/openverse-catalog
API script: openverse-catalog/openverse_catalog/dags/providers/provider_api_scripts/foobar_museum.py
@@ -61,19 +83,31 @@ API script test: openverse-catalog/tests/dags/providers/provider_api_scripts/t
NOTE: You will also need to add a new ProviderWorkflow dataclass configuration to the PROVIDER_WORKFLOWS list in `openverse-catalog/dags/providers/provider_workflows.py`.
```
-This generates a provider script with a templated `ProviderDataIngester` for you in the [`provider_api_scripts` folder](../dags/providers/provider_api_scripts), as well as a corresponding test file. Complete the TODOs detailed in the generated files to implement behavior specific to your API.
-
-Some APIs may not fit perfectly into the established `ProviderDataIngester` pattern. For advanced use cases and examples of how to modify the ingestion flow, see the [`ProviderDataIngester` FAQ](provider_data_ingester_faq.md).
+This generates a provider script with a templated `ProviderDataIngester` for you
+in the [`provider_api_scripts` folder](../dags/providers/provider_api_scripts),
+as well as a corresponding test file. Complete the TODOs detailed in the
+generated files to implement behavior specific to your API.
+Some APIs may not fit perfectly into the established `ProviderDataIngester`
+pattern. For advanced use cases and examples of how to modify the ingestion
+flow, see the [`ProviderDataIngester` FAQ](provider_data_ingester_faq.md).
### Add a `ProviderWorkflow` configuration class
-Now that you have an ingester class, you're ready to wire up a provider DAG in Airflow to automatically pull data and load it into our Catalog database. This is done by defining a `ProviderWorkflow` configuration dataclass and adding it to the `PROVIDER_WORKFLOWS` list in [`provider_workflows.py`](../dags/providers/provider_workflows.py). Our DAG factories will pick up the configuration and generate a complete new DAG in Airflow!
+Now that you have an ingester class, you're ready to wire up a provider DAG in
+Airflow to automatically pull data and load it into our Catalog database. This
+is done by defining a `ProviderWorkflow` configuration dataclass and adding it
+to the `PROVIDER_WORKFLOWS` list in
+[`provider_workflows.py`](../dags/providers/provider_workflows.py). Our DAG
+factories will pick up the configuration and generate a complete new DAG in
+Airflow!
At minimum, you'll need to provide the following in your configuration:
-* `ingester_class`: the `ProviderDataIngester` class itself
+
+- `ingester_class`: the `ProviderDataIngester` class itself
Example:
+
```python
# In openverse_catalog/dags/providers/provider_workflows.py
from providers.provider_api_scripts.foobar_museum import FoobarMuseumDataIngester
@@ -88,8 +122,15 @@ PROVIDER_WORKFLOWS = [
]
```
-There are many other options that allow you to tweak the `schedule` (when and how often your DAG is run), timeouts for individual steps of the DAG, and more. These are documented in the definition of the `ProviderWorkflow` dataclass. *<TODO: add docs for other options.>*
+There are many other options that allow you to tweak the `schedule` (when and
+how often your DAG is run), timeouts for individual steps of the DAG, and more.
+These are documented in the definition of the `ProviderWorkflow` dataclass.
+_<TODO: add docs for other options.>_
-After adding your configuration, run `just up` and you should now have a fully functioning provider DAG! *<TODO: add and link to docs for how to run provider DAGs locally, preferably with images.>*
+After adding your configuration, run `just up` and you should now have a fully
+functioning provider DAG! _<TODO: add and link to docs for how to run provider
+DAGs locally, preferably with images.>_
-*NOTE*: when your code is merged, the DAG will become available in production but will be disabled by default. A contributor with Airflow access will need to manually turn the DAG on in production.
+_NOTE_: when your code is merged, the DAG will become available in production
+but will be disabled by default. A contributor with Airflow access will need to
+manually turn the DAG on in production.
diff --git a/openverse_catalog/docs/data_models.md b/openverse_catalog/docs/data_models.md
index ec48aff13..43482fff8 100644
--- a/openverse_catalog/docs/data_models.md
+++ b/openverse_catalog/docs/data_models.md
@@ -1,57 +1,61 @@
-*<TODO: This documentation is temporary and should be replaced by more thorough documentation of our DB fields in https://github.com/WordPress/openverse-catalog/issues/783>*
+_<TODO: This documentation is temporary and should be replaced by more thorough
+documentation of our DB fields in
+https://github.com/WordPress/openverse-catalog/issues/783>_
# Data Models
-The following is temporary, limited documentation of the columns for each of our Catalog data models.
+The following is temporary, limited documentation of the columns for each of our
+Catalog data models.
## Required Fields
-| field name | description |
-| --- | --- |
-| *foreign_identifier* | Unique identifier for the record on the source site. |
-| *foreign_landing_url* | URL of page where the record lives on the source website. |
-| *audio_url* / *image_url* | Direct link to the media file. Note that until [issue #784 is addressed](https://github.com/WordPress/openverse-catalog/issues/784) the field name differs depending on media type. |
-| *license_info* | [LicenseInfo object](https://github.com/WordPress/openverse-catalog/blob/8423590fd86a0a3272ca91bc11f2f37979048181/openverse_catalog/dags/common/licenses/licenses.py#L25) that has (1) the URL of the license for the record, (2) string representation of the license, (3) version of the license, (4) raw license URL that was by provider, if different from canonical URL. Usually generated by calling [`get_license_info`](https://github.com/WordPress/openverse-catalog/blob/8423590fd86a0a3272ca91bc11f2f37979048181/openverse_catalog/dags/common/licenses/licenses.py#L29) on respective fields returns/available from the API. |
+| field name | description |
+| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| _foreign_identifier_ | Unique identifier for the record on the source site. |
+| _foreign_landing_url_ | URL of page where the record lives on the source website. |
+| _audio_url_ / _image_url_ | Direct link to the media file. Note that until [issue #784 is addressed](https://github.com/WordPress/openverse-catalog/issues/784) the field name differs depending on media type. |
+| _license_info_ | [LicenseInfo object](https://github.com/WordPress/openverse-catalog/blob/8423590fd86a0a3272ca91bc11f2f37979048181/openverse_catalog/dags/common/licenses/licenses.py#L25) that has (1) the URL of the license for the record, (2) string representation of the license, (3) version of the license, (4) raw license URL that was by provider, if different from canonical URL. Usually generated by calling [`get_license_info`](https://github.com/WordPress/openverse-catalog/blob/8423590fd86a0a3272ca91bc11f2f37979048181/openverse_catalog/dags/common/licenses/licenses.py#L29) on respective fields returns/available from the API. |
## Optional Fields
-The following fields are optional, but it is highly encouraged to populate as much data as possible:
-
-| field name | description |
-| --- | --- |
-| *thumbnail_url* | Direct link to a thumbnail-sized version of the record. |
-| *filesize* | Size of the main file in bytes. |
-| *filetype* | The filetype of the main file, eg. 'mp3', 'jpg', etc. |
-| *creator* | The creator of the image. |
-| *creator_url* | The user page, or home page of the creator. |
-| *title* | Title of the record. |
-| *meta_data* | Dictionary of metadata about the record. Currently, a key we prefer to have is `description`. |
-| *raw_tags* | List of tags associated with the record. |
-| *watermarked* | Boolean, true if the record has a watermark. |
+The following fields are optional, but it is highly encouraged to populate as
+much data as possible:
+
+| field name | description |
+| --------------- | --------------------------------------------------------------------------------------------- |
+| _thumbnail_url_ | Direct link to a thumbnail-sized version of the record. |
+| _filesize_ | Size of the main file in bytes. |
+| _filetype_ | The filetype of the main file, eg. 'mp3', 'jpg', etc. |
+| _creator_ | The creator of the image. |
+| _creator_url_ | The user page, or home page of the creator. |
+| _title_ | Title of the record. |
+| _meta_data_ | Dictionary of metadata about the record. Currently, a key we prefer to have is `description`. |
+| _raw_tags_ | List of tags associated with the record. |
+| _watermarked_ | Boolean, true if the record has a watermark. |
#### Image-specific fields
Image also has the following fields:
-| field_name | description |
-| --- | --- |
-| *width* | Image width in pixels. |
-| *height* | Image height in pixels. |
+| field_name | description |
+| ---------- | ----------------------- |
+| _width_ | Image width in pixels. |
+| _height_ | Image height in pixels. |
#### Audio-specific fields
Audio has the following fields:
-| field_name | description |
-| --- | --- |
-| *duration* | Audio duration in milliseconds. |
-| *bit_rate* | Audio bit rate as int. |
-| *sample_rate* | Audio sample rate as int. |
-| *category* | Category such as 'music', 'sound', 'audio_book', or 'podcast'. |
-| *genres* | List of genres. |
-| *set_foreign_id* | Unique identifier for the audio set on the source site. |
-| *audio_set* | The name of the set (album, pack, etc) the audio is part of. |
-| *set_position* | Position of the audio in the audio_set. |
-| *set_thumbnail* | URL of the audio_set thumbnail. |
-| *set_url* | URL of the audio_set. |
-| *alt_files* | A dictionary with information about alternative files for the audio (different formats/quality). Dict should have the following keys: *url*, *filesize*, *bit_rate*, *sample_rate*.
+| field_name | description |
+| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| _duration_ | Audio duration in milliseconds. |
+| _bit_rate_ | Audio bit rate as int. |
+| _sample_rate_ | Audio sample rate as int. |
+| _category_ | Category such as 'music', 'sound', 'audio_book', or 'podcast'. |
+| _genres_ | List of genres. |
+| _set_foreign_id_ | Unique identifier for the audio set on the source site. |
+| _audio_set_ | The name of the set (album, pack, etc) the audio is part of. |
+| _set_position_ | Position of the audio in the audio_set. |
+| _set_thumbnail_ | URL of the audio_set thumbnail. |
+| _set_url_ | URL of the audio_set. |
+| _alt_files_ | A dictionary with information about alternative files for the audio (different formats/quality). Dict should have the following keys: _url_, _filesize_, _bit_rate_, _sample_rate_. |
diff --git a/openverse_catalog/docs/provider_data_ingester_faq.md b/openverse_catalog/docs/provider_data_ingester_faq.md
index 612cf7bd8..9adb39798 100644
--- a/openverse_catalog/docs/provider_data_ingester_faq.md
+++ b/openverse_catalog/docs/provider_data_ingester_faq.md
@@ -1,19 +1,30 @@
# ProviderDataIngester FAQ
-The most straightforward implementation of a `ProviderDataIngester` repeats the following process:
+The most straightforward implementation of a `ProviderDataIngester` repeats the
+following process:
-* Builds a set of query params for the next request, based upon the previous params (for example, by updating offsets or page numbers)
-* Makes a single GET request to the configured static `endpoint` using the built params
-* Extracts a "batch" of records from the response, as a list of record JSON representations
-* Iterates over the records in the batch, extracting desired data, and commits them to local storage
+- Builds a set of query params for the next request, based upon the previous
+ params (for example, by updating offsets or page numbers)
+- Makes a single GET request to the configured static `endpoint` using the built
+ params
+- Extracts a "batch" of records from the response, as a list of record JSON
+ representations
+- Iterates over the records in the batch, extracting desired data, and commits
+ them to local storage
-Some provider APIs may not fit neatly into this workflow. This document addresses some common use cases.
+Some provider APIs may not fit neatly into this workflow. This document
+addresses some common use cases.
## How do I process a provider "record" that contains data about multiple records?
-**Example**: You're pulling data from a Museum database, and each "record" in a batch contains multiple photos of a single physical object.
+**Example**: You're pulling data from a Museum database, and each "record" in a
+batch contains multiple photos of a single physical object.
-**Solution**: The `get_record_data` method takes a `data` object representing a single record from the provider API. Typically, it extracts required data and returns it as a single dict. However, it can also return a **list of dictionaries** for cases like the one described, where multiple Openverse records can be extracted.
+**Solution**: The `get_record_data` method takes a `data` object representing a
+single record from the provider API. Typically, it extracts required data and
+returns it as a single dict. However, it can also return a **list of
+dictionaries** for cases like the one described, where multiple Openverse
+records can be extracted.
```python
def get_record_data(self, data: dict) -> dict | list[dict] | None:
@@ -31,9 +42,13 @@ def get_record_data(self, data: dict) -> dict | list[dict] | None:
## What if I can't get all the necessary information for a record from a single API request?
-**Example**: A provider's `search` endpoint returns a list of image records containing *most* of the information we need for each record, but not image dimensions. This information *is* available via the API by hitting a `details` endpoint for a given image, though.
+**Example**: A provider's `search` endpoint returns a list of image records
+containing _most_ of the information we need for each record, but not image
+dimensions. This information _is_ available via the API by hitting a `details`
+endpoint for a given image, though.
-**Solution**: In this case, you can reuse the `get_response_json` method by passing in the endpoint you need:
+**Solution**: In this case, you can reuse the `get_response_json` method by
+passing in the endpoint you need:
```python
def get_record_data(self, data: dict) -> dict | list[dict] | None:
@@ -48,13 +63,16 @@ def get_record_data(self, data: dict) -> dict | list[dict] | None:
...
```
-**NOTE**: When doing this, keep in mind that adding too many requests may slow down ingestion. Be aware of rate limits from your provider API as well.
+**NOTE**: When doing this, keep in mind that adding too many requests may slow
+down ingestion. Be aware of rate limits from your provider API as well.
## What if my API endpoint isn't static and needs to change from one request to another?
-**Example**: Rather than passing a `page` number in query parameters, a provider expects the `page` as part of the endpoint path itself.
+**Example**: Rather than passing a `page` number in query parameters, a provider
+expects the `page` as part of the endpoint path itself.
-**Solution**: If your `endpoint` needs to change, you can implement it as a `property`:
+**Solution**: If your `endpoint` needs to change, you can implement it as a
+`property`:
```python
@property
@@ -63,7 +81,10 @@ def endpoint(self) -> str:
return f"https://foobar.museum.org/images/page/{self.page_number}"
```
-In this example, `self.page_number` is an instance variable that gets updated after each request. To set up the instance variable you can override `__init__`, **being careful to remember to call `super` and pass through kwargs**, and then update it in `get_next_query_params`:
+In this example, `self.page_number` is an instance variable that gets updated
+after each request. To set up the instance variable you can override `__init__`,
+**being careful to remember to call `super` and pass through kwargs**, and then
+update it in `get_next_query_params`:
```python
def __init__(self, *args, **kwargs):
@@ -92,9 +113,14 @@ Now each time `get_batch` is called, the `endpoint` is correctly updated.
## How do I run ingestion for a set of discrete categories?
-**Example**: My provider has some set of categories that I'd like to iterate over and ingest data for. E.g., a particular audio provider's search endpoint requires you specify whether you're searching for "podcasts", "music", etc. I'd like to iterate over all the available categories and run ingestion for each.
+**Example**: My provider has some set of categories that I'd like to iterate
+over and ingest data for. E.g., a particular audio provider's search endpoint
+requires you specify whether you're searching for "podcasts", "music", etc. I'd
+like to iterate over all the available categories and run ingestion for each.
-**Solution**: You can do this by overriding the `ingest_records` method, which accepts optional `kwargs` that it passes through on each call to `get_next_query_params`. This is best demonstrated with code:
+**Solution**: You can do this by overriding the `ingest_records` method, which
+accepts optional `kwargs` that it passes through on each call to
+`get_next_query_params`. This is best demonstrated with code:
```python
CATEGORIES = ["music", "audio_book", "podcast"]
@@ -120,9 +146,12 @@ This will result in the ingestion function running once for each category.
## What if I need to do more complex processing to get a batch?
-**Example**: A single GET request is insufficient to get a batch from a provider. Instead, several requests need to be made in sequence until a "batchcomplete" token is encountered.
+**Example**: A single GET request is insufficient to get a batch from a
+provider. Instead, several requests need to be made in sequence until a
+"batchcomplete" token is encountered.
-**Solution**: You can override `get_response_json` in order to implement more complex behavior.
+**Solution**: You can override `get_response_json` in order to implement more
+complex behavior.
```python
# Psuedo code serves as an example
diff --git a/openverse_catalog/utilities/README.md b/openverse_catalog/utilities/README.md
index 2ce663418..32070e604 100644
--- a/openverse_catalog/utilities/README.md
+++ b/openverse_catalog/utilities/README.md
@@ -1,4 +1,6 @@
# Utilities
-This folder contains utilities that may be run in the dev environment (e.g. devex utilities, documentation generation, etc.).
-This folder is not mounted into the container in production and thus will not be available or accessible in that environment.
+This folder contains utilities that may be run in the dev environment (e.g.
+devex utilities, documentation generation, etc.). This folder is not mounted
+into the container in production and thus will not be available or accessible in
+that environment.
diff --git a/prettier.config.js b/prettier.config.js
index b48775a1a..7b0c36b47 100644
--- a/prettier.config.js
+++ b/prettier.config.js
@@ -3,15 +3,16 @@
// - https://github.com/WordPress/openverse/blob/main/prettier.config.js.jinja
module.exports = {
- trailingComma: 'es5',
+ trailingComma: "es5",
tabWidth: 2,
semi: false,
- singleQuote: true,
+ singleQuote: false,
+ proseWrap: "always",
overrides: [
{
- files: '*.yml',
+ files: "*.yml",
options: {
- singleQuote: false,
+ proseWrap: "preserve",
},
},
],