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

Implement Detector, Category, DetectorCategory #101

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

matt-bernhardt
Copy link
Member

@matt-bernhardt matt-bernhardt commented Sep 10, 2024

This adds models for Detector, Category, and the linking DetectorCategory. There are uniqueness and dependency constraints specified in the migration and class files, and confirmed via tests.

I did not write tests for the linking class, as I'm not sure there's a need? I'm happy to write these if desired, though.

The fixtures for these classes match what we've already implemented in code, with the thought that these should change slowly enough that we should probably keep the fixtures in sync? I'm not sure about this though.

The biggest side effect is that implementing the Detector class is done by changing the existing module to a class - which forces changes in a handful of other files.

Developer

Ticket(s)

https://mitlibraries.atlassian.net/browse/TCO-82

Accessibility

  • ANDI or Wave has been run in accordance to our guide and
    all issues introduced by these changes have been resolved or opened
    as new issues (link to those issues in the Pull Request details above)
  • There are no accessibility implications to this change

Documentation

  • Project documentation has been updated, and yard output previewed
  • No documentation changes are needed These classes will eventually need yard documentation, but thus far I don't know that this is needed?

ENV

  • All new ENV is documented in README.
  • All new ENV has been added to Heroku Pipeline, Staging and Prod.
  • ENV has not changed.

Stakeholders

  • Stakeholder approval has been confirmed
  • Stakeholder approval is not needed

Dependencies and migrations

NO dependencies are updated

YES migrations are included Adding three models with associated records

Reviewer

Code

  • I have confirmed that the code works as intended.
  • Any CodeClimate issues have been fixed or confirmed as
    added technical debt.

Documentation

  • The commit message is clear and follows our guidelines
    (not just this pull request message).
  • The documentation has been updated or is unnecessary.
  • New dependencies are appropriate or there were no changes.

Testing

  • There are appropriate tests covering any new functionality.
  • No additional test coverage is required.

@mitlib mitlib temporarily deployed to tacos-api-pipeline-pr-101 September 10, 2024 14:32 Inactive
@mitlib mitlib temporarily deployed to tacos-api-pipeline-pr-101 September 10, 2024 14:38 Inactive
@mitlib mitlib temporarily deployed to tacos-api-pipeline-pr-101 September 10, 2024 15:00 Inactive
@mitlib mitlib temporarily deployed to tacos-api-pipeline-pr-101 September 10, 2024 18:25 Inactive
@mitlib mitlib temporarily deployed to tacos-api-pipeline-pr-101 September 10, 2024 18:40 Inactive
@matt-bernhardt matt-bernhardt marked this pull request as ready for review September 10, 2024 18:55
** Why are these changes being introduced:

Our chosen architecture calls for a set of models that will comprise a
sort of "knowledge graph", which TACOS will consult during the
categorization process. This includes classes for Category, Detector,
and a linking DetectorCategory class. The Detector and DetectorCategory
classes will each define a confidence value.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/tco-82

** How does this address that need:

This defines those classes. The migration includes the creation of the
needed records for each class: Three category records, six detectors,
and five records which link between them.

There are currently no detectors which map to two of the categories,
although we have talked about those being needed. Additionally, one
detector, SuggestedResource, is unique in that specific records will
count toward each category - so it isn't appropriate to have a link
record which uniformly connects to only one category.

** Document any side effects to this change:

We previously had a Detector model file, but it was set as a Module in
order to provide a namespace for its subclasses. This has been updated
to be just a class, which impacts the dashboard and test files. Also,
there was a method to define a table name prefix, which has been moved
from the Detector file to the subclass files.
@matt-bernhardt
Copy link
Member Author

Quick postscript about this PR - Please check the structure of the migration, as I'm not sure I got this right. With uniqueness constraints on the database tables, and sample records in the migration, I may have created a PR where the rollback doesn't happen cleanly. I've tried working with up and down methods in the migration, but haven't had success there, so everything is just done in change at the moment.

I'm happy to have guidance or suggestions for changes here.

Copy link
Member

@JPrevost JPrevost left a comment

Choose a reason for hiding this comment

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

I need to pivot to something else and will finish the review tomorrow, but wanted to submit my initial input even if it isn't complete. Overall this looks like what we want.

I definitely think the db/seed.rb is the better way to handle the data creation you have in the migration (whether we seed it in prod or manually create it is tbd, but it'll be great to have that seed to auto run them in PR builds and locally whenever we find a need).

db/migrate/20240909183413_create_categories.rb Outdated Show resolved Hide resolved
db/migrate/20240909183413_create_categories.rb Outdated Show resolved Hide resolved
test/models/category_test.rb Show resolved Hide resolved
app/models/detector.rb Outdated Show resolved Hide resolved
@JPrevost JPrevost self-assigned this Sep 10, 2024
@matt-bernhardt
Copy link
Member Author

Thanks - let me look over these suggestions and make some changes. I'll un-tag for a review now, and re-tag when I'm done.

- Move the record population out of migrations and into db/seeds.rb

- Splits the migrations into three separate files, one per model

- Add two indices on the linking model, from each direction

- Removes the confidence value from the Detector model, leaving only
  the one on the DetectorCategory linking model
@mitlib mitlib temporarily deployed to tacos-api-pipeline-pr-101 September 10, 2024 21:30 Inactive
@matt-bernhardt
Copy link
Member Author

Okay, @JPrevost - I've made the changes you mentioned in your initial review. It should be ready for you to finish looking at now.

Copy link
Member

@JPrevost JPrevost 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. Thanks!

@@ -7,3 +7,56 @@
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
# MovieGenre.find_or_create_by!(name: genre_name)
# end

Copy link
Member

Choose a reason for hiding this comment

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

Note: If these don't run automatically in our PR builds (and maybe other Heroku tiers? We can talk about that) they can be configured to do that. I haven't checked if this repo is already set to run seeds in Heroku or not, just noting it before I forget as something we can address if it doesn't work as desired.

@matt-bernhardt matt-bernhardt merged commit 3cea65a into main Sep 12, 2024
2 of 3 checks passed
@matt-bernhardt matt-bernhardt deleted the tco-82-knowledge-graph branch September 12, 2024 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants