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

Replace media_url with url in provider scripts #1891

Merged
merged 3 commits into from
May 17, 2023

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Apr 24, 2023

Fixes

Fixes #1409 by @stacimc

Description

This PR renames audio_url and image_url in the provider API scripts and ImageStore/AudioStore classes to url, which simplifies the code significantly.

Testing Instructions

The CI should pass. The tests have been updated to use url instead of image_url/audio_url

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.

@obulat obulat requested review from a team as code owners April 24, 2023 15:37
@obulat obulat requested review from krysal and AetherUnbound April 24, 2023 15:37
@obulat obulat added 🟨 priority: medium Not blocking but should be addressed soon ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository labels Apr 24, 2023
@openverse-bot openverse-bot added the 🟨 priority: medium Not blocking but should be addressed soon label Apr 24, 2023
@obulat obulat added the 🧱 stack: catalog Related to the catalog and Airflow DAGs label Apr 24, 2023
@openverse-bot openverse-bot added ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🧱 stack: catalog Related to the catalog and Airflow DAGs 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Apr 24, 2023
Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

It looks like there's a failing test for the provider data ingester:

 =================================== FAILURES ===================================
_____________________________ test_get_batch_data ______________________________
[gw1] linux -- Python 3.10.10 /usr/local/bin/python

    def test_get_batch_data():
        response_json = _get_resource_json("complete_response.json")
        batch = ingester.get_batch_data(response_json)
    
>       assert batch == EXPECTED_BATCH_DATA
E       AssertionError: assert [{'id': 100, ...le 102', ...}] == [{'id': 100, ...534_web.jpg'}]
E         At index 0 diff: {'id': 100, 'image_url': 'https://openaccess-cdn.clevelandart.org/1916.586.a/1916.586.a_web.jpg', 'media_type': 'image', 'title': 'Title 100', 'url': 'https://clevelandart.org/art/1916.586.a'} != {'id': 100, 'media_type': 'image', 'title': 'Title 100', 'url': 'https://openaccess-cdn.clevelandart.org/1916.586.a/1916.586.a_web.jpg'}
E         Use -v to get more diff

tests/dags/providers/provider_api_scripts/test_provider_data_ingester.py:137: AssertionError
=========================== short test summary info ============================
FAILED tests/dags/providers/provider_api_scripts/test_provider_data_ingester.py::test_get_batch_data

Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

I'm also getting the following when I run the SMK DAG locally:

[2023-04-25, 00:09:13 UTC] {slack.py:320} INFO - 
*DAG*: `smk_workflow`
*Task*: `ingest_data.pull_image_data`
*Logical Date*: 2023-03-01T00:00:00Z
*Log*: http://localhost:8080/log?execution_date=2023-03-01T00%3A00%3A00%2B00%3A00&task_id=ingest_data.pull_image_data&dag_id=smk_workflow&map_index=-1

*Exception*: ImageStore.add_item() missing 1 required positional argument: 'url'
*Exception Type*: `builtins.TypeError`

It looks like this piece was not updated:

"image_url": img.get("image_url"),

I think with a change this large, we'll need to be sure we are able to run each affected DAG successfully locally before we deploy it (I wish there was a better way, maybe some ingestion testing in the future!)

@@ -123,13 +123,13 @@ def clean_media_metadata(self, **media_data) -> dict | None:
for field in [
"foreign_identifier",
"foreign_landing_url",
f"{self.media_type}_url",
"url",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whew, this is a nice change to see!

@obulat obulat removed the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label Apr 25, 2023
@obulat obulat force-pushed the rename/image_url_and_audio_url branch 2 times, most recently from f53a1f7 to acca578 Compare April 25, 2023 10:31
@obulat obulat force-pushed the rename/image_url_and_audio_url branch from f87e1a5 to a57ca3f Compare April 28, 2023 14:34
@obulat obulat self-assigned this Apr 30, 2023
@krysal
Copy link
Member

krysal commented May 2, 2023

@obulat Is this PR ready for review or it is a work in progress?

@obulat obulat force-pushed the rename/image_url_and_audio_url branch from a57ca3f to f26ace3 Compare May 2, 2023 15:15
@obulat obulat changed the base branch from main to refactor/license_info May 2, 2023 15:16
@obulat
Copy link
Contributor Author

obulat commented May 2, 2023

@obulat Is this PR ready for review or it is a work in progress?

I've rebased it onto the license_info PR, and am going to draft it until that PR is merge. I will run the ingestion for all providers locally after that to check that everything works as expected.

@obulat obulat marked this pull request as draft May 2, 2023 15:17
@obulat obulat force-pushed the refactor/license_info branch from 9ce9453 to 6a749c9 Compare May 2, 2023 18:56
@obulat obulat force-pushed the rename/image_url_and_audio_url branch from f26ace3 to 1c7ca3c Compare May 2, 2023 18:58
@obulat obulat force-pushed the refactor/license_info branch from 6a749c9 to 127781b Compare May 3, 2023 03:16
@obulat obulat force-pushed the rename/image_url_and_audio_url branch from 1c7ca3c to 1026c55 Compare May 3, 2023 03:20
Base automatically changed from refactor/license_info to main May 3, 2023 03:34
@obulat obulat force-pushed the rename/image_url_and_audio_url branch 3 times, most recently from b6796a6 to fbad818 Compare May 10, 2023 13:03
@obulat obulat marked this pull request as ready for review May 10, 2023 13:03
@obulat
Copy link
Contributor Author

obulat commented May 10, 2023

@AetherUnbound, I ran data ingestion locally, and did not get any url-related errors. All but two providers correctly load data. I do get errors in rawpixel (403 response in Airflow, although if I open the link in the browser - it shows results) and iNaturalist (something with local setup in the preingestion tasks).

@obulat obulat requested a review from AetherUnbound May 10, 2023 14:38
@obulat obulat force-pushed the rename/image_url_and_audio_url branch from fbad818 to d1c714b Compare May 10, 2023 14:39
Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for testing all the provider scripts! 🙌🏼 I have one thought for a variable rename but it's not blocking.

@@ -52,7 +52,7 @@ class NyplDataIngester(ProviderDataIngester):
# NYPL returns a list of image objects, with the dimension encoded
# in the URL's query parameter.
# This list is in order from the largest image to the smallest one.
image_url_dimensions = ["g", "v", "q", "w", "r"]
url_dimensions = ["g", "v", "q", "w", "r"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this would be better as image_dimensions?

@openverse-bot
Copy link
Collaborator

Based on the medium urgency of this PR, the following reviewers are being gently reminded to review this PR:

@krysal
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 4 day(s) ago. PRs labelled with medium urgency are expected to be reviewed within 4 weekday(s)2.

@obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

@obulat obulat force-pushed the rename/image_url_and_audio_url branch from d1c714b to 7801638 Compare May 17, 2023 09:46
Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

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

LGTM. Great to have the url column simplified 👏

@obulat obulat merged commit 614720f into main May 17, 2023
@obulat obulat deleted the rename/image_url_and_audio_url branch May 17, 2023 15:56
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: improvement Improvement to an existing user-facing feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: catalog Related to the catalog and Airflow DAGs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Consider using url as field name in provider scripts
4 participants