Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add batched catalog_cleaner DAG #3601

Closed
wants to merge 3 commits into from
Closed

Add batched catalog_cleaner DAG #3601

wants to merge 3 commits into from

Conversation

krysal
Copy link
Member

@krysal krysal commented Dec 29, 2023

Fixes

Related to #3415 by @obulat

Description

WIP. Tested with TSV files found in the S3 bucket .../shared/data-refresh-cleaned-data. The files for titles and tags were missing so I made only for URL fields.

Testing Instructions

To try locally, store the TSV files in tha DAG's folder. You will also need some of the dirty data there from upstream I'll prepare a file later but if you have access, you can download and upload the file as follows.

  1. Download upstream sample data. These sources are two of the ones that need the HTTP protocol in the image or creator URL.
# Taken from upstream db
\copy (SELECT * FROM image WHERE source IN ('animaldiversity', 'geographorguk') LIMIT 20000)
     TO '/tmp/bad_rows_sample.csv' DELIMITER ',' CSV HEADER;
  1. Start the catalog stack
just catalog/up
  1. Copy the sample data to the database container
docker cp /tmp/bad_rows_sample.csv openverse-upstream_db-1:/tmp/bad_rows_sample.csv
  1. Copy the sample data to the database
just catalog/pgcli
\copy image from '/tmp/bad_rows_sample.csv' WITH (FORMAT CSV, HEADER)

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow 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 (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
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.

@krysal krysal added 🟧 priority: high Stalls work on the project or its dependents 🌟 goal: addition Addition of new feature 💻 aspect: code Concerns the software code in the repository 🧱 stack: catalog Related to the catalog and Airflow DAGs labels Dec 29, 2023
Copy link

Full-stack documentation: https://docs.openverse.org/_preview/3601

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 to see the current status of the deployments.

Changed files 🔄:

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic, @krysal! I'll be testing this PR locally, thank you for the detailed instructions on getting the data from prod.
I have a note on the name for this DAG: I believe this DAG could be used for updates that are not related to cleaning in the future. For instance, if we create a DAG that collects the filetype data in the same format (CSV with identifier and filetype), we could use this DAG. We could also use it for machine-generated tags (but I guess this would require upsert, not just replacement?), or the dimensions data (width, height - but this would also require updating the SQL command to allow for updating 2 columns at once?)
I'm not suggesting the addition of this functionality (upserting, handling of more than one column) in this PR, but I think changing the name of the DAG here to allow for these additions later could be appropriate. Or do you think it's better to create new similar DAGs later, @krysal?

@AetherUnbound AetherUnbound mentioned this pull request Jan 3, 2024
@krysal krysal force-pushed the catalog_cleaner_dag branch from 754b654 to b76b0e9 Compare January 26, 2024 15:46
@krysal
Copy link
Member Author

krysal commented Feb 8, 2024

I have a note on the name for this DAG: I believe this DAG could be used for updates that are not related to cleaning in the future. For instance, if we create a DAG that collects the filetype data in the same format (CSV with identifier and filetype), we could use this DAG.

@obulat That sounds like an interesting approach! I was focused on the case we have at hand, but I see it can be useful to generalize the DAG. I'll take note and close this for now given the project needs an official proposal plus an implementation plan. Also, sorry for taking so long to respond! I had to focus on other unfinished routes. This will be resumed in no time.

@krysal krysal closed this Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🌟 goal: addition Addition of new feature 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: catalog Related to the catalog and Airflow DAGs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants