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

Refactor StockSnap to use ProviderDataIngester #601

Merged
merged 24 commits into from
Jul 13, 2022

Conversation

rwidom
Copy link
Collaborator

@rwidom rwidom commented Jul 3, 2022

Fixes

Fixes WordPress/openverse#1512 by @stacimc

Description

Moves StockSnap provider API script to use the new ProviderDataIngester class, and updates a couple of the url and title details. (More detail in #299 and #555 ).

Testing Instructions

Check out the branch, and run just test as one piece.

You can also go to the Airflow page and manually kick off the stocksnap_workflow dag, and take a look at the resulting tsv file. The Airflow log will give you the exact file name, and you can see it by running just shell and more /var/workflow_output/stocksnap_image_v001_20220713202334.tsv (or whatever the file is called). My only hesitation with running it that way is wanting to avoid abusing / overwhelming the stocksnap API.

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.

@rwidom rwidom requested a review from a team as a code owner July 3, 2022 22:31
@openverse-bot openverse-bot 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 Jul 3, 2022
Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

🎉 I am so excited to see this @rwidom, thanks for picking this up!

I was able to run this locally with real data, but first you'll need to update the StockSnap provider workflow definition in provider_workflows.py to configure the ingester class:

ProviderWorkflow(
    provider_script="stocksnap",
    ingester_class=StockSnapDataIngester,
)

I left a couple comments for some errors being thrown at the moment, but then you should be able to run this locally and actually pull data. I don't think an API key is necessary.

StockSnap doesn't use query parameters, but reflects the incremental page in the endpoint url

All of these providers seem to have some little quirk! 😄 I like your idea of updating the endpoint with a page counter.

@rwidom
Copy link
Collaborator Author

rwidom commented Jul 6, 2022

I don't seem to be able to run this with real data locally (at least, when I do just down -v, just recreate, and then go to my local airflow site and click run on stocksnap, it runs twice "successfully" but skips writing to or pulling from S3 both times, and I can't find any tmp directory with tsv files on my local machine after a very quick look), but that might be about separate issues with my local set-up, which I'm going to delve into more with @sarayourfriend later this week.

I think everything else is resolved?

Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

Just a couple quick comments I forgot as I was re-testing this -- thanks for your perseverance despite not being able to run this locally! I do think your problems must be related to your environment setup, since the API does not require authentication 😞

After those comments though, I was able to run StockSnap with and without an ingestion_limit and pull/load data perfectly 🎉

@rwidom rwidom requested a review from stacimc July 11, 2022 20:35
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

I can't provide as many in-depth suggestions for the actual code as other folks on the team, but I'm able to run this locally without issue. It's great to see the new ProviderDataIngester in action!

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.

This is great @rwidom! I hope you have been able to run it, it's working well. I have left just a few comments to improve the data we are getting from this provider, but really this is almost nearly complete. Excellent work!

Copy link
Contributor

@stacimc stacimc 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 so much for your perseverance with local testing issues :) Everything looks good, and running locally works great.

@rwidom
Copy link
Collaborator Author

rwidom commented Jul 13, 2022

Thanks so much @zackkrida , @krysal and @stacimc!

@rwidom
Copy link
Collaborator Author

rwidom commented Jul 13, 2022

💯 This looks great! Thanks so much for your perseverance with local testing issues :) Everything looks good, and running locally works great.

Thanks so much! I didn't see it had been approved when I just edited the overview. Oh well. Either way-- Yay! Onward!

@rwidom rwidom merged commit cc7322b into main Jul 13, 2022
@rwidom rwidom deleted the issue/595-refactor-stocksnap-4-newingester branch July 13, 2022 23:02
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
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Stocksnap to use ProviderDataIngester
5 participants