Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Merge catalog into monorepo
Dhruv Bhanushali697f62f01a32
diff --cc .github/CODEOWNERSindex 512d9703f,6ab1d44af..1ec9bbb84--- a/.github/CODEOWNERS+++ b/.github/CODEOWNERS@@@ -1,36 -1,2 +1,40 @@@-# All files are owned by the [Openverse Catalog team](https://github.com/orgs/WordPress/teams/openverse-catalog)-* @WordPress/openverse-catalog++catalog/ @WordPress/openverse-catalog++archive/ @WordPress/openverse-catalog+++api/ @WordPress/openverse-api+ingestion_server/ @WordPress/openverse-api+nginx/ @WordPress/openverse-api+postgres/ @WordPress/openverse-api+sample_data/ @WordPress/openverse-api+.flake8 @WordPress/openverse-api+.isort.cfg @WordPress/openverse-api+docker-compose.yml @WordPress/openverse-api+load_sample_data.sh @WordPress/openverse-api++frontend/ @WordPress/openverse-frontend+.eslintignore @WordPress/openverse-frontend+.eslintrc.js @WordPress/openverse-frontend+.npmrc @WordPress/openverse-frontend+.pnpmfile.cjs @WordPress/openverse-frontend+package.json @WordPress/openverse-frontend+pnpm-lock.yaml @WordPress/openverse-frontend+pnpm-workspace.yaml @WordPress/openverse-frontend+prettier.config.js @WordPress/openverse-frontend+.prettierignore @WordPress/openverse-frontend++automations/ @WordPress/openverse-maintainers+brand/ @WordPress/openverse-maintainers+dead_links/ @WordPress/openverse-maintainers++docker/ @WordPress/openverse-maintainers+documentation/ @WordPress/openverse-maintainers+readme_assets/ @WordPress/openverse-maintainers+templates/ @WordPress/openverse-maintainers+.gitattributes @WordPress/openverse-maintainers+.gitignore @WordPress/openverse-maintainers+.github/ @WordPress/openverse-maintainers+.pre-commit-config.yaml @WordPress/openverse-maintainers+CODE_OF_CONDUCT.md @WordPress/openverse-maintainers+CONTRIBUTING.md @WordPress/openverse-maintainers+justfile @WordPress/openverse-maintainers+LICENSE @WordPress/openverse-maintainers+README.md @WordPress/openverse-maintainersdiff --cc .github/PULL_REQUEST_TEMPLATE/pull_request_template.mdindex dc5a5773b,3a9367c29..67075a713--- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md+++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md@@@ -28,6 -28,7 +28,7 @@@ Fixes #[issue number] by @[issue author- [ ] I added or updated documentation (if applicable).- [ ] I tried running the project locally and verified that there are no visibleerrors.-- [ ] I ran the DAG documentation generator (if applicable).++- [ ] I ran the DAG documentation generator (only applicable for catalog PRs).[best_practices]:https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelinesdiff --cc .github/actions/get-changes/action.ymlindex 9cdd64c8f,000000000..9922ab97cmode 100644,000000..100644--- a/.github/actions/get-changes/action.yml+++ b/.github/actions/get-changes/action.yml@@@ -1,34 -1,0 +1,37 @@@+name: openverse/get-changes+description: Determine where changes happened in the repository++outputs:+ changes:+ description: "JSON array of keys from `.github/filters.yml`"+ value: ${{ steps.paths-filter.outputs.changes }}++ catalog:++ description: "'true' if catalog changes are present"++ value: ${{ steps.paths-filter.outputs.catalog }}+ api:+ description: "'true' if API changes are present"+ value: ${{ steps.paths-filter.outputs.api }}+ ingestion_server:+ description: "'true' if ingestion server changes are present"+ value: ${{ steps.paths-filter.outputs.ingestion_server }}+ frontend:+ description: "'true' if frontend changes are present"+ value: ${{ steps.paths-filter.outputs.frontend }}+ documentation:+ description: "'true' if documentation changes are present"+ value: ${{ steps.paths-filter.outputs.documentation }}+ lint:+ description: "'true' if linting setup changes are present"+ value: ${{ steps.paths-filter.outputs.frontend }}++runs:+ using: "composite"+ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - id: paths-filter+ name: Check changed paths+ uses: dorny/paths-filter@v2+ with:+ filters: ./.github/filters.ymldiff --cc .github/actions/load-img/action.ymlindex 488703e7d,000000000..c73bd9458mode 100644,000000..100644--- a/.github/actions/load-img/action.yml+++ b/.github/actions/load-img/action.yml@@@ -1,42 -1,0 +1,60 @@@+name: openverse/load-img+description: Download and import Docker images from artifacts++inputs:+ setup_ingestion_server:+ default: "true"+ description: Whether to set up ingestion server image++ setup_api:+ default: "true"+ description: Whether to set up API image+++ setup_catalog:++ default: "true"++ description: Whether to set up catalog image+++runs:+ using: "composite"+ steps:++ # Catalog++ - name: Download image `catalog`++ uses: actions/download-artifact@v3++ if: inputs.setup_catalog == 'true'++ with:++ name: catalog++ path: /tmp++++ - name: Load image `catalog`++ if: inputs.setup_catalog == 'true'++ shell: bash++ run: |++ docker load --input /tmp/catalog.tar+++ # Ingestion server+ - name: Download image `ingestion_server`+ uses: actions/download-artifact@v3+ if: inputs.setup_ingestion_server == 'true'+ with:+ name: ingestion_server+ path: /tmp++ - name: Load image `ingestion_server`+ if: inputs.setup_ingestion_server == 'true'+ shell: bash+ run: |+ docker load --input /tmp/ingestion_server.tar++ # API+ - name: Download image `api`+ uses: actions/download-artifact@v3+ if: inputs.setup_api == 'true'+ with:+ name: api+ path: /tmp++ - name: Load image `api`+ if: inputs.setup_api == 'true'+ shell: bash+ run: |+ docker load --input /tmp/api.tardiff --cc .github/dependabot.ymlindex bb7065954,a4c40ca99..17f599ac4--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@@ -6,36 -6,23 +6,55 @@@version: 2updates:- # Enable version updates for Python libraries in `requirements_dev.txt`- # These can be updated more frequently than those in `requirements_prod.txt` since- # they are not pinned by the Airflow constraints file.+ # Enable version updates for Python libs in Openverse API- package-ecosystem: pip- directory: /+ # Look for a `Pipfile` in the `/api` directory+ directory: /api+ # Check for updates once a month+ schedule:+ interval: monthly+ labels:+ - "π» aspect: code"+ - "π§° goal: internal improvement"+ - "π© priority: low"+ - "π tech: python"+ - "π§± stack: api"+ - dependencies++ # Enable version updates for Python libs in ingestion server+ - package-ecosystem: pip+ # Look for a `Pipfile` in the `/ingestion_server` directory+ directory: /ingestion_server+ # Check for updates once a month+ schedule:+ interval: monthly+ labels:+ - "π» aspect: code"+ - "π§° goal: internal improvement"+ - "π© priority: low"+ - "π tech: python"+ - "π§± stack: ingestion server"+ - dependencies+++ # Enable version updates for Python dev-libs in the calalog++ #++ # `requirements-dev.txt` can be updated more frequently than++ # `requirements_prod.txt` since they are not pinned by the Airflow constraints++ # file.++ - package-ecosystem: pip++ # Look for requirements file in the `/ingestion_server` directory++ directory: /catalog+ # Check for updates once a month+ schedule:+ interval: monthly- open-pull-requests-limit: 10+ labels:+ - "π» aspect: code"+ - "π§° goal: internal improvement"+ - "π© priority: low"+ - "π tech: python"+ - "π§± stack: catalog"+ - dependencies+- package-ecosystem: "github-actions"directory: /schedule:diff --cc .github/filters.ymlindex f541892b8,000000000..2bc13e6aamode 100644,000000..100644--- a/.github/filters.yml+++ b/.github/filters.yml@@@ -1,27 -1,0 +1,31 @@@++catalog:++ - catalog/**++ # Change to the CI + CD workflow should trigger complete workflow.++ - .github/workflows/ci_cd.yml+api:+ - api/**+ # Change to the CI + CD workflow should trigger complete workflow.+ - .github/workflows/ci_cd.yml+ingestion_server:+ - ingestion_server/**+ # Change to the CI + CD workflow should trigger complete workflow.+ - .github/workflows/ci_cd.yml+frontend:+ - frontend/**+ - package.json+ - pnpm-lock.yaml+ - pnpm-workspace.yaml+ - .npmrc+ - .pnpmfile.cjs+ # Change to the CI + CD workflow should trigger complete workflow.+ - .github/workflows/ci_cd.yml+documentation:+ - documentation/**+ # Change to the CI + CD workflow should trigger complete workflow.+ - .github/workflows/ci_cd.yml+lint:+ - prettier.config.js+ - .prettierignore+ - .eslintrc.js+ - .eslintignore+ - .pre-commit-config.yamldiff --cc .github/workflows/ci_cd.ymlindex d723a3eb1,31a9d0d50..f28b8e60b--- a/.github/workflows/ci_cd.yml+++ b/.github/workflows/ci_cd.yml@@@ -20,119 -19,25 +20,124 @@@ concurrencycancel-in-progress: ${{ github.event_name == 'pull_request' }}jobs:- lint:- name: Lint+ ###########+ # Helpers #+ ###########++ get-changes:+ name: Get changesruns-on: ubuntu-latest+ permissions:+ pull-requests: read+ outputs:++ catalog: ${{ steps.paths-filter.outputs.catalog }}+ api: ${{ steps.paths-filter.outputs.api }}+ ingestion_server: ${{ steps.paths-filter.outputs.ingestion_server }}+ frontend: ${{ steps.paths-filter.outputs.frontend }}+ documentation: ${{ steps.paths-filter.outputs.documentation }}+ changes: ${{ steps.paths-filter.outputs.changes }}steps:- name: Checkout repositoryuses: actions/checkout@v3- - uses: extractions/setup-just@v1+ - name: Get changes+ id: paths-filter+ uses: ./.github/actions/get-changes++ get-image-tag:+ name: Get image tag+ runs-on: ubuntu-latest+ outputs:+ image_tag: ${{ steps.get-image-tag.outputs.image_tag }}++ steps:+ - name: Get image tag+ id: get-image-tag+ run: |+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then+ echo "image_tag=${{ inputs.image_tag }}" >> "$GITHUB_OUTPUT"+ else+ echo "image_tag=${{ github.sha }}" >> "$GITHUB_OUTPUT"+ fi++ determine-images:+ name: Determine images to build and publish+ runs-on: ubuntu-latest+ outputs:+ do_build: ${{ steps.set-matrix.outputs.do_build }}+ build_matrix: ${{ steps.set-matrix.outputs.build_matrix }}+ do_publish: ${{ steps.set-matrix.outputs.do_publish }}+ publish_matrix: ${{ steps.set-matrix.outputs.publish_matrix }}+ needs:+ - get-changes++ steps:+ - name: Set matrix images+ id: set-matrixenv:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ CHANGES: ${{ needs.get-changes.outputs.changes }}+ shell: python+ run: |+ import json+ import os+ import sys++ changes = json.loads(os.environ.get('CHANGES'))- - name: Get Python version- id: python-version- run: echo "value=$(just catalog/py-version)" >> "$GITHUB_OUTPUT"+ build_matrix = {"image": [], "include": []}+ publish_matrix = {"image": []}- - name: Setup Python- uses: actions/setup-python@v4+ if "frontend" in changes:+ build_matrix["image"].append("frontend")+ build_matrix["include"].append({"image": "frontend", "context": "frontend", "target": "app"})+ publish_matrix["image"].append("frontend")++ if "catalog" in changes:++ build_matrix["image"].append("catalog")++ build_matrix["include"].append({"image": "catalog", "context": "catalog", "target": "cat"})++ publish_matrix["image"].append("catalog")+ if "api" in changes or "ingestion_server" in changes:+ # Always build the ingestion server and API images for either changeset+ build_matrix["image"] += ["api", "ingestion_server"]+ build_matrix["include"] += [+ {"image": "ingestion_server", "context": "ingestion_server", "target": "ing"},+ {"image": "api", "context": "api", "target": "api"},+ ]+ if "api" in changes:+ build_matrix["image"].append("api_nginx")+ build_matrix["include"].append({"image": "api_nginx", "context": "api", "target": "nginx"})+ publish_matrix["image"] += ["api", "api_nginx"]+ if "ingestion_server" in changes:+ publish_matrix["image"].append("ingestion_server")++ do_build = 'true' if len(build_matrix["image"]) else 'false'+ do_publish = 'true' if len(publish_matrix["image"]) else 'false'++ with open(os.environ.get("GITHUB_OUTPUT"), "a") as gh_out:+ for dest in [sys.stdout, gh_out]:+ print(f"do_build={do_build}", file=dest)+ print(f"build_matrix={json.dumps(build_matrix)}", file=dest)+ print(f"do_publish={do_publish}", file=dest)+ print(f"publish_matrix={json.dumps(publish_matrix)}", file=dest)++ #############+ # Universal #+ #############++ lint: # This includes type-checking of the frontend.+ name: Lint files+ runs-on: ubuntu-latest++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-envwith:- python-version: "${{ steps.python-version.outputs.value }}"+ # Python is not needed to run pre-commit.+ setup_python: false+ # Node.js is needed by lint actions.+ install_recipe: "node-install"- name: Cache pre-commit envsuses: actions/cache@v3@@@ -190,524 -57,94 +195,611 @@@- name: Checkout repositoryuses: actions/checkout@v3- # βΉοΈStep only applies for frontend image.- - uses: extractions/setup-just@v1- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}++ # βΉοΈStep only applies for frontend and catalog images.++ # Frontend downloads translations and catalog runs `just` recipes.+ - name: Setup CI env- if: matrix.image == 'frontend'++ if: matrix.image == 'frontend' || matrix.image == 'catalog'+ uses: ./.github/actions/setup-env+ with:+ setup_python: false+ # Python is not needed to build the image.+ install_recipe: node-install- - name: Get Python version- id: python-version- run: echo "value=$(just catalog/py-version)" >> "$GITHUB_OUTPUT"++ # βΉοΈWhile this step only applies for catalog image, it is run for all.++ # This step++ # - sets the Python version used by the catalog image++ # - sets the Airflow version used by the catalog image++ - name: Prepare catalog for building++ id: prepare-catalog++ # if: matrix.image == 'catalog'++ run: |++ echo "python_version=$(just catalog/py-version)" >> "$GITHUB_OUTPUT"++ echo "airflow_version=$(just catalog/airflow-version)" >> "$GITHUB_OUTPUT"+- - name: Get Airflow version- id: airflow-version- run: echo "value=$(just catalog/airflow-version)" >> "$GITHUB_OUTPUT"+ # βΉοΈStep only applies for frontend image.+ # This step+ # - downloads translation strings from GlotPress so that they can be+ # bundled inside the Docker image+ # - copies pnpm config files from the root to the `frontend/` directory+ # so that they can be used to mock a workspace inside the Docker image+ - name: Prepare frontend for building+ if: matrix.image == 'frontend'+ run: |+ just frontend/run i18n+ cp .npmrc .pnpmfile.cjs pnpm-lock.yaml frontend/+ env:+ GLOTPRESS_USERNAME: ${{ secrets.MAKE_USERNAME }}+ GLOTPRESS_PASSWORD: ${{ secrets.MAKE_LOGIN_PASSWORD }}- name: Setup Docker Buildxuses: docker/setup-buildx-action@v2with:install: true- - name: Build image+ - name: Build image `${{ matrix.image }}`uses: docker/build-push-action@v4with:- context: catalog+ context: ${{ matrix.context }}+ target: ${{ matrix.target }}push: false- tags: openverse-catalog- cache-from: type=gha,scope=catalog- cache-to: type=gha,scope=catalog- outputs: type=docker,dest=/tmp/catalog.tar+ tags: openverse-${{ matrix.image }}+ cache-from: type=gha,scope=${{ matrix.image }}+ cache-to: type=gha,scope=${{ matrix.image }}+ outputs: type=docker,dest=/tmp/${{ matrix.image }}.tarbuild-args: |- PROJECT_PY_VERSION=${{ steps.python-version.outputs.value }}- PROJECT_AIRFLOW_VERSION=${{ steps.airflow-version.outputs.value }}+ SEMANTIC_VERSION=${{ needs.get-image-tag.outputs.image_tag }}++ PROJECT_PY_VERSION=${{ steps.prepare-catalog.outputs.python_version }}++ PROJECT_AIRFLOW_VERSION=${{ steps.prepare-catalog.outputs.airflow_version }}- - name: Upload image+ - name: Upload image `${{ matrix.image }}`uses: actions/upload-artifact@v3with:- name: catalog- path: /tmp/catalog.tar+ name: ${{ matrix.image }}+ path: /tmp/${{ matrix.image }}.tar- test:- name: Run tests++ ###########++ # Catalog #++ ###########++++ test-cat:++ name: Run tests for the catalog++ if: needs.get-changes.outputs.catalog == 'true'+ runs-on: ubuntu-latest++ timeout-minutes: 15+ needs:- - lint++ - get-changes++ - build-images++++ steps:++ - name: Checkout repository++ uses: actions/checkout@v3++++ - name: Setup CI env++ uses: ./.github/actions/setup-env++ with:++ setup_python: false++ # Python is not needed to run the tests.++ setup_nodejs: false++ # Node.js is not needed to run API tests.++ install_recipe: ""++++ - name: Load Docker images++ uses: ./.github/actions/load-img++ with:++ setup_api: false++ setup_ingestion_server: false++++ - name: Run tests++ run: |++ just catalog/test --extended++++ catalog-checks:++ name: Run catalog checks++ if: needs.get-changes.outputs.catalog == 'true'++ runs-on: ubuntu-latest++ needs:++ - get-changes++ - build-images++++ steps:++ - name: Checkout repository++ uses: actions/checkout@v3++++ - name: Setup CI env++ uses: ./.github/actions/setup-env++ with:++ # Python is not needed to run pre-commit.++ setup_python: false++ # Node.js is needed by lint actions.++ install_recipe: "node-install"++++ - name: Load Docker images++ uses: ./.github/actions/load-img++ with:++ setup_api: false++ setup_ingestion_server: false++++ - name: Check DAG documentation++ run: |++ just catalog/generate-dag-docs true+++ ####################+ # Ingestion server #+ ####################++ test-ing:+ name: Run tests for ingestion-server+ if: needs.get-changes.outputs.ingestion_server == 'true'+ runs-on: ubuntu-latest+ timeout-minutes: 15+ needs:+ - get-changes+ - build-images++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-env+ with:+ # Python is needed to run the test.+ setup_nodejs: false+ # Node.js is not needed to run ingestion server tests.+ install_recipe: ingestion_server/install++ - name: Load Docker images+ uses: ./.github/actions/load-img+ with:+ setup_api: false++ setup_catalog: false++ - name: Run ingestion-server tests+ run: just ingestion_server/test-local++ - name: Upload ingestion test logs+ if: success() || failure()+ uses: actions/upload-artifact@v3+ with:+ name: ing_logs+ path: ingestion_server/test/ingestion_logs.txt++ - name: Print ingestion test logs+ if: success() || failure()+ run: cat ingestion_server/test/ingestion_logs.txt++ #######+ # API #+ #######++ test-api:+ name: Run tests for the API+ if: needs.get-changes.outputs.ingestion_server == 'true' || needs.get-changes.outputs.api == 'true'+ runs-on: ubuntu-latest+ timeout-minutes: 15+ needs:+ - get-changes+ - build-images++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-env+ with:+ setup_python: false+ # Python is not needed to run the tests.+ setup_nodejs: false+ # Node.js is not needed to run API tests.+ install_recipe: ""++ - name: Load Docker images+ uses: ./.github/actions/load-img++ with:++ setup_catalog: false++ - name: Start API, ingest and index test data+ run: just api/init++ - name: Run API tests+ run: just api/test++ - name: Print API test logs+ if: success() || failure()+ run: |+ just logs > api_logs+ cat api_logs++ - name: Upload API test logs+ if: success() || failure()+ uses: actions/upload-artifact@v3+ with:+ name: api_logs+ path: api_logs++ django-checks:+ name: Run Django checks+ if: needs.get-changes.outputs.api == 'true'+ runs-on: ubuntu-latest+ needs:+ - get-changes- build-images+ strategy:+ fail-fast: false+ matrix:+ recipe:+ - "api/dj check"+ - "api/dj validateopenapischema"+ - "api/dj makemigrations --check --noinput --merge"+ - "api/doc-test"+steps:- - uses: actions/checkout@v3- - uses: extractions/setup-just@v1+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-env+ with:+ setup_python: false+ # Python is not needed to run the tests.+ setup_nodejs: false+ # Node.js is not needed to run API tests.+ install_recipe: ""++ - name: Load Docker images+ uses: ./.github/actions/load-img++ - name: Run check recipe+ run: just ${{ matrix.recipe }}env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ DC_USER: root++ - name: Upload schema on failure+ if: failure() && contains(matrix.recipe, 'validateopenapischema')+ uses: actions/upload-artifact@v3+ with:+ name: openverse-api-openapi-schema.yaml+ path: ./api/openapi.yaml++ # This job runs when `django-checks` doesn't and always passes, thus allowing+ # PRs to meet the required checks criteria and be merged.+ bypass-django-checks:+ name: Run Django checks+ if: needs.get-changes.outputs.api != 'true'+ runs-on: ubuntu-latest+ needs:+ - get-changes+ strategy:+ matrix:+ recipe:+ - "api/dj check"+ - "api/dj validateopenapischema"+ - "api/dj makemigrations --check --noinput --merge"+ - "api/doc-test"++ steps:+ - name: Pass+ run: echo 'Django checks are skipped because API is unchanged.'- - name: Get Python version- id: python-version- run: echo "value=$(just catalog/py-version)" >> "$GITHUB_OUTPUT"+ ############+ # Frontend #+ ############- - name: Setup Python- uses: actions/setup-python@v4+ frontend-unit:+ name: Run frontend unit tests+ if: needs.get-changes.outputs.frontend == 'true'+ runs-on: ubuntu-latest+ needs:+ - get-changes+ - lint++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-envwith:- python-version: "${{ steps.python-version.outputs.value }}"+ setup_python: false+ install_recipe: node-install- - name: Cache pre-commit envs- uses: actions/cache@v3+ - name: Run unit tests+ run: just frontend/run test:unit++ storybook-smoke:+ name: Check Storybook smoke test+ if: needs.get-changes.outputs.frontend == 'true'+ runs-on: ubuntu-latest+ needs:+ - get-changes+ - lint++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-envwith:- path: ~/.cache/pre-commit- key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}+ setup_python: false+ install_recipe: node-install- - 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: Run Storybook smoke-test+ run: just frontend/run storybook:smoke- - name: Change permissions for Docker steps- run: chmod -R 777 catalog/+ nuxt-build:+ name: Check Nuxt build+ if: needs.get-changes.outputs.frontend == 'true'+ runs-on: ubuntu-latest+ needs:+ - get-changes+ - lint- - name: Build dev container- # The containers must be rebuilt here because we need the dev dependencies- # rather than the production ones- run: just build+ steps:+ - name: Checkout repository+ uses: actions/checkout@v3- - name: Check DAG documentation- run: just catalog/generate-dag-docs true+ - name: Setup CI env+ uses: ./.github/actions/setup-env+ with:+ setup_python: false+ install_recipe: node-install- - name: Test- run: just catalog/test --extended+ - name: Run build+ run: just frontend/run build- push:+ playwright:+ name: Run Playwright tests+ if: needs.get-changes.outputs.frontend == 'true'+ runs-on: ubuntu-latest+ timeout-minutes: 15+ needs:+ - get-changes+ - lint+ strategy:+ fail-fast: false+ matrix:+ name:+ - playwright_vr+ - playwright_e2e+ - storybook_vr+ include:+ - name: playwright_vr+ script: "test:playwright visual-regression"+ - name: playwright_e2e+ script: "test:playwright e2e"+ - name: storybook_vr+ script: "test:storybook"++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-env+ with:+ setup_python: false+ install_recipe: node-install++ - name: Run Playwright tests+ run: just frontend/run ${{ matrix.script }} --workers=2++ - uses: actions/upload-artifact@v3+ if: failure()+ id: test-results+ with:+ name: ${{ matrix.name }}_test_results+ path: frontend/test-results++ # This job runs when `playwright` doesn't and always passes, thus allowing+ # PRs to meet the required checks criteria and be merged.+ bypass-playwright:+ name: Run Playwright tests+ if: needs.get-changes.outputs.frontend != 'true'+ runs-on: ubuntu-latest+ needs:+ - get-changes+ strategy:+ matrix:+ name:+ - playwright_vr+ - playwright_e2e+ - storybook_vr++ steps:+ - name: Pass+ run: echo 'Playwright tests are skipped because frontend is unchanged.'++ playwright-test-failure-comment:+ name: Post Playwright test debugging instructions+ if: |+ !cancelled() &&+ github.event_name == 'pull_request' &&+ needs.get-changes.outputs.frontend == 'true'+ runs-on: ubuntu-latest+ needs:+ - get-changes+ - playwright++ steps:+ - uses: peter-evans/find-comment@v2+ id: test-results-comment+ with:+ issue-number: ${{ github.event.pull_request.number }}+ body-includes: Playwright failure test results++ - uses: actions/github-script@v6+ if: steps.test-results-comment.outputs.comment-id != 0+ with:+ script: |+ await github.rest.issues.deleteComment({+ repo: context.repo.repo,+ owner: context.repo.owner,+ comment_id: ${{ steps.test-results-comment.outputs.comment-id }}+ })+ console.log('Deleted comment with ID ${{ steps.test-results-comment.outputs.comment-id }}')++ - name: Build help body+ if: needs.playwright.result == 'failure'+ id: help-body+ run: |+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) # Security hardening: https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections+ MESSAGE=$(cat <<HEREDOC+ help_body<<$EOF+ **Playwright failure test results**: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}>++ It looks like some of the Playwright tests failed. You can download the trace output and image diffs for the failed tests under the "Artifacts" section in the above page.++ You can read the [docs on how to use this artifact](https://github.com/${{ github.repository }}/blob/main/frontend/test/playwright/README.md#debugging).+ $EOF+ HEREDOC+ )+ echo "$MESSAGE"+ echo "$MESSAGE" >> "$GITHUB_OUTPUT"++ - uses: peter-evans/create-or-update-comment@v2+ id: create-comment+ # Do not leave a comment on forks+ if: |+ needs.playwright.result == 'failure' &&+ (+ github.event_name == 'pull_request' &&+ github.event.pull_request.head.repo.owner.login == 'WordPress' &&+ github.actor != 'dependabot[bot]'+ )+ with:+ issue-number: ${{ github.event.pull_request.number }}+ body: ${{ steps.help-body.outputs.help_body }}++ #################+ # Documentation #+ #################++ emit-docs:+ name: Emit full-stack docs+ # https://github.com/actions/runner/issues/491#issuecomment-850884422+ if: |+ !failure() && !cancelled() &&+ (+ (+ github.event_name == 'push' &&+ github.repository == 'WordPress/openverse'+ ) ||+ (+ github.event_name == 'pull_request' &&+ github.event.pull_request.head.repo.owner.login == 'WordPress' &&+ github.actor != 'dependabot[bot]'+ )+ ) &&+ (needs.get-changes.outputs.frontend == 'true' || needs.get-changes.outputs.documentation == 'true') &&+ (needs.test-ing.result == 'success' || needs.test-ing.result == 'skipped') &&+ (needs.test-api.result == 'success' || needs.test-api.result == 'skipped') &&++ (needs.test-cat.result == 'success' || needs.test-cat.result == 'skipped') &&+ (needs.nuxt-build.result == 'success' || needs.nuxt-build.result == 'skipped')+ runs-on: ubuntu-latest+ needs:+ - get-changes++ - test-cat+ - test-ing+ - test-api+ - nuxt-build++ steps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Setup CI env+ uses: ./.github/actions/setup-env++ - name: Compile documentation+ uses: ./.github/actions/build-docs+ with:+ glotpress_username: ${{ secrets.MAKE_USERNAME }}+ glotpress_password: ${{ secrets.MAKE_LOGIN_PASSWORD }}+ # Docs will be located at `/tmp/docs`.++ - name: Recreate working directory # to avoid superfluous files from getting tracked automatically+ run: |+ cd ..+ sudo rm -rf openverse+ mkdir openverse++ - name: Checkout repository at `gh-pages` branch+ uses: actions/checkout@v3+ with:+ ref: gh-pages++ - name: Copy existing previews+ if: github.event_name == 'push'+ run: |+ mv /tmp/docs /tmp/gh-pages+ mv _preview /tmp/gh-pages/_preview++ - name: Replace preview of current PR+ if: github.event_name == 'pull_request'+ run: |+ cp -r . /tmp/gh-pages+ sudo rm -rf /tmp/gh-pages/_preview/${{ github.event.pull_request.number }}+ mv /tmp/docs /tmp/gh-pages/_preview/${{ github.event.pull_request.number }}++ - name: Deploy+ uses: peaceiris/actions-gh-pages@v3+ with:+ github_token: ${{ secrets.GITHUB_TOKEN }}+ publish_dir: /tmp/gh-pages+ force_orphan: true+ cname: docs.openverse.org++ - uses: peter-evans/find-comment@v2+ if: github.event_name == 'pull_request'+ id: final-preview-comment+ with:+ issue-number: ${{ github.event.pull_request.number }}+ body-includes: Full-stack documentation++ - uses: peter-evans/create-or-update-comment@v2+ if: github.event_name == 'pull_request'+ with:+ issue-number: ${{ github.event.pull_request.number }}+ comment-id: ${{ steps.final-preview-comment.outputs.comment-id }}+ edit-mode: replace+ body: |+ **Full-stack documentation**: <https://docs.openverse.org/_preview/${{ github.event.pull_request.number }}>++ Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.++ You can check [the GitHub pages deployment action list](https://github.com/${{ github.repository }}/actions/workflows/pages/pages-build-deployment) to see the current status of the deployments.++ - name: Checkout repository # again, to enable cleaning+ uses: actions/checkout@v3+ if: success() || failure()++ #################+ # Docker images #+ #################++ publish-images:name: Publish Docker imagesruns-on: ubuntu-latest- if: github.event_name == 'release' && github.event.action == 'published'+ # prevent running on fork PRs+ if: |+ !failure() && !cancelled() &&+ github.event_name == 'push' &&+ github.repository == 'WordPress/openverse' &&+ needs.determine-images.outputs.do_publish == 'true' &&+ (needs.test-ing.result == 'success' || needs.test-ing.result == 'skipped') &&+ (needs.test-api.result == 'success' || needs.test-api.result == 'skipped') &&++ (needs.test-cat.result == 'success' || needs.test-cat.result == 'skipped') &&+ (needs.nuxt-build.result == 'success' || needs.nuxt-build.result == 'skipped')needs:- - test+ - determine-images+ - get-image-tag+ - build-images+ - test-ing # test for ingestion server+ - test-api # test for API++ - test-cat # test for catalog+ - nuxt-build # test for frontendpermissions:packages: writecontents: readdiff --cc .gitignoreindex b19e0cfe9,d00a240cf..05b32997a--- a/.gitignore+++ b/.gitignore@@@ -1,53 -1,157 +1,63 @@@-# Byte-compiled / optimized / DLL files-__pycache__/-*.py[cod]-*$py.class--# C extensions-*.so--# Distribution / packaging-.Python-build/-develop-eggs/-dist/-downloads/-eggs/-.eggs/-lib/-lib64/-parts/-sdist/-var/-wheels/-pip-wheel-metadata/-share/python-wheels/-*.egg-info/-.installed.cfg-*.egg-MANIFEST--# PyInstaller-# Usually these files are written by a python script from a template-# before PyInstaller builds the exe, so as to inject date/other infos into it.-*.manifest-*.spec--# Installer logs-pip-log.txt-pip-delete-this-directory.txt--# Unit test / coverage reports-htmlcov/-.tox/-.nox/-.coverage-.coverage.*-.cache-nosetests.xml-coverage.xml-*.cover-*.py,cover-.hypothesis/-.pytest_cache/--# Translations-*.mo-*.pot--# Django stuff:-*.log-local_settings.py-db.sqlite3-db.sqlite3-journal--# Flask stuff:-instance/-.webassets-cache--# Scrapy stuff:-.scrapy--# Sphinx documentation-docs/_build/--# PyBuilder-target/--# Jupyter Notebook-.ipynb_checkpoints--# IPython-profile_default/-ipython_config.py--# pyenv-.python-version+# macOS+._*+.DS_Store-# pipenv-# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.-# However, in case of collaboration, if having platform-specific dependencies or dependencies-# having no cross-platform support, pipenv may install dependencies that don't work, or not-# install all needed dependencies.-#Pipfile.lock+# Editor/IDE configs+.idea/+.vscode/+.swp-# celery beat schedule file-celerybeat-schedule++# General detritus++logs/+-# SageMath parsed files-*.sage.py+# Environment+.env-# Environments-*.env-.venv+# Python environmentsenv/venv/-ENV/-env.bak/-venv.bak/--# Spyder project settings-.spyderproject-.spyproject+pip-log.txt-# Rope project settings-.ropeproject+# Python+__pycache__/+*.py[cod]+.python-version-# mkdocs documentation-/site+# Node.js dependencies+node_modules/+npm-debug.log*+.pnpm-debug.log-# mypy-.mypy_cache/-.dmypy.json-dmypy.json+# Nuxt+.nuxt-# Pyre type checker-.pyre/++# Airflow++airflow.cfg++airflow.db+-# Editors and IDE's-.vscode/-.history/-.idea/-*.sublime-workspace+# Local certificates+*.pem+*.crt+*.key-# environment file which may have keys-env.sh+# pre-commit+pre-commit.pyz-# airflow testing detritus-airflow.cfg-airflow.db-logs/-unittests.cfg-!*/util/test_resources/logs/*++# Ruff++.ruff_cache+-# large SI sample data-si_samples_*+# ESLint+.eslintcache-# Vim detritus-*.swp+# Vercel+vercel.json+.vercel-# macOS-.DS_Store+# Grafana+grafana.db-# pre-commit-pre-commit.pyz+# Ingestion server+# TODO: This shouldn't be in root+ingestion_server.log-# These logs must be Git-tracked-!catalog/tests/dags/common/test_resources/logs/**/*.log-!catalog/tests/dags/common/test_resources/logs/+*.tsbuildinfodiff --cc .isort.cfgindex 74597f1f3,d2bbc8a43..d1b9e0348--- a/.isort.cfg+++ b/.isort.cfg@@@ -1,13 -1,6 +1,8 @@@[settings]profile=black-sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER-# These submodules are all added to the PYTHONPATH by Airflow, so we need to add them individually here.-known_first_party=common,data_refresh,database,maintenance,oauth2,providers,retired+sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER+known_django=django,rest_framework- known_first_party=catalog,ingestion_server++known_first_party=catalog,ingestion_server,common,data_refresh,database,maintenance,oauth2,providers,retired++lines_after_imports=2- multi_line_output=3- include_trailing_comma=true- force_grid_wrap=0- ensure_newline_before_comments=true- use_parentheses=truediff --cc CONTRIBUTING.mdindex 1db676a91,533ebe6a9..a4da01e03--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@@ -6,173 -9,17 +6,173 @@@ document is a set of guidelines to hel## Code of Conduct-By participating in this project, you are expected to uphold our-[Code of Conduct](./CODE_OF_CONDUCT.md).+You should read and agree to abide by the [code of conduct](CODE_OF_CONDUCT.md)+before contributing to WordPress projects. This applies to all Openverse+repositories because Openverse is a WordPress Foundation project.++## Keep in touch++Don't hesitate to ask for help; if you're stuck, we're here for you! You can+ping us via any of our [communication channels](README.md#keep-in-touch).++## Code and code-related contributions++### Get started++Detailed help for contributing code can be found in the+[developer documentation](https://docs.openverse.org/), which also includes the+following subfolders.++- [Storybook](https://docs.openverse.org/storybook/) (UI components)+- [Tailwind Config Viewer](https://docs.openverse.org/tailwind/) (design tokens)++The following resources are preferred reading for starting your Openverse+contribution journey in the code and code-related space.++- [GitHub contribution practices](https://docs.openverse.org/reference/github_contribution_practices.html)+- [Dev flow](https://docs.openverse.org/reference/dev_flow.html)+- [General setup guide](https://docs.openverse.org/guides/general_setup.html)+- [Quickstart guide](https://docs.openverse.org/guides/quickstart.html)++#### Friendly notes++It's totally acceptable to work on more than one+["good first issue"](https://github.com/WordPress/openverse/issues?q=is:issue+is:open+sort:updated-desc+label:%22good+first+issue%22).++On GitHub, you can ping us on any issue you would like to work on or triaging+and on PRs that you've opened or are giving feedback on. You can ping a specific+person using their GitHub handle, or even the entire Openverse team using+`@WordPress/openverse-maintainers`.++### Text and documentation++Our documentation and copy text could always use improvement. If you spot any+scope for improvement, from the smallest punctuation error to the largest+factual inaccuracy, you can file an issue or fix an already open one.++- [Good first issues with the "π aspect: text" label](https://github.com/WordPress/openverse/issues?q=is:issue+is:open+sort:updated-desc+label:%22good+first+issue%22+label:%22%F0%9F%93%84+aspect:+text%22)+- [Issues wanting help with the "π aspect: text" label](https://github.com/WordPress/openverse/issues?q=is:issue+is:open+sort:updated-desc+label:%22help+wanted%22+label:%22%F0%9F%93%84+aspect:+text%22)++### Bug reproduction & triage++Openverse has a large list of open bugs. In many cases these bugs can be out of+date, or their reproduction criteria may no longer be accurate. It is useful+information for maintainers to know whether the issue mentioned can still be+reproduced on recent versions of the code or if the issue can no longer be+replicated.++- [Issues with the "π goal: fix" label](https://github.com/WordPress/openverse/issues?q=is:open+is:issue+label:%22%F0%9F%9B%A0+goal:+fix%22)++### Pull request review++New contributors are welcome and invited to provide feedback on pull requests.+You can start by just asking questions! It's great to get to know the project+and helps PR authors by uncovering unspoken or undocumented assumptions that+exist about the project. It is frequently folks who know the least about and are+newest to a project that ask the most helpful questions in this regard.++- [Non-draft open PRs](https://github.com/WordPress/openverse/pulls?q=is:pr+is:open+-is:draft)++### Programming++Any issues labeled as "good first issue" or "help wanted" in our repositories+are all up for grabs. Just add a comment tagging the maintainers using+`@WordPress/openverse-maintainers` on the issue with questions or requesting the+issue be assigned to you when you're ready to work on it.++- [Good first issues](https://github.com/WordPress/openverse/issues?q=is:issue+is:open+sort:updated-desc+label:%22good+first+issue%22)+- [Issues wanting help](https://github.com/WordPress/openverse/issues?q=is:issue+is:open+sort:updated-desc+label:%22help+wanted%22)++## Non-code contributions++If programming is not your cup of tea, there are ways to contribute to Openverse+that do not involve working with code at all. Some of them are listed below.++### Design++If you'd like to contribute to the design, feel free to propose a solution to an+existing problem labeled with+[Needs Design](https://github.com/WordPress/openverse-frontend/issues?q=is%3Aopen+is%3Aissue+label%3A%22needs+design%22),+or share an idea if you think it meets Openverse's goals.++The [WordPress Design team](http://make.wordpress.org/design/) uses+[Figma](https://www.figma.com/) to collaborate and share work for all WordPress+projects. If you are not familiar with designing for WordPress, please carefully+read the [design handbook](https://make.wordpress.org/design/handbook/). Once+you have a [WordPress Slack](https://make.wordpress.org/chat/) account, join the+[#design channel](http://wordpress.slack.com/messages/design/) and ask the team+to set you up with a free Figma account.++This will give you access to+[all projects and files](https://www.figma.com/files/team/642003996626140596/WordPress.org?fuid=968867265893371002)+used in WordPress.++Before designing a proposal, browse the+[Design Library](https://www.figma.com/file/GIIQ4sDbaToCfFQyKMvzr8/Openverse-Design-Library?node-id=0%3A1)+file to understand how Openverse has been built, and take a look at the+[created work](https://www.figma.com/files/project/31962071/Openverse?fuid=968867265893371002)+to get a glance at how design ideas are made. As the design onboarding section+in the design library file is constantly being added to and improved, some+documentation may be missing. If you have doubts, ask on+[#design channel](http://wordpress.slack.com/messages/design/) for+clarification. If you discover new information that is yet to be documented,+contributing this information back to the documentation is very much+appreciated.++Once you are done and ready to share your idea,+[create an issue with the `design` label and fill in the template](https://github.com/WordPress/openverse-frontend/issues/new?assignees=&labels=πΌοΈ+aspect%3A+design%2Cβ¨+goal%3A+improvement%2C+π¦+status%3A+awaiting+triage&template=feature_request.md&title=<Replace+this+with+actual+title>).+Please be as specific and concise as possible and feel free to add mockups,+prototypes, videos, sketches, and anything that makes your idea easier to+understand.++After creating the issue, it will be labeled with `aspect: design`. Please+reference+[existing design issues](https://github.com/WordPress/openverse-frontend/issues?q=is%3Aopen+is%3Aissue+label%3A%22%F0%9F%96%BC%EF%B8%8F+aspect%3A+design%22)+as a guide for how to describe your solution and to understand how the+discussion evolves before implementation begins.++### Translations++You can also contribute to Openverse by translating it.++An overview of Openverse translations is here:+[https://translate.wordpress.org/projects/meta/openverse/](https://translate.wordpress.org/projects/meta/openverse/)++A getting started guide for translating on GlotPress (the software behind+[translate.wordpress.org](http://translate.wordpress.org)) is here:+[https://make.wordpress.org/polyglots/handbook/translating/glotpress-translate-wordpress-org/#getting-started](https://make.wordpress.org/polyglots/handbook/translating/glotpress-translate-wordpress-org/#getting-started)++### Providers++Openverse is powered by upstream providers of openly licensed media. You can+help expand Openverse by identifying sources of Creative Commons licensed+media - we're always looking to broaden our dataset.+- [Our currently list of providers which have been identified but are not yet being ingested can be found here](https://github.com/WordPress/openverse-catalog/issues?q=is%3Aopen+is%3Aissue+label%3A%22%E2%98%81%EF%B8%8F+provider%3A+any%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+audio%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+images%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+text%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+video%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+3D+models%22).++[Our currently list of providers which have been identified but are not yet being ingested can be found here](https://github.com/WordPress/openverse/issues?q=is%3Aopen+is%3Aissue+label%3A%22%E2%98%81%EF%B8%8F+provider%3A+any%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+audio%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+images%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+text%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+video%22%2C%22%E2%98%81%EF%B8%8F+provider%3A+3D+models%22).++You can use the- [New Source Suggestion for Openverse](https://github.com/WordPress/openverse-catalog/issues/new?assignees=&labels=%F0%9F%9A%A6+status%3A+awaiting+triage%2C%F0%9F%A7%B9+status%3A+ticket+work+required%2C%E2%98%81%EF%B8%8F+provider%3A+any&template=new_source_suggestion.yml&title=%3CSource+name+here%3E)++[New Source Suggestion for Openverse](https://github.com/WordPress/openverse/issues/new?assignees=&labels=%F0%9F%9A%A6+status%3A+awaiting+triage%2C%F0%9F%A7%B9+status%3A+ticket+work+required%2C%E2%98%81%EF%B8%8F+provider%3A+any&template=new_source_suggestion.yml&title=%3CSource+name+here%3E)+issue template to submit whatever sources you find.++### Feedback++Feedback like reporting bugs and missing features is big help for Openverse. We+want Openverse to be a bug-free app with great user experience and providing+feedback is a way to put any shortcomings on our radar and get them resolved.-## Project Documentation+You can report bugs, request features and see all other forms of feedback we+would like to receive by+[submitting a new issue](https://github.com/WordPress/openverse/issues/new/choose)+on GitHub. All are welcome to write issues and the Openverse maintainers have+deep gratitude for those who do. Note that you will need a GitHub account to+create new issues.-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.+You can also provide feedback via any of our other+[communication channels](README.md#keep-in-touch).-## Questions or Thoughts?+### Referrals-Feel free to [join us on Slack](https://make.wordpress.org/chat/) and discuss-the project with the engineers and community members on #openverse.+If you know folks who have expertise in any of the above areas who you think+might be interested in contributing to open source, send them our way! We're+happy to help onboard folks to the project itself, as well as the tools and+technologies we use.diff --cc README.mdindex 750dfff22,665f6baaa..d493c3256--- a/README.md+++ b/README.md@@@ -1,69 -1,264 +1,71 @@@-<img src="https://github.com/WordPress/openverse/raw/main/brand/banner.svg" width="100%"/>+<a href="https://openverse.org">+ <img src="brand/banner.svg" width="100%" alt="Visit Openverse.org"/>+</a><p align="center">- <a href="https://github.com/orgs/WordPress/projects/3">Project Board</a> | <a href="https://make.wordpress.org/openverse/">Community Site</a> | <a href="https://make.wordpress.org/chat/">#openverse @ Slack</a> | <a href="https://make.wordpress.org/openverse/handbook/">Handbook</a> | <a href="https://www.figma.com/file/w60dl1XPUvSaRncv1Utmnb/Openverse-Releases">Figma Mockups</a> | <a href="https://www.figma.com/file/GIIQ4sDbaToCfFQyKMvzr8/Openverse-Design-Library">Figma Design Library</a>+ <a href="https://github.com/orgs/WordPress/projects/3">Project Board</a> |+ <a href="https://make.wordpress.org/openverse/">Community Site</a> |+ <a href="https://make.wordpress.org/chat/">#openverse @ Slack</a> |+ <a href="https://make.wordpress.org/openverse/handbook/openverse-handbook/">Handbook</a> |+ <a href="https://make.wordpress.org/design/handbook/">Design Handbook</a> |+ <a href="https://www.figma.com/file/w60dl1XPUvSaRncv1Utmnb/Openverse-Releases?node-id=0%3A1">Releases mockups</a> |+ <a href="https://www.figma.com/file/GIIQ4sDbaToCfFQyKMvzr8/Openverse-Design-Library?node-id=0%3A1">Design Library</a></p>-# Openverse Catalog--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.--## API Data--[Apache Airflow](https://airflow.apache.org/) is used to manage the workflow for-various API ETL jobs which pull and process data from a number of open APIs on-the internet.--### API Workflows--To view more information about all the available workflows (DAGs) within the-project, see [DAGs.md](catalog/DAGs.md).--See each provider API script's notes in their respective [handbook][ov-handbook]-entry.--[ov-handbook]: https://make.wordpress.org/openverse/handbook/openverse-handbook/--## Web Crawl Data (retired)--The Common Crawl Foundation provides an open repository of petabyte-scale web-crawl data. A new dataset is published at the end of each month comprising over-200 TiB of uncompressed data.--The data is available in three file formats:--- WARC (Web ARChive): the entire raw data, including HTTP response metadata,- WARC metadata, etc.-- 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].--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)-- the CC referenced hyperlink (which may indicate a license),-- HTML meta data in JSON format which indicates the number of images on each- webpage and other domains that they reference,-- the location of the webpage in the WARC file so that the page contents can be- found.--The steps above were performed in [`ExtractCCLinks.py`][ex_cc_links].--This method was retired in 2021.--[ccrawl_doc]: https://commoncrawl.org/the-data/get-started/-[ex_cc_links]: archive/ExtractCCLinks.py--## Development setup for Airflow and API puller scripts--There are a number of scripts in the directory-[`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)--[api_scripts]: catalog/dags/providers/provider_api_scripts--### Requirements--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.--### Setup--To set up the local python environment along with the pre-commit hook, run:--```shell-python3 -m venv venv-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:--```shell-just build-```--### Environment--To set up environment variables run:--```shell-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--The `.env` file does not need to be modified if you only want to run the tests.--### Running & Testing--There is a [`docker-compose.yml`][dockercompose] provided in the-[`catalog`][cc_airflow] directory, so from that directory, run--```shell-just up-```--This results, among other things, in the following running containers:--- `openverse_catalog_webserver_1`-- `openverse_catalog_postgres_1`-- `openverse_catalog_s3_1`--and some networking setup so that they can communicate. Note:--- `openverse_catalog_webserver_1` is running the Apache Airflow daemon, and also- has a few development tools (e.g., `pytest`) installed.-- `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/catalog` in the- container `openverse_catalog_webserver_1`. On production, only the DAGs folder- will be mounted, e.g. `/opt/airflow/openverse/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`)-- Postgres: `localhost:5434` (using a database connector)--At this stage, you can run the tests via:--```shell-just test--# Alternatively, run all tests including longer-running ones-just test --extended-```--Edits to the source files or tests can be made on your local machine, then tests-can be run in the container via the above command to see the effects.--If you'd like, it's possible to login to the webserver container via:--```shell-just shell-```--If you just need to run an airflow command, you can use the `airflow` recipe.-Arguments passed to airflow must be quoted:--```shell-just run scheduler airflow config list-```--To follow the logs of the running container:--```shell-just logs-```--To begin an interactive [`pgcli` shell](https://www.pgcli.com/) on the database-container, run:--```shell-just db-shell-```--If you'd like to bring down the containers, run--```shell-just down-```--To reset the test DB (wiping out all databases, schemata, and tables), run--```shell-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.--To fully recreate everything from the ground up, you can use:--```shell-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-> [generate-dag-docs recipe](https://github.com/WordPress/openverse-catalog/blob/c9be67e483e49e9eda7cd21b52bcde8857cd3922/justfile#L126).--[justfile]: justfile-[dockercompose]: catalog/docker-compose.yml-[cc_airflow]: catalog/--## Directory Structure--```text-openverse-catalog-βββ .github/ # Templates for GitHub-βββ archive/ # Files related to the previous CommonCrawl parsing implementation-βββ docker/ # Dockerfiles and supporting files-β βββ airflow/ # - Docker image for Airflow server and workers-β βββ local_postgres/ # - Docker image for development Postgres database-βββ catalog/ # Primary code directory-β βββ dags/ # DAGs & DAG support code-β β βββ common/ # - Shared modules used across DAGs-β β βββ data_refresh/ # - DAGs & code related to the data refresh process-β β βββ database/ # - DAGs related to database actions (matview refresh, cleaning, etc.)-β β βββ maintenance/ # - DAGs related to airflow/infrastructure maintenance-β β βββ oauth2/ # - DAGs & code for Oauth2 key management-β β βββ providers/ # - DAGs & code for provider ingestion-β β β βββ provider_api_scripts/ # - API access code specific to providers-β β β βββ provider_csv_load_scripts/ # - Schema initialization SQL definitions for SQL-based providers-β β β βββ *.py # - DAG definition files for providers-β β βββ retired/ # - DAGs & code that is no longer needed but might be a useful guide for the future-β βββ templates/ # Templates for generating new provider code-βββ * # Documentation, configuration files, and project requirements-```--## Publishing+<p align="center">+ Openverse is a search engine for openly-licensed media.+</p>-The docker image for the catalog (Airflow) is published to-ghcr.io/WordPress/openverse-catalog.+# Openverse++Openverse is a powerful search engine for GPL-compatible images, audio, and+more. Openverse is live at [openverse.org](https://openverse.org).++This repository contains most of the codebase, except for the Openverse catalog.+Eventually the catalog will be merged into this repository as well.++- [Catalog](https://github.com/wordpress/openverse-catalog) | The Apache+ Airflow-powered system for downloading and storing Openverse's metadata++- [Catalog](catalog/) | The methods used to identify and index over 1.4 billion++ Creative Commons licensed works+- [Ingestion server](ingestion_server/) | The mechanism for refreshing the data+ from the catalog to the API+- [API](api/) | The Django REST API for querying the database, used by the+ frontend+- [Frontend](frontend/) | The public search engine at+ [openverse.org](https://openverse.org), built with Vue and Nuxt+- [Automations](automations/) | Scripts used for various workflows around+ Openverse repositories and processes+- [Utilities](utilities/) | Scripts or utilities which are useful across+ multiple projects or don't necessarily fit into a specific project.++This repository also contains the following directories.++- [Brand](brand/) | Brand assets for Openverse such as logo and icon and+ guidelines for using these assets+- [Templates](templates/) | Common scaffolding code that is rendered and synced+ to the catalog repo++## Keep in touch++You can keep in touch with the project via the following channels:++- GitHub+ - [Issues](https://github.com/WordPress/openverse/issues/)+ - [PRs](https://github.com/WordPress/openverse/pulls/)+ - [Discussions](https://github.com/WordPress/openverse/discussions/)+ - [Project Board](https://github.com/orgs/WordPress/projects/3)+- [Community Site](https://make.wordpress.org/openverse/)+- #openverse channel in the+ [Making WordPress Slack](https://make.wordpress.org/chat/)+ - Weekly Development Chat (@+ [Tuesday 15:00 UTC](https://everytimezone.com/s/d1d42c7b))+ - Monthly Prioritisation Meeting++## Documentation++To use the Openverse API, please refer to the+[API consumer documentation](https://api.openverse.engineering/v1/).## Contributingdiff --cc api/justfileindex 3563bea6c,000000000..dab84d80amode 100644,000000..100644--- a/api/justfile+++ b/api/justfile@@@ -1,120 -1,0 +1,120 @@@+set dotenv-load := false++COLOR := "\\033[0;34m"+NO_COLOR := "\\033[0m"++# Show all available recipes+@_default:+ printf "\n{{ COLOR }}# API (path: \`api/\`)\n"+ printf "===================={{ NO_COLOR }}\n"+ just --list --unsorted+++# Install dependencies+install *args="--dev":+ pipenv install {{ args }}++######+# Up #+######++# Bring up services specific to the API profile+up *flags:+ env COMPOSE_PROFILES="api" just ../up {{ flags }}++# Wait for all profile services to be up+wait-up: up+ just ../ingestion_server/wait # API profile includes ingestion server+ just wait # API waits for ES in entrypoint++# Load sample data into API via ingestion server+init: wait-up+ cd .. && ./load_sample_data.sh++recreate:+ just ../down -v+ just up "--force-recreate --build"+ just init++##########+# Health #+##########++# Check the health of the service+@health host="localhost:50280":+ -curl -s -o /dev/null -w '%{http_code}' 'http://{{ host }}/healthcheck/'++# Wait for the service to be healthy+@wait host="localhost:50280":+ # The just command on the second line is executed in the context of the+ # parent directory and so must be prefixed with `api/`.+ just ../_loop \+ '"$(just api/health {{ host }})" != "200"' \+ "Waiting for the API to be healthy..."++########+# cURL #+########++# Make a cURL GET request to service at the given path+_curl-get path host="localhost:50280":+ curl "http://{{ host }}/v1/{{ path }}"++# Make a test cURL GET request to the API+stats media="images" host="localhost:50280":+ just _curl-get "{{ media }}/stats/" {{ host }}++# Launch a `pgcli` shell in the web container (requires typing credentials)+pgcli db_host="db" db_name="openledger" db_user="deploy":- just ../exec web pgcli -h {{ db_host }} openledger++ env DC_USER="opener" just ../exec web pgcli -h {{ db_host }} openledger++#########################+# Django administration #+#########################++# Run Django administrative commands locally+dj-local +args="":+ pipenv run python manage.py {{ args }}++# Run Django administrative commands inside the Docker container+dj +args="": wait-up- just ../exec web python manage.py {{ args }}++ env DC_USER="opener" just ../exec web python manage.py {{ args }}++# Get IPython shell inside the Docker container+ipython:+ just dj shell++# Get DB shell inside the Docker container+dbshell:+ just dj dbshell++#########+# Tests #+#########++# Run API tests inside the Docker container+test *args: wait-up- just ../exec web ./test/run_test.sh {{ args }}++ env DC_USER="opener" just ../exec web ./test/run_test.sh {{ args }}++# Run API tests locally+test-local *args:+ pipenv run ./test/run_test.sh {{ args }}++# Run smoke test for the API docs+doc-test: wait-up+ curl --fail 'http://localhost:50280/v1/?format=openapi'++#########+# NGINX #+#########++# Build and run the NGINX image locally+nginx upstream_url='api.openverse.engineering':+ # upstream_url can also be set to 172.17.0.1:50280 for local testing+ docker build --target nginx . -t openverse-api_nginx:latest+ @echo "--> NGINX server will be run at http://localhost:9090, upstream at {{ upstream_url }}"+ @echo "--> Try a static URL like http://localhost:9090/static/admin/css/base.css to test"+ docker run --rm -p 9090:8080 -it \+ -e DJANGO_NGINX_UPSTREAM_URL="{{ upstream_url }}" \+ -e DJANGO_NGINX_GIT_REVISION="$(git rev-parse HEAD)" \+ openverse-api_nginx:latestdiff --cc archive/jars/aws-java-sdk-1.11.212.jarindex 000000000,799fb69fb..c89f71218mode 000000,100644..100644Binary files differdiff --cc archive/jars/hadoop-aws-2.8.1.jarindex 000000000,a2377726f..7eee7cd5amode 000000,100644..100644Binary files differdiff --cc archive/jars/postgresql-42.1.4.jarindex 000000000,08a54b105..a7adcddf2mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00000-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,fac0fbc0a..f26e9f712mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00001-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,524e2fb2e..d01254ad3mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00002-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,8772ab74c..254152ce5mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00003-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,ea965c209..b626b7010mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00004-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,0c1a47f84..8a981102fmode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00005-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,ee91266ef..62e7cf2b1mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00006-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,025055954..02b6536afmode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00007-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,2ee31c457..ea9cb17f7mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00008-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,5e2eef237..3b31bbb90mode 000000,100644..100644Binary files differdiff --cc archive/output/CC-MAIN-2018-22/part-00009-f7de218e-85c7-4724-9a90-bf2516de6907-c000.snappy.parquetindex 000000000,dba6327e8..23815cb8bmode 000000,100644..100644Binary files differdiff --cc catalog/.gitignoreindex 000000000,000000000..71e875f38new file mode 100644--- /dev/null+++ b/catalog/.gitignore@@@ -1,0 -1,0 +1,2 @@@++# Keep required logs++!tests/dags/common/test_resources/logs/diff --cc catalog/DEPLOYMENT.mdindex 000000000,609df89ba..02c95fd30mode 000000,100644..100644--- a/catalog/DEPLOYMENT.md+++ b/catalog/DEPLOYMENT.md@@@ -1,0 -1,92 +1,92 @@@+ # 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.++ # 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.++ ## 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.++ 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`](catalog/docker-compose.yml) is used to spin up Airflow in++[`docker-compose.yml`](docker-compose.yml) is used to spin up Airflow in+ production.++ **Note**: Service deployments are only necessary in the following conditions:++ - The Docker image has been modified+ - 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).++ ### Deployment workflow++ 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).+ 4. π Update the catalog version in the infrastructure repo by running+ `just bump prod catalog-airflow`+ 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.+-The [`dag-sync.sh`](./dag-sync.sh) script is used in production to regularly++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`.++ _**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.++ 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](catalog/dags/providers/provider_api_scripts/inaturalist.py)).++[iNaturalist](dags/providers/provider_api_scripts/inaturalist.py)).diff --cc catalog/Dockerfileindex 000000000,1bcae1e5f..9e0b20346mode 000000,100644..100644--- a/catalog/Dockerfile+++ b/catalog/Dockerfile@@@ -1,0 -1,68 +1,68 @@@+ # Cannot use $PYTHON_VERSION because that is overwritten by the base image+ # with the patch version (we only care about major and minor version)+ ARG PROJECT_PY_VERSION+ ARG PROJECT_AIRFLOW_VERSION+-FROM apache/airflow:slim-${PROJECT_AIRFLOW_VERSION}-python${PROJECT_PY_VERSION}++FROM apache/airflow:slim-${PROJECT_AIRFLOW_VERSION}-python${PROJECT_PY_VERSION} as cat++ # Build-time arguments, with sensible defaults+ ARG REQUIREMENTS_FILE=requirements_prod.txt++ # Path configurations+ ENV AIRFLOW_HOME=/opt/airflow+ ENV DAGS_FOLDER=${AIRFLOW_HOME}/catalog/dags+ ENV PYTHONPATH=${DAGS_FOLDER}+ ENV PATH=${AIRFLOW_HOME}/.local/bin:$PATH++ # Container optimizations+ ENV PYTHONUNBUFFERED=1+ ENV PIP_NO_CACHE_DIR=1+ ENV PIP_NO_COLOR=1++ # Airflow/workflow configuration+ ENV OUTPUT_DIR=/var/workflow_output/+ ENV AIRFLOW__CORE__DAGS_FOLDER=${DAGS_FOLDER}+ ENV AIRFLOW__CORE__LOAD_EXAMPLES=False+ ENV AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS=False+ ENV AIRFLOW__CORE__ENABLE_XCOM_PICKLING=True+ ENV AIRFLOW__WEBSERVER__EXPOSE_STACKTRACE=True++ # TODO: Test if moving this to .env changes anything!+ ENV AIRFLOW__LOGGING__REMOTE_LOGGING=True+ ENV AIRFLOW__LOGGING__REMOTE_LOG_CONN_ID=aws_default+ ENV AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER=s3://openverse-airflow-logs+++ USER root+ RUN apt-get update \+ && apt-get -yqq install \+ build-essential \+ libpq-dev \+ libffi-dev \+ && apt-get autoremove -y \+ && rm -rf /var/lib/apt/lists/*++ # Create and set the ownership of directories so airflow user can write to them+ # These directories are not needed in production but it's easier to perform+ # this step here while we're doing it for the output directory+ RUN mkdir -p ${OUTPUT_DIR} /home/airflow/.ipython /home/airflow/.cache/pytest && \+ chown airflow ${OUTPUT_DIR} /home/airflow/.ipython /home/airflow/.cache/pytest++ USER airflow++ WORKDIR ${AIRFLOW_HOME}+ # Always add the prod req because the dev reqs depend on it for deduplication+ COPY ${REQUIREMENTS_FILE} requirements_prod.txt ${AIRFLOW_HOME}/++ # args go out of scope when a new build stage starts so it must be redeclared here+ ARG PROJECT_PY_VERSION+ ARG PROJECT_AIRFLOW_VERSION++ # https://airflow.apache.org/docs/apache-airflow/stable/installation/installing-from-pypi.html#constraints-files+ ARG CONSTRAINTS_FILE="https://raw.githubusercontent.com/apache/airflow/constraints-${PROJECT_AIRFLOW_VERSION}/constraints-${PROJECT_PY_VERSION}.txt"++ RUN pip install --user -r ${REQUIREMENTS_FILE} -c ${CONSTRAINTS_FILE}++ COPY entrypoint.sh /opt/airflow/entrypoint.sh++ ENTRYPOINT ["/usr/bin/dumb-init", "--", "/opt/airflow/entrypoint.sh"]diff --cc catalog/README.mdindex 000000000,000000000..665f6baaanew file mode 100644--- /dev/null+++ b/catalog/README.md@@@ -1,0 -1,0 +1,304 @@@++<img src="https://github.com/WordPress/openverse/raw/main/brand/banner.svg" width="100%"/>++++<p align="center">++ <a href="https://github.com/orgs/WordPress/projects/3">Project Board</a> | <a href="https://make.wordpress.org/openverse/">Community Site</a> | <a href="https://make.wordpress.org/chat/">#openverse @ Slack</a> | <a href="https://make.wordpress.org/openverse/handbook/">Handbook</a> | <a href="https://www.figma.com/file/w60dl1XPUvSaRncv1Utmnb/Openverse-Releases">Figma Mockups</a> | <a href="https://www.figma.com/file/GIIQ4sDbaToCfFQyKMvzr8/Openverse-Design-Library">Figma Design Library</a>++</p>++++# Openverse Catalog++++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.++++## API Data++++[Apache Airflow](https://airflow.apache.org/) is used to manage the workflow for++various API ETL jobs which pull and process data from a number of open APIs on++the internet.++++### API Workflows++++To view more information about all the available workflows (DAGs) within the++project, see [DAGs.md](catalog/DAGs.md).++++See each provider API script's notes in their respective [handbook][ov-handbook]++entry.++++[ov-handbook]: https://make.wordpress.org/openverse/handbook/openverse-handbook/++++## Web Crawl Data (retired)++++The Common Crawl Foundation provides an open repository of petabyte-scale web++crawl data. A new dataset is published at the end of each month comprising over++200 TiB of uncompressed data.++++The data is available in three file formats:++++- WARC (Web ARChive): the entire raw data, including HTTP response metadata,++ WARC metadata, etc.++- 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].++++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)++- the CC referenced hyperlink (which may indicate a license),++- HTML meta data in JSON format which indicates the number of images on each++ webpage and other domains that they reference,++- the location of the webpage in the WARC file so that the page contents can be++ found.++++The steps above were performed in [`ExtractCCLinks.py`][ex_cc_links].++++This method was retired in 2021.++++[ccrawl_doc]: https://commoncrawl.org/the-data/get-started/++[ex_cc_links]: archive/ExtractCCLinks.py++++## Development setup for Airflow and API puller scripts++++There are a number of scripts in the directory++[`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)++++[api_scripts]: catalog/dags/providers/provider_api_scripts++++### Requirements++++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.++++### Setup++++To set up the local python environment along with the pre-commit hook, run:++++```shell++python3 -m venv venv++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:++++```shell++just build++```++++### Environment++++To set up environment variables run:++++```shell++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++++The `.env` file does not need to be modified if you only want to run the tests.++++### Running & Testing++++There is a [`docker-compose.yml`][dockercompose] provided in the++[`catalog`][cc_airflow] directory, so from that directory, run++++```shell++just up++```++++This results, among other things, in the following running containers:++++- `openverse_catalog_webserver_1`++- `openverse_catalog_postgres_1`++- `openverse_catalog_s3_1`++++and some networking setup so that they can communicate. Note:++++- `openverse_catalog_webserver_1` is running the Apache Airflow daemon, and also++ has a few development tools (e.g., `pytest`) installed.++- `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/catalog` in the++ container `openverse_catalog_webserver_1`. On production, only the DAGs folder++ will be mounted, e.g. `/opt/airflow/openverse/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`)++- Postgres: `localhost:5434` (using a database connector)++++At this stage, you can run the tests via:++++```shell++just test++++# Alternatively, run all tests including longer-running ones++just test --extended++```++++Edits to the source files or tests can be made on your local machine, then tests++can be run in the container via the above command to see the effects.++++If you'd like, it's possible to login to the webserver container via:++++```shell++just shell++```++++If you just need to run an airflow command, you can use the `airflow` recipe.++Arguments passed to airflow must be quoted:++++```shell++just run scheduler airflow config list++```++++To follow the logs of the running container:++++```shell++just logs++```++++To begin an interactive [`pgcli` shell](https://www.pgcli.com/) on the database++container, run:++++```shell++just db-shell++```++++If you'd like to bring down the containers, run++++```shell++just down++```++++To reset the test DB (wiping out all databases, schemata, and tables), run++++```shell++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.++++To fully recreate everything from the ground up, you can use:++++```shell++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++> [generate-dag-docs recipe](https://github.com/WordPress/openverse-catalog/blob/c9be67e483e49e9eda7cd21b52bcde8857cd3922/justfile#L126).++++[justfile]: justfile++[dockercompose]: catalog/docker-compose.yml++[cc_airflow]: catalog/++++## Directory Structure++++```text++openverse-catalog++βββ .github/ # Templates for GitHub++βββ archive/ # Files related to the previous CommonCrawl parsing implementation++βββ docker/ # Dockerfiles and supporting files++β βββ airflow/ # - Docker image for Airflow server and workers++β βββ local_postgres/ # - Docker image for development Postgres database++βββ catalog/ # Primary code directory++β βββ dags/ # DAGs & DAG support code++β β βββ common/ # - Shared modules used across DAGs++β β βββ data_refresh/ # - DAGs & code related to the data refresh process++β β βββ database/ # - DAGs related to database actions (matview refresh, cleaning, etc.)++β β βββ maintenance/ # - DAGs related to airflow/infrastructure maintenance++β β βββ oauth2/ # - DAGs & code for Oauth2 key management++β β βββ providers/ # - DAGs & code for provider ingestion++β β β βββ provider_api_scripts/ # - API access code specific to providers++β β β βββ provider_csv_load_scripts/ # - Schema initialization SQL definitions for SQL-based providers++β β β βββ *.py # - DAG definition files for providers++β β βββ retired/ # - DAGs & code that is no longer needed but might be a useful guide for the future++β βββ templates/ # Templates for generating new provider code++βββ * # Documentation, configuration files, and project requirements++```++++## Publishing++++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.++++## Additional Resources++++- 2022-01-12: **[cc-archive/cccatalog](https://github.com/cc-archive/cccatalog):++ The old repository for this catalog contains useful information for the++ original motivations and architecture of the Catalog.**++++For additional context see:++++- 2020-12-07:++ [Upcoming Changes to the CC Open Source Community β Creative Commons Open Source](https://opensource.creativecommons.org/blog/entries/2020-12-07-upcoming-changes-to-community/)++- 2021-05-03:++ [CC Search to Join WordPress - Creative Commons](https://creativecommons.org/2021/05/03/cc-search-to-join-wordpress/)++- 2021-05-10:++ [Welcome to Openverse β Openverse β WordPress.org](https://make.wordpress.org/openverse/2021/05/11/hello-world/)++- 2021-12-13:++ [Dear Users of CC Search, Welcome to Openverse - Creative Commons](https://creativecommons.org/2021/12/13/dear-users-of-cc-search-welcome-to-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/).++++## License++++- [`LICENSE`](LICENSE) (Expat/[MIT][mit] License)++++[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 --cc catalog/env.templateindex 000000000,e4b8e5179..8c04388a8mode 000000,100644..100644--- a/catalog/env.template+++ b/catalog/env.template@@@ -1,0 -1,112 +1,112 @@@+ # ,-. ;-. ,--. . . . , ,--. ,-. ,-. ,--. ,-. ,-. . . ,--. , ,-. #+ # / \ | ) | |\ | | / | | ) ( ` | / / \ |\ | | | / #+ # | | |-' |- | \| | / |- |-< `-. |- | | | | \| |- | | -. #+ # \ / | | | | |/ | | \ . ) | \ \ / | | | | \ | #+ # `-' ' `--' ' ' ' `--' ' ' `-' `--' `-' `-' ' ' ' ' `-' #++ ########################################################################################+ # Airflow Settings+ ########################################################################################+ # Some brand-based suggestions: #C52B9B (pink), #FFE033 (yellow)+ AIRFLOW__WEBSERVER__NAVBAR_COLOR="#FFF"+ # Disabled by default to make development easier+ # (enabled on prod for security)+ AIRFLOW__CORE__HIDE_SENSITIVE_VAR_CONN_FIELDS=False+ # Use the following python code to generate a fernet key for production+ # python -c "import base64, os; print(base64.urlsafe_b64encode(os.urandom(32)).decode())"+ # AIRFLOW__CORE__FERNET_KEY=+ # CSRF key https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key+ AIRFLOW__WEBSERVER__SECRET_KEY=sample-secret-key=+ # Executor to use+ AIRFLOW__CORE__EXECUTOR=LocalExecutor+ # Environment this instance is being run in+ AIRFLOW_VAR_ENVIRONMENT=dev++ ########################################################################################+ # API Keys+ ########################################################################################+ # See: https://airflow.apache.org/docs/apache-airflow/stable/howto/variable.html#storing-variables-in-environment-variables+ AIRFLOW_VAR_API_KEY_BROOKLYN_MUSEUM=not_set+ AIRFLOW_VAR_API_KEY_DATA_GOV=not_set+ AIRFLOW_VAR_API_KEY_EUROPEANA=not_set+ AIRFLOW_VAR_API_KEY_FLICKR=not_set+ AIRFLOW_VAR_API_KEY_FREESOUND=not_set+ AIRFLOW_VAR_API_KEY_JAMENDO=not_set+ AIRFLOW_VAR_API_KEY_NYPL=not_set+ AIRFLOW_VAR_API_KEY_RAWPIXEL=not_set+ AIRFLOW_VAR_API_KEY_THINGIVERSE=not_set+ AIRFLOW_VAR_API_KEY_WALTERS_ART_MUSEUM=not_set+++ ########################################################################################+ # Connection/Variable info+ ########################################################################################+ # Airflow primary metadata database+ # Change the following line in prod to use the appropriate DB-AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow++AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@upstream_db:5432/airflow+ # Remote logging connection ID+ # Replace "access_key" and "secret+key" with the real values. Secret key must be URL-encoded+ AIRFLOW_CONN_AWS_DEFAULT=aws://test_key:test_secret@?region_name=us-east-1&endpoint_url=http://s3:5000++ # Catalog DB connection. Change the following line in prod to use the appropriate DB-AIRFLOW_CONN_POSTGRES_OPENLEDGER_UPSTREAM=postgres://deploy:deploy@postgres:5432/openledger-AIRFLOW_CONN_POSTGRES_OPENLEDGER_TESTING=postgres://deploy:deploy@postgres:5432/openledger++AIRFLOW_CONN_POSTGRES_OPENLEDGER_UPSTREAM=postgres://deploy:deploy@upstream_db:5432/openledger++AIRFLOW_CONN_POSTGRES_OPENLEDGER_TESTING=postgres://deploy:deploy@upstream_db:5432/openledger+ OPENLEDGER_CONN_ID=postgres_openledger_upstream+ TEST_CONN_ID=postgres_openledger_testing++ # API DB connection. Change the following line in prod to use the appropriate DB-AIRFLOW_CONN_POSTGRES_OPENLEDGER_API=postgres://deploy:[email protected]:5432/openledger++AIRFLOW_CONN_POSTGRES_OPENLEDGER_API=postgres://deploy:deploy@db:5432/openledger+ OPENLEDGER_API_CONN_ID=postgres_openledger_api++ # Slack webhook connection info (note that these values are modified by the Docker entrypoint)+ # A distinction is made here between "notifications" and "alerts", the former being+ # useful updates and the latter being alarms or actionable errors.+ AIRFLOW_CONN_SLACK_NOTIFICATIONS=https://slack+ AIRFLOW_CONN_SLACK_ALERTS=https://slack++ S3_LOCAL_ENDPOINT=http://s3:5000+ AWS_CONN_ID=aws_default++ AIRFLOW_CONN_EMR_EMPTY=emr://+ AIRFLOW_CONN_EMR_TEST=emr://?host=http://s3:5000++ EMR_CONN_ID=emr_empty+ EMR_TEST_CONN_ID=emr_test++ # Connection to the Ingestion Server, used for managing data refreshes. Default is used to+ # connect to your locally running ingestion server.+ AIRFLOW_CONN_DATA_REFRESH=http://172.17.0.1:8001++ # Django Admin url. Change the following line to use the appropriate environment.+ DJANGO_ADMIN_URL="https://localhost:8000/admin"++ # GitHub - used for maintenance+ AIRFLOW_VAR_GITHUB_API_KEY="not_set"+++ ########################################################################################+ # Other config+ ########################################################################################+ # Version of the catalog docker image to use. Defaults to `latest` and is not used for+ # local development (since the image is always built locally). See available tags at+ # https://ghcr.io/wordpress/openverse-catalog+ DOCKER_IMAGE_TAG=latest+ # External port airflow will be mounted to+ AIRFLOW_PORT=9090+ # Minutes to wait until processing a file that hasn't been modified+ LOADER_FILE_AGE=1+ # Contact email for any APIs+ # AWS/S3 configuration - does not need to be changed for development+ AWS_ACCESS_KEY=test_key+ AWS_SECRET_KEY=test_secret+ # General bucket used for TSV->DB ingestion and logging+ OPENVERSE_BUCKET=openverse-storage+ # Seconds to wait before poking for availability of the data refresh pool when running a data_refresh+ # DAG. Used to shorten the time for testing purposes.+ DATA_REFRESH_POKE_INTERVAL=5+ # Number of Retries if DAG task fails to run+ DEFAULT_RETRY_COUNT = 2++ AIRFLOW_VAR_AIRFLOW_RDS_ARN=unset+ AIRFLOW_VAR_AIRFLOW_RDS_SNAPSHOTS_TO_RETAIN=7diff --cc catalog/justfileindex 000000000,b5f49827b..8c2062abbmode 000000,100644..100644--- a/catalog/justfile+++ b/catalog/justfile@@@ -1,0 -1,136 +1,136 @@@+ set dotenv-load := false++ COLOR := "\\033[0;34m"+ NO_COLOR := "\\033[0m"++ # Show all available recipes+ @_default:+ printf "\n{{ COLOR }}# Catalog (path: \`catalog/\`)\n"+ printf "============================{{ NO_COLOR }}\n"+ just --list --unsorted+++ SERVICE := env_var_or_default("SERVICE", "scheduler")++ ###########+ # Version #+ ###########++ export PROJECT_PY_VERSION := `grep '# PYTHON' requirements_prod.txt | awk -F= '{print $2}'`+ export PROJECT_AIRFLOW_VERSION := `grep '^apache-airflow' requirements_prod.txt | awk -F= '{print $3}'`++ # Print the required Python version+ @py-version:+ echo $PROJECT_PY_VERSION++ # Print the current Airflow version+ @airflow-version:+ echo $PROJECT_AIRFLOW_VERSION++ ###########+ # Install #+ ###########++ # Create a virtual environment using the project Python version+ venv:+ # Invokes `python<version>`, like `python3.10`+ bash -c "python$PROJECT_PY_VERSION -m venv venv/"++ # Check that the active Python version matches the required Python version+ check-py-version:+ #!/usr/bin/env python+ import os+ import sys+ current = f"{sys.version_info[0]}.{sys.version_info[1]}"+ required = os.environ.get("PROJECT_PY_VERSION")+ if current != required:+ print(f"Detected Python version {current} but required {required}", file=sys.stderr)+ sys.exit(1)++ # Install dependencies+ install *args: check-py-version+ python -m pip install -r requirements_tooling.txt -r requirements_dev.txt++ ######+ # Up #+ ######++ # Bring up services specific to the catalog profile+ up *flags:+ env COMPOSE_PROFILES="catalog" just ../up {{ flags }}++ # Bring up services specific to the catalog profile, except Airflow+ up-deps *flags:+ env COMPOSE_PROFILES="catalog_dependencies" just ../up {{ flags }}++ ##################+ # Administration #+ ##################++ # Launch a Bash shell in an existing container under `SERVICE`+ shell:- just ../exec {{ SERVICE }} /bin/bash++ env DC_USER="airflow" just ../exec {{ SERVICE }} /bin/bash++ # Launch an IPython shell in a new container under `SERVICE`+ ipython: up-deps- just ../run \++ env DC_USER="airflow" just ../run \+ --rm \+ --workdir /opt/airflow/catalog/dags \+ {{ SERVICE }} \+ bash -c \'ipython\'++ # Launch a `pgcli` shell in the PostgreSQL container (requires typing credentials)+ pgcli db_host="postgres" db_name="openledger" db_user="airflow":- env DC_USER="root" just ../exec postgres pgcli -h {{ db_host }} {{ db_name }} {{ db_user }}++ just ../exec postgres pgcli -h {{ db_host }} {{ db_name }} {{ db_user }}++ #########+ # Tests #+ #########++ # Run a command in a test container under `SERVICE`+ _mount-test command: up-deps- just ../run \++ env DC_USER="airflow" just ../run \+ --rm \+ -e AIRFLOW_VAR_INGESTION_LIMIT=1000000 \+ -w /opt/airflow/catalog \+ --volume {{ justfile_directory() }}/../docker:/opt/airflow/docker/ \+ {{ SERVICE }} \+ {{ command }}++ # Launch a Bash shell in a test container under `SERVICE`+ test-session:+ just _mount-test bash++ # Run pytest in a test container under `SERVICE`+ test *args:+ just _mount-test "bash -c \'pytest {{ args }}\'"++ #############+ # Utilities #+ #############++ # Generate the DAG documentation+ generate-dag-docs fail_on_diff="false":+ #!/bin/bash+ set -e- DC_USER=root just ../run \++ just ../run \+ {{ SERVICE }} \+ "bash -c 'python catalog/utilities/dag_doc_gen/dag_doc_generation.py && chmod 666 /opt/airflow/catalog/utilities/dag_doc_gen/DAGs.md'"+ # Move the file to the top level, since that level is not mounted into the container+ mv 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+ if [ $? -ne 0 ]; then+ printf "\n\n\e[31m!! Changes found in DAG documentation, please run 'just generate-dag-docs' locally and commit difference !!\n\n"+ exit 1+ fi+ fi++ # Generate files for a new provider+ add-provider provider_name endpoint +media_types="image":+ python3 templates/create_provider_ingester.py "{{ provider_name }}" "{{ endpoint }}" -m {{ media_types }}diff --cc docker-compose.ymlindex 663e522a6,6682b54f0..29018805c--- a/docker-compose.yml+++ b/docker-compose.yml@@@ -1,197 -1,138 +1,322 @@@-version: "3"+version: "2.4"++ # Common build configuration for Airflow+ # Extension field, see https://docs.docker.com/compose/compose-file/compose-file-v3/#extension-fields+ x-airflow-common: &airflow-common+ profiles:+ - catalog+ restart: on-failure+ depends_on:+ - postgres+ - s3+ image: openverse_catalog+ env_file:+ - .env+ - catalog/.env+ build:+ context: ./catalog/+ args:+ - REQUIREMENTS_FILE=requirements_dev.txt+ - PROJECT_PY_VERSION=${PROJECT_PY_VERSION}+ - PROJECT_AIRFLOW_VERSION=${PROJECT_AIRFLOW_VERSION}+ volumes:+ - ./catalog:/opt/airflow/catalog- - ipython:/home/airflow/.ipython- - pytest_cache:/home/airflow/.cache/pytest++ - catalog-ipython:/home/airflow/.ipython++ - catalog-pytest-cache:/home/airflow/.cache/pytest+services:- # Services only needed for local development- postgres:++ # Database used by the API+ db:profiles:- - catalog_dependencies- - catalog- build: docker/local_postgres- env_file:- - docker/local_postgres/.env+ - ingestion_server+ - api+ image: postgres:13.2-alpineports:- - "5434:5432"+ - "50254:5432"+ volumes:+ - api-postgres:/var/lib/postgresql/data+ env_file:+ - docker/db/env.docker+ healthcheck:+ test: "pg_isready -U deploy -d openledger"+++ # Database used by the catalog+ upstream_db:+ profiles:++ - catalog++ - catalog_dependencies+ - ingestion_server+ - api+ build: ./docker/upstream_db/+ image: openverse-upstream_db+ expose:+ - "5432"volumes:- - postgres:/var/lib/postgresql/data+ - catalog-postgres:/var/lib/postgresql/data+ - ./sample_data:/sample_data+ env_file:+ - docker/upstream_db/env.docker+ healthcheck:+ test: "pg_isready -U deploy -d openledger"+ s3:+ profiles:+ - catalog_dependencies+ - catalog+ image: minio/minio:latest+ ports:+ - "5010:5000"+ - "5011:5001"+ env_file:+ - .env+ - docker/minio/.env+ # Create empty buckets on every container startup+ # Note: $0 is included in the exec because "/bin/bash -c" swallows the first+ # argument, so it must be re-added at the beginning of the exec call+ entrypoint: >-+ /bin/bash -c+ "for b in $${BUCKETS_TO_CREATE//,/ }; do+ echo \"Making bucket $$b\" && mkdir -p /data/$$b;+ done &&+ exec $$0 \"$$@\""+ command: minio server /data --address :5000 --console-address :5001+ volumes:+ - minio:/data+ healthcheck:+ test: ["CMD", "curl", "-f", "http://localhost:5010/minio/health/live"]+ interval: 30s+ timeout: 20s+ retries: 3++ load_to_s3:+ profiles:+ - catalog_dependencies+ - catalog+ image: minio/mc:latest+ env_file:+ - .env+ - docker/minio/.env+ depends_on:+ - s3+ volumes:+ # Buckets for testing provider data imported from s3 are subdirectories under+ # /tests/s3-data/+ - ./catalog/tests/s3-data:/data:rw+ # Loop through subdirectories mounted to the volume and load them to s3/minio.+ # This takes care of filesystem delays on some local dev environments that may make+ # minio miss files included directly in the minio volume.+ # More info here: https://stackoverflow.com/questions/72867045+ # This does *not* allow for testing permissions issues that may come up in real AWS.+ # And, if you remove files from /tests/s3-data, you will need to use `just down -v`+ # and `just up` or `just recreate` to see the minio bucket without those files.+ entrypoint: >+ /bin/sh -c "+ /usr/bin/mc config host add s3 http://s3:5000 $${AWS_ACCESS_KEY} $${AWS_SECRET_KEY};+ cd /data;+ for b in */ ; do+ echo \"Loading bucket $$b\"+ /usr/bin/mc mb --ignore-existing s3/$$b+ /usr/bin/mc cp --r $$b s3/$$b+ /usr/bin/mc ls s3/$$b;+ done ;+ exit 0;+ "++ # Dev changes for the scheduler+ scheduler:+ <<: *airflow-common+ depends_on:- - postgres++ - upstream_db+ - s3+ command: scheduler+ expose:+ - "8793" # Used for fetching logs+ environment:+ # Upgrade the DB on startup+ _AIRFLOW_DB_UPGRADE: "true"+ _AIRFLOW_WWW_USER_CREATE: "true"+ _AIRFLOW_WWW_USER_USERNAME: airflow+ _AIRFLOW_WWW_USER_PASSWORD: airflow+ _AIRFLOW_WWW_USER_FIRSTNAME: Air+ _AIRFLOW_WWW_USER_LASTNAME: Flow+ _AIRFLOW_WWW_USER_EMAIL: [email protected]++ # Dev changes for the webserver container+ webserver:+ <<: *airflow-common+ depends_on:- - postgres++ - upstream_db+ - s3+ - scheduler+ command: webserver+ ports:+ - "${AIRFLOW_PORT}:8080"++ plausible_db:+ profiles:+ - frontend+ image: postgres:13.2-alpine+ expose:+ - "5432"+ volumes:+ - plausible-postgres:/var/lib/postgresql/data+ env_file:+ - ./docker/plausible_db/env.docker+ healthcheck:+ test: "pg_isready -U deploy -d plausible"++ plausible_ch:+ profiles:+ - frontend+ image: clickhouse/clickhouse-server:22.6-alpine+ volumes:+ - plausible-clickhouse:/var/lib/clickhouse+ - ./docker/clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro+ - ./docker/clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro+ ulimits:+ nofile:+ soft: 262144+ hard: 262144++ plausible:+ profiles:+ - frontend+ image: plausible/analytics:latest+ ports:+ - "50288:8000"+ command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"+ depends_on:+ - plausible_db+ - plausible_ch+ env_file:+ - docker/plausible/env.docker++ cache:+ profiles:+ - api+ image: redis:4.0.14+ ports:+ - "50263:6379"++ es:+ profiles:+ - ingestion_server+ - api+ image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0+ ports:+ - "50292:9200"+ env_file:+ - docker/es/env.docker+ healthcheck:+ test:+ [+ "CMD-SHELL",+ "curl -si -XGET 'localhost:9200/_cluster/health?pretty' | grep -qE 'yellow|green'",+ ]+ interval: 10s+ timeout: 60s+ retries: 10+ ulimits:+ nofile:+ soft: 65536+ hard: 65536+ # Memory limit for ES, as it tends to be a memory hoarder+ # Set this value to an empty string to remove the limit+ # https://docs.docker.com/compose/compose-file/compose-file-v2/#cpu-and-other-resources+ mem_limit: ${ES_MEM_LIMIT:-4294967296} # 4 GiB in bytes+ volumes:+ - es-data:/usr/share/elasticsearch/data++ web:+ profiles:+ - api+ build:+ context: ./api/+ target: api+ args:+ SEMANTIC_VERSION: ${SEMANTIC_VERSION:-v1.0.0}+ image: openverse-api+ volumes:+ - ./api:/api+ ports:+ - "50280:8000" # Django+ - "50230:3000" # Sphinx (unused by default; see `sphinx-live` recipe)+ depends_on:+ - db+ - es+ - cache+ env_file:+ - api/env.docker+ - api/.env+ environment:+ STATIC_ROOT: ${STATIC_ROOT:-}+ MEDIA_ROOT: ${MEDIA_ROOT:-}+ stdin_open: true+ tty: true++ ingestion_server:+ profiles:+ - ingestion_server+ - api+ build: ./ingestion_server/+ image: openverse-ingestion_server+ command: gunicorn -c ./gunicorn.conf.py+ ports:+ - "50281:8001"+ depends_on:+ - db+ - upstream_db+ - es+ - indexer_worker+ volumes:+ - ./ingestion_server:/ingestion_server+ env_file:+ - ingestion_server/env.docker+ - ingestion_server/.env+ stdin_open: true+ tty: true++ indexer_worker:+ profiles:+ - ingestion_server+ - api+ build: ./ingestion_server/+ image: openverse-ingestion_server+ command: gunicorn -c ./gunicorn_worker.conf.py+ expose:+ - "8002"+ depends_on:+ - db+ - upstream_db+ - es+ volumes:+ - ./ingestion_server:/ingestion_server+ env_file:+ - ingestion_server/env.docker+ stdin_open: true+ tty: true++ proxy:+ profiles:+ - api+ image: nginx:alpine+ ports:+ - "50200:9080"+ - "50243:9443"+ environment:+ HTTPS_PORT: 50243 # See `ports` mapping above.+ depends_on:+ - web+ volumes:+ - ./docker/nginx/templates:/etc/nginx/templates+ - ./docker/nginx/certs:/etc/nginx/certs+volumes:- postgres:+ api-postgres:+ catalog-postgres:+ plausible-postgres:+ plausible-clickhouse:+ es-data:+ minio:- ipython:- pytest_cache:++ catalog-ipython:++ catalog-pytest-cache:diff --cc justfileindex 9bb87d65b,5fa47fcb5..234a4674c--- a/justfile+++ b/justfile@@@ -4,37 -4,14 +4,39 @@@ set dotenv-load := fals# @ - Quiet recipes (https://github.com/casey/just#quiet-recipes)# _ - Private recipes (https://github.com/casey/just#private-recipes)- IS_PROD := env_var_or_default("PROD", "")-# The monorepo uses `PROD` instead of `IS_PROD`.-IS_PROD := env_var_or_default("IS_PROD", "")++IS_PROD := env_var_or_default("PROD", env_var_or_default("IS_PROD", ""))++# `PROD_ENV` can be "ingestion_server" or "catalog"++PROD_ENV := env_var_or_default("PROD_ENV", "")IS_CI := env_var_or_default("CI", "")- DC_USER := env_var_or_default("DC_USER", "opener")-# Show all available recipes+# Show all available recipes, also recurses inside nested justfiles@_default:- just --list --unsorted- cd catalog/ && just+ just --list --unsorted+ cd docker/nginx && just+ cd docker/es && just++ cd catalog && just+ cd api && just+ cd ingestion_server && just+ cd frontend && just+ cd automations/python && just+ cd automations/js && just+ cd documentation && just+ printf "\nTo run a nested recipe, add the folder path before it, like \`just frontend/install\`.\n"++###########+# Helpers #+###########++# Sleep for given time showing the given message as long as given condition is met+@_loop condition message timeout="5m" time="5":+ timeout --foreground {{ timeout }} bash -c 'while [ {{ condition }} ]; do \+ echo "{{ message }}" && sleep {{ time }}; \+ done'; \+ EXIT_CODE=$?; \+ if [ $EXIT_CODE -eq 124 ]; then \+ echo "Timed out"; \+ exit $EXIT_CODE; \+ fi######## Dev #@@@ -92,18 -53,28 +94,33 @@@ lint hook="" *files="": precommi######### Create .env files from templates-@env:+env:- cp api/env.template api/.env- cp ingestion_server/env.template ingestion_server/.env+ # Root+ ([ ! -f .env ] && cp env.template .env) || true+ # Docker+ ([ ! -f docker/local_postgres/.env ] && cp docker/local_postgres/env.template docker/local_postgres/.env) || true+ ([ ! -f docker/minio/.env ] && cp docker/minio/env.template docker/minio/.env) || true- # First party services++ # First-party services+ ([ ! -f catalog/.env ] && cp catalog/env.template catalog/.env) || true++ ([ ! -f ingestion_server/.env ] && cp ingestion_server/env.template ingestion_server/.env) || true++ ([ ! -f api/.env ] && cp api/env.template api/.env) || true########### Docker ###########DOCKER_FILE := "-f " + (- if IS_PROD == "true" { "ingestion_server/docker-compose.yml" }- if IS_PROD == "true" { "catalog/docker-compose.yml" }++ if IS_PROD == "true" {++ if PROD_ENV == "ingestion_server" { "ingestion_server/docker-compose.yml" }++ else if PROD_ENV == "catalog" { "catalog/docker-compose.yml" }++ else { "docker-compose.yml" }++ }else { "docker-compose.yml" })+ EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }-DC_USER := env_var_or_default("DC_USER", "airflow")++ export PROJECT_PY_VERSION := `just catalog/py-version`+ export PROJECT_AIRFLOW_VERSION := `just catalog/airflow-version`# Run `docker-compose` configured with the correct files and environmentdc *args:@@@ -130,9 -101,7 +147,10 @@@ up *flags# Also see `wait-up` recipe in sub-justfiles# Wait for all services to be upwait-up: up+ just ingestion_server/wait-up+ just api/wait-up+ just frontend/wait-up+ just catalog/wait-up# Also see `init` recipe in sub-justfiles# Load sample data into the Docker Compose services@@@ -158,8 -126,20 +176,20 @@@ logs services="" args=(if IS_CI != ""attach service:docker attach $(docker-compose ps | grep {{ service }} | awk '{print $1}')- EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }-# Execute statement in service containers using Docker Composeexec +args:-- just dc exec -u {{ DC_USER }} {{ EXEC_DEFAULTS }} {{ args }}++ just dc exec -u {{ env_var_or_default("DC_USER", "root") }} {{ EXEC_DEFAULTS }} {{ args }}++ # Execute statement in a new service container using Docker Compose+ run +args:- just dc run -u {{ DC_USER }} {{ EXEC_DEFAULTS }} "{{ args }}"++ just dc run -u {{ env_var_or_default("DC_USER", "root") }} {{ EXEC_DEFAULTS }} "{{ args }}"++ ########+ # Misc #+ ########++ # Pull, build, and deploy all services+ deploy:+ -git pull+ @just pull+ @just updiff --cc templates/pull_request_template.md.jinjaindex c779919e2,000000000..f4d2fb41bmode 100644,000000..100644--- a/templates/pull_request_template.md.jinja+++ b/templates/pull_request_template.md.jinja@@@ -1,87 -1,0 +1,88 @@@+## 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. -->++{% block additional_sections %}+{% endblock -%}++## 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 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 ran the DAG documentation generator (only applicable for catalog PRs).+{% block additional_checks %}+{% endblock %}++[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>+<summary>Developer Certificate of Origin</summary>++```+Developer Certificate of Origin+Version 1.1++Copyright (C) 2004, 2006 The Linux Foundation and its contributors.+1 Letterman Drive+Suite D4700+San Francisco, CA, 94129++Everyone is permitted to copy and distribute verbatim copies of this+license document, but changing it is not allowed.+++Developer's Certificate of Origin 1.1++By making a contribution to this project, I certify that:++(a) The contribution was created in whole or in part by me and I+ have the right to submit it under the open source license+ indicated in the file; or++(b) The contribution is based upon previous work that, to the best+ of my knowledge, is covered under an appropriate open source+ license and I have the right under that license to submit that+ work with modifications, whether created in whole or in part+ by me, under the same open source license (unless I am+ permitted to submit under a different license), as indicated+ in the file; or++(c) The contribution was provided directly to me by some other+ person who certified (a), (b) or (c) and I have not modified+ it.++(d) I understand and agree that this project and the contribution+ are public and that a record of the contribution (including all+ personal information I submit with it, including my sign-off) is+ maintained indefinitely and may be redistributed consistent with+ this project or the open source license(s) involved.+```++</details>