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

Fill creator name in finnish museum DAG #978

Merged
merged 13 commits into from
Feb 1, 2023
Merged

Fill creator name in finnish museum DAG #978

merged 13 commits into from
Feb 1, 2023

Conversation

krysal
Copy link
Member

@krysal krysal commented Jan 30, 2023

Fixes

Fixes WordPress/openverse#1294 by @krysal

Description

This PR changes the query parameters of the Finnish museum to request only the fields that the DAG actually uses (including the creators). The creator can be of three types: "primary", "secondary" and/or "corporate". I made it include the available ones in said order, separated by a ";" since the names of an individual author can include commas as well.

Testing Instructions

Run the finnish_museums_workflow DAG, wait for a while and observe the rows in the image table.

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).
  • [N/A] 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 requested a review from a team as a code owner January 30, 2023 17:50
@krysal krysal requested review from obulat and stacimc and removed request for a team January 30, 2023 17:50
@openverse-bot openverse-bot added this to Needs review in Openverse PRs Jan 30, 2023
@openverse-bot openverse-bot added the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label Jan 30, 2023
@krysal krysal added 🟧 priority: high Stalls work on the project or its dependents ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository and removed 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Jan 30, 2023
Copy link
Contributor

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

A couple of thoughts!

author = "; ".join(list(author.keys()))
authors.append(author)

return "; ".join(authors)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will return an empty string if no authors are found, but it might be better to return None in that case to have NULL in the database rather than an empty string. Maybe we could do self.get_creator(data) or None above?

Copy link
Contributor

Choose a reason for hiding this comment

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

To make sure that we don't have different implementations for when creator name is not available ("" vs None), we could add a check and conversion here:


@AetherUnbound, should we create an issue for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! 😮 I was naive to believe it would return None this way. Fixed in last commits. Thanks, @AetherUnbound.

@obulat Adding an extra check there or/and in the MediaStore classes sounds good!

Copy link
Contributor

Choose a reason for hiding this comment

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

Your idea about adding a check in MediaStore is better than the columns one, @krysal. We could add

if title === "":
  title = None

in the MediaStore here:

def clean_media_metadata(self, **media_data) -> dict | None:

Are there any other string fields that need that, too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think title and creator are both good fields to check for that!

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.

LGTM!

We should fix the utf-8 issue in jsons, though.

"Kuva on julkaistu Nime\u00e4 4.0 Kansainv\u00e4linen (CC BY 4.0)-lisenssill\u00e4. Verkkopalvelussa julkaistua n\u00e4ytt\u00f6kuvaa voi k\u00e4ytt\u00e4\u00e4 vapaasti my\u00f6s kaupallisessa k\u00e4yt\u00f6ss\u00e4. Kuvan yhteydess\u00e4 on mainittava tekij\u00e4 ja/tai kuvaaja sek\u00e4 organisaation ja kokoelman nimi. Kuvan k\u00e4ytt\u00e4j\u00e4ll\u00e4 on vastuu tekij\u00e4noikeuksien ja yksityisyyden suojan kunnioittamisesta. Esimerkiksi henkil\u00f6kuvien k\u00e4ytt\u00f6 markkinoinnissa ja/tai mainonnassa on kielletty ilman kuvassa olevan henkil\u00f6n suostumusta. Museovirasto pyrkii julkaisemansa tiedon oikeellisuuteen. Kuvien tiedoissa voi kuitenkin olla puutteellisuuksia ja virheit\u00e4. Virheen huomatessanne pyyd\u00e4mme ottamaan yhteytt\u00e4 Kuvakokoelmien asiakaspalveluun. Kuvia ja tietoja julkaistaessa asiakkaan vastuulla on varmistaa niiden oikeellisuus. Painolaatuiset kuvat ovat maksullisia. Lis\u00e4tietoja tarvittaessa: Museoviraston Kuvakokoelmat (kuvakokoelmat@museovirasto.fi)."
],
"link": "http://creativecommons.org/licenses/by/4.0/deed.fi"
"SA-kuvat ovat lisensoitu Nime\u00e4 4.0 Kansainv\u00e4linen (CC BY 4.0) -lisenssill\u00e4 ja ne ovat vapaasti k\u00e4ytett\u00e4viss\u00e4 ja julkaistavissa. Kuvat ovat n\u00e4ht\u00e4viss\u00e4 my\u00f6s www.sa-kuva.fi -palvelussa."
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that ensureAscii=false wasn't used when saving the json file so that the utf-8 characters are not converted to \uxxx-type codes.

Openverse PRs automation moved this from Needs review to Reviewer approved Jan 31, 2023
Base automatically changed from fix/finnish-date-intervals to main January 31, 2023 18:37
Copy link
Contributor

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

Looks great! It seems that the diff is also showing some changes from #934, it might be best to rebase before we merge just to resolve those!

@krysal krysal merged commit 09b3a64 into main Feb 1, 2023
Openverse PRs automation moved this from Reviewer approved to Merged! Feb 1, 2023
@krysal krysal deleted the add/finnish-creator branch February 1, 2023 20:30
AetherUnbound added a commit that referenced this pull request Feb 2, 2023
* Fill creator name in finnish museum DAG (#978)

* Bump pre-commit from 2.21.0 to 3.0.2 (#983)

* 🔄 synced local '.pre-commit-config.yaml' with remote 'templates/.pre-commit-config.yaml.jinja'

* Update docstrings to conform to linting

* Update DAGs.md

---------

Co-authored-by: Krystle Salazar <krystle.salazar@automattic.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: openverse-bot <null>
Co-authored-by: Madison Swain-Bowden <bowdenm@spu.edu>
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: high Stalls work on the project or its dependents
Projects
No open projects
Openverse PRs
  
Merged!
Development

Successfully merging this pull request may close these issues.

Fill creator info of Finnish Museum's images
5 participants