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

Optimization: only check allowed for unique programs #240

Merged
merged 7 commits into from
Jul 12, 2024

Conversation

daisieh
Copy link
Member

@daisieh daisieh commented Jul 11, 2024

It looks to me like you're checking OPA for program ID for every object to be ingested, so if there were 300 treatments in 5 programs, you'd have to call OPA 300 times. If that's the case, no wonder you'd want to check for site admin first, because that would bypass a lot of calls. But if instead you only check for unique program IDs, you'd only have to call OPA 5 times. Even if it's a little wasteful to call it those 4 extra times for the site admin, it's not so bad, and it would simplify the code. I tried to update the comment to help explain the exact behavior.

This is all moot because katsu_ingest.py sorts the ingest file by program first, and ingests only one program at a time, so it will take the same amount of calls (1) whether the user is a site admin or not.

Should behave as before.

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.72%. Comparing base (5fc681a) to head (4fb813d).

Files Patch % Lines
chord_metadata_service/mohpackets/apis/core.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #240      +/-   ##
===========================================
+ Coverage    96.64%   96.72%   +0.08%     
===========================================
  Files           36       36              
  Lines         3669     3668       -1     
===========================================
+ Hits          3546     3548       +2     
+ Misses         123      120       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@daisieh daisieh requested a review from SonQBChau July 11, 2024 23:35
@SonQBChau
Copy link

Yes, the change makes sense to me.

However, it also alters the test behavior, as I was testing for admin ingestion without program authorization. I have updated the tests to reflect this change. Additionally, I found a bug in the previous tests where ingestion required an array instead of a single object.

Thanks!

@daisieh daisieh merged commit 8ff3cc1 into develop Jul 12, 2024
6 checks passed
@daisieh daisieh deleted the daisieh/opa-optimization branch July 12, 2024 16:31
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.

2 participants