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 implementation plan for documenting the API media properties #3965

Merged
merged 8 commits into from
Apr 3, 2024

Conversation

dhruvkb
Copy link
Member

@dhruvkb dhruvkb commented Mar 25, 2024

Fixes

Fixes #1996 by @obulat

Description

This PR adds the implementation plan for documenting the media properties in the API. The IP uses introspection as the primary approach along with a documentation generation plan similar to that for the catalog.

Reviewers

I have requested reviews from @obulat and @krysal. The reason for the selection is because @obulat was involved in the IP and implementation for the corresponding project at the catalog layer and because IIRC @krysal has done prior work in the area of media properties documentation.

Testing Instructions

Please read the IP and comment your opinions. You can also see the implementation of this plan at #3966.

Decision-making process

This discussion is following the Openverse decision-making process. Information about this process can be found on the Openverse documentation site. Requested reviewers or participants will be following this process. If you are being asked to give input on a specific detail, you do not need to familiarise yourself with the process and follow it.

Current round

This discussion is currently in the Clarification round. The deadline for review of this round is 5 April 2024.

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.

@dhruvkb dhruvkb added 🟨 priority: medium Not blocking but should be addressed soon 🌟 goal: addition Addition of new feature 📄 aspect: text Concerns the textual material in the repository 🧱 stack: api Related to the Django API 🧱 stack: documentation Related to Sphinx documentation labels Mar 25, 2024
@dhruvkb dhruvkb requested review from krysal and obulat March 25, 2024 22:04
@dhruvkb dhruvkb requested a review from a team as a code owner March 25, 2024 22:04
Copy link

github-actions bot commented Mar 25, 2024

@dhruvkb dhruvkb force-pushed the media_props_api_ip branch from 587a06b to f35fb26 Compare March 25, 2024 22:12
@krysal krysal added the 🧭 project: implementation plan An implementation plan for a project label Mar 26, 2024
@krysal
Copy link
Member

krysal commented Mar 28, 2024

I'm reviewing this today. In the meantime, @dhruvkb, could you add a note about the revision round, like in #3650, for example?

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.

@dhruvkb This is looking like a solid document! I don't anticipate more questions or comments than the ones I left here.

@dhruvkb dhruvkb requested a review from krysal March 29, 2024 06:41
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.

Thanks for updating the details, and writing this comprehensive proposal! Everything looks good to me, so shortcuting the rounds, I approve it 👍

Co-authored-by: Krystle Salazar <[email protected]>
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.

It's great that Django has all of the capabilities to allow for documenting the properties! Love the plan and the linked PR with documentation.

I would love to see more detail on the Future improvements point on jsonb fields, especially after the incident caused by #3930. Do you think this should be done in a separate project, or as a separate part of this project? Would we add separate serializers to allow us to use introspection, or is there another way available to auto-generate documentation?

I wouldn't consider the "Fully document media properties" project completed without documenting the JSONFields because they are the ones that can cause problems in the future.

We will document this information in the docstring of the model classes from
where it can be accessed using `inspect.getdoc`. To ensure that these notes are
co-located with the fields' code, we will parse docstrings of all ancestors and
mixins of a model class.
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this work with help_text that is located in a separate file and is added inside __init__, as the source ones?

self.fields["source"].help_text = SOURCE_HELP_TEXT.format(**variables)
self.fields["excluded_source"].help_text = EXCLUDED_SOURCE_HELP_TEXT.format(

Copy link
Member Author

Choose a reason for hiding this comment

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

These help texts are taken from the model and not from the serializer. That's because for a specific model a number of serializers may be defined that can have different help_texts as per the requirements of the endpoint.

So for source, we show this

help_text="The source of the data, meaning a particular dataset. "
"Source and provider can be different. Eg: the Google Open "
"Images dataset is source=openimages, but provider=flickr.",

Copy link
Member Author

Choose a reason for hiding this comment

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

You can visit https://docs.openverse.org/_preview/3966/meta/media_properties/api.html to see the the generated docs output.

@dhruvkb
Copy link
Member Author

dhruvkb commented Apr 2, 2024

I wouldn't consider the "Fully document media properties" project completed without documenting the JSONFields because they are the ones that can cause problems in the future.

I totally agree with this sentiment and I tried earnestly to include them. But the documentation of JSONFields in their current state poses a number of issues and the alternative of documenting them from the serializers produces documentation that is based on our "expectation" during serialization and not reality of the DB or models.

I have documented these issues in f9dd8c9 and noted some steps we can take to enforce validity in our JSON data, which can then be used to generate documentation.

@dhruvkb dhruvkb requested a review from obulat April 2, 2024 14:35
@openverse-bot
Copy link
Collaborator

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

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

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

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

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.

Thank you for adding information on the json fields and possible solutions.
The plan looks good, and I'm short-circuiting this discussion to approve it.

Co-authored-by: Olga Bulat <[email protected]>
@dhruvkb dhruvkb merged commit 05ff48d into main Apr 3, 2024
38 checks passed
@dhruvkb dhruvkb deleted the media_props_api_ip branch April 3, 2024 16:09
@dhruvkb dhruvkb mentioned this pull request Apr 3, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📄 aspect: text Concerns the textual material in the repository 🌟 goal: addition Addition of new feature 🟨 priority: medium Not blocking but should be addressed soon 🧭 project: implementation plan An implementation plan for a project 🧱 stack: api Related to the Django API 🧱 stack: documentation Related to Sphinx documentation
Projects
Status: Accepted
Archived in project
Development

Successfully merging this pull request may close these issues.

Implementation Plan: Clearly document all media properties in catalog in API & Frontend
4 participants