Navigation Menu

Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Remove get_*_operator functions, simplify commoncrawl logic #301

Merged
merged 3 commits into from Dec 10, 2021

Conversation

AetherUnbound
Copy link
Contributor

Fixes

Fixes #242 by @AetherUnbound

Description

As described in #242, many of the get_*_operator functions are only used once and create an unnecessary level of indirection when trying to view a DAG definition. This PR attempts to remove all get_*_operator functions and replace them with operator definitions directly within the DAG definition.

The commoncrawl DAGs were the most complex to refactor, and I ended up creating a utility function to house some of the utilities that were defined in the operators.py file initially.

While attempting to verify this I also found that our .airflowignore file was a bit too permissive and was preventing the commoncrawl DAGs from being parsed. I corrected this behavior and the DAGs parsed just fine.

Testing Instructions

just test and just run airflow dags list, specifically checking for the presence of commoncrawl DAGs!

Checklist

  • 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.
  • 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.

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.

@AetherUnbound AetherUnbound requested a review from a team as a code owner December 9, 2021 21:05
@AetherUnbound AetherUnbound added ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🟩 priority: low Low priority and doesn't need to be rushed labels Dec 9, 2021
@dhruvkb dhruvkb added this to Needs review in Openverse PRs Dec 9, 2021
Comment on lines +151 to +153
# This was "--default" previously but a task within the DAG
# modified it on DAG parse time to be this value.
CC_INDEX_TEMPLATE,
Copy link
Member

Choose a reason for hiding this comment

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

Nice cleanup!

Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM!

Here's the testing output:

#############################################################################
                         RUNNING "airflow dags list"
#############################################################################
dag_id                    | filepath                | owner          | paused
==========================+=========================+================+=======
airflow_log_cleanup       | maintenance/airflow_log | data-eng-admin | True  
                          | _cleanup_workflow.py    |                |       
brooklyn_museum_workflow  | providers/brooklyn_muse | data-eng-admin | True  
                          | um_workflow.py          |                |       
check_new_smithsonian_uni | providers/check_new_smi | data-eng-admin | True  
t_codes_workflow          | thsonian_unit_codes_wor |                |       
                          | kflow.py                |                |       
cleveland_museum_workflow | providers/cleveland_mus | data-eng-admin | True  
                          | eum_workflow.py         |                |       
commoncrawl_etl_workflow  | commoncrawl/commoncrawl | data-eng-admin | True  
                          | _etl.py                 |                |       
europeana_ingestion_workf | providers/europeana_ing | data-eng-admin | True  
low                       | estion_workflow.py      |                |       
europeana_workflow        | providers/europeana_wor | data-eng-admin | True  
                          | kflow.py                |                |       
finnish_museums_workflow  | providers/finnish_museu | data-eng-admin | True  
                          | ms_workflow.py          |                |       
flickr_ingestion_workflow | providers/flickr_ingest | data-eng-admin | True  
                          | ion_workflow.py         |                |       
flickr_workflow           | providers/flickr_workfl | data-eng-admin | True  
                          | ow.py                   |                |       
freesound_workflow        | providers/freesound_wor | data-eng-admin | True  
                          | kflow.py                |                |       
image_expiration_workflow | database/image_expirati | data-eng-admin | True  
                          | on_workflow.py          |                |       
jamendo_workflow          | providers/jamendo_workf | data-eng-admin | True  
                          | low.py                  |                |       
metropolitan_museum_workf | providers/metropolitan_ | data-eng-admin | True  
low                       | museum_workflow.py      |                |       
museum_victoria_workflow  | providers/museum_victor | data-eng-admin | True  
                          | ia_workflow.py          |                |       
nypl_workflow             | providers/nypl_workflow | data-eng-admin | True  
                          | .py                     |                |       
oauth2_authorization      | oauth2/authorize_dag.py | data-eng-admin | True  
oauth2_token_refresh      | oauth2/token_refresh_da | data-eng-admin | True  
                          | g.py                    |                |       
phylopic_workflow         | providers/phylopic_work | data-eng-admin | True  
                          | flow.py                 |                |       
rawpixel_workflow         | providers/rawpixel_work | data-eng-admin | True  
                          | flow.py                 |                |       
recreate_audio_popularity | database/recreate_audio | data-eng-admin | True  
_calculation              | _popularity_calculation |                |       
                          | .py                     |                |       
recreate_image_popularity | database/recreate_image | data-eng-admin | True  
_calculation              | _popularity_calculation |                |       
                          | .py                     |                |       
refresh_all_audio_popular | database/refresh_all_au | data-eng-admin | True  
ity_data                  | dio_popularity_data.py  |                |       
refresh_all_image_popular | database/refresh_all_im | data-eng-admin | True  
ity_data                  | age_popularity_data.py  |                |       
refresh_audio_view_data   | database/refresh_audio_ | data-eng-admin | True  
                          | view_data.py            |                |       
refresh_image_view_data   | database/refresh_image_ | data-eng-admin | True  
                          | view_data.py            |                |       
science_museum_workflow   | providers/science_museu | data-eng-admin | True  
                          | m_workflow.py           |                |       
smithsonian_workflow      | providers/smithsonian_w | data-eng-admin | True  
                          | orkflow.py              |                |       
staten_museum_workflow    | providers/statens_museu | data-eng-admin | True  
                          | m_workflow.py           |                |       
stocksnap_workflow        | providers/stocksnap_wor | data-eng-admin | True  
                          | kflow.py                |                |       
sync_commoncrawl_workflow | commoncrawl/sync_common | data-eng-admin | True  
                          | crawl_workflow.py       |                |       
tsv_to_postgres_loader    | database/loader_workflo | data-eng-admin | True  
                          | w.py                    |                |       
walters_workflow          | providers/walters_workf | data-eng-admin | True  
                          | low.py                  |                |       
wikimedia_commons_workflo | providers/wikimedia_wor | data-eng-admin | True  
w                         | kflow.py                |                |       
wikimedia_ingestion_workf | providers/wikimedia_ing | data-eng-admin | True  
low                       | estion_workflow.py      |                |       
wordpress_workflow        | providers/wordpress_wor | data-eng-admin | True  
                          | kflow.py                |                |       
                                                                             

I see two commoncrawl entries. Is that all that should be there?

Openverse PRs automation moved this from Needs review to Reviewer approved Dec 10, 2021
@AetherUnbound
Copy link
Contributor Author

I see two commoncrawl entries. Is that all that should be there?

That's correct!

@AetherUnbound AetherUnbound merged commit 12f8000 into main Dec 10, 2021
Openverse PRs automation moved this from Reviewer approved to Merged! Dec 10, 2021
@AetherUnbound AetherUnbound deleted the feature/remove-get-operator-funcs#242 branch December 10, 2021 18:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed
Projects
No open projects
Openverse PRs
  
Merged!
Development

Successfully merging this pull request may close these issues.

[Improvement] Use operators directly, remove get_.*_operator functions
3 participants