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

Cv2 3435 alegre with presto for audio #1647

Merged
merged 20 commits into from
Oct 5, 2023

Conversation

DGaffney
Copy link
Contributor

@DGaffney DGaffney commented Sep 6, 2023

Description

This ticket integrates alegre's presto usage into Check-API for dealing with callbacks from storage requests on alegre. As stated in the ticket, I think we can actually get away with a pretty narrow implementation:

At the point that the webhook for storing data is executed, we don’t actually need to make a callback-based search query - we can use the search functionality nearly exactly as written today. When a new item is added in Check-API, we send a request to Alegre to store it, which then executes a callback against presto. Alegre receives the response from Presto, and at that point, we send a callback in turn from Alegre back to Check-API. At that point, when we receive the callback on Check-API from Alegre, we know that the data is now properly stored within Alegre - so we can just synchronously send a request to Alegre to do the lookup as it exists today. In fact, we should probably…. entirely rollback the portion of changes on Alegre for the GET requests (e.g. search-side) for now. The overwhelmingly common flow is for Alegre GETs to be used when we already know that the item is now safely stored, so in those rare cases where we aren’t sure, we should route through the new webhook setup instead of making everything be doubly-called-back. Make sense?

References: 3435

How has this been tested?

I've updated and fixed the tests on alegre to assert an expected message packet to be sent to alegre, and I'm mapping that directly to the added webhook, and then patching directly into existing functionality. Should be pretty minor if any difference downstream of that.

Things to pay attention to during code review

We will need to extensively test full service-to-service integrations just because this is involving so many different repos....

Checklist

  • I have performed a self-review of my own code
  • I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
  • I have added regression tests, if the PR fixes a bug
  • I have added logging, exception reporting, and custom tracing with any additional information required for debugging
  • I have commented my code in hard-to-understand areas, if any
  • I have made needed changes to the README
  • My changes generate no new warnings
  • If I added a third party module, I included a rationale for doing so and followed our current guidelines

@DGaffney DGaffney marked this pull request as ready for review September 12, 2023 10:58
@computermacgyver
Copy link
Contributor

computermacgyver commented Sep 12, 2023

There are functions such as Bot::Alegre.get_items_with_similar_media that expect Alegre to return similar results based on the a media file specified as a URL. My reading of meedan/alegre#340 is that this no longer works unless the audio has been stored already in Alegre with that URL. This assumption does not hold when this function is called from Smooch Search (https://github.com/meedan/check-api/blob/c983b834a859c4052553b8cf102e13f79ba78577/app/models/concerns/smooch_search.rb#L167C5-L167C5) and likely also when it is called from Check Web search.

Currently Alegre will temporarily hash and store an Audio file to perform the search, but this will no longer be the case after meedan/alegre#340 is merged. We therefore need to identify such instances and either (a) create exceptions for audio to fail gracefully or (b) solve the more general case of how we'll use callbacks for tipline/check-web search or (c) ensure that Alegre already fails gracefully in such cases but also logs and ideally alerts the calling service.

Copy link
Contributor

@caiosba caiosba 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 going to review this once I'm able to run it locally, in order to make some tests.

Copy link
Contributor

@computermacgyver computermacgyver left a comment

Choose a reason for hiding this comment

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

Looking great

app/models/bot/alegre.rb Show resolved Hide resolved
app/models/bot/alegre.rb Outdated Show resolved Hide resolved
app/models/bot/alegre.rb Outdated Show resolved Hide resolved
@DGaffney DGaffney requested a review from caiosba September 22, 2023 19:58
Copy link
Contributor

@caiosba caiosba left a comment

Choose a reason for hiding this comment

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

Thanks Devin! We're almost there! I added a couple of requests about the tests, but other than that, please also do:

  • Rebase this branch against latest develop
  • Add alegre_token: dev to config/config.yml.example

app/models/bot/alegre.rb Show resolved Hide resolved
app/models/concerns/alegre_webhooks.rb Outdated Show resolved Hide resolved
test/models/bot/alegre_3_test.rb Outdated Show resolved Hide resolved
@DGaffney DGaffney force-pushed the cv2-3435-alegre-with-presto-for-audio branch from 57aa278 to ff1add2 Compare September 25, 2023 17:31
@DGaffney DGaffney requested a review from caiosba September 26, 2023 14:04
test/test_helper.rb Outdated Show resolved Hide resolved
test/controllers/webhooks_controller_test.rb Outdated Show resolved Hide resolved
app/models/bot/alegre.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@computermacgyver computermacgyver left a comment

Choose a reason for hiding this comment

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

Great work.

@codeclimate
Copy link

codeclimate bot commented Oct 4, 2023

Code Climate has analyzed commit 60ad614 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (100% is the threshold).

This pull request will bring the total coverage in the repository to 100.0% (0.2% change).

View more on Code Climate.

@caiosba caiosba self-requested a review October 5, 2023 00:04
Copy link
Contributor

@caiosba caiosba left a comment

Choose a reason for hiding this comment

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

I pushed a few cosmetic changes, simplified one test and added one more test. Good to go after Alegre is merged!

@DGaffney DGaffney merged commit dfbb1bc into develop Oct 5, 2023
8 checks passed
@DGaffney DGaffney deleted the cv2-3435-alegre-with-presto-for-audio branch October 5, 2023 12:40
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