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

Convert MARC Export to use Celery (PP-1472) #2017

Merged
merged 7 commits into from
Sep 4, 2024
Merged

Conversation

jonathangreen
Copy link
Member

@jonathangreen jonathangreen commented Aug 28, 2024

Description

Convert the MARC export script to use Celery.

Motivation and Context

This ended up being rather involved, since the export can take quite a long time. Even getting a large enough chunk of data for a single s3 multipart upload can take longer then I was comfortable with.

This PR takes the approach of processing batch_size (default: 500) records in one task, then saving the output to redis and re-queuing the task to process the next batch_size of records. Once the data in redis is large enough, a multipart upload is started in S3, and the multipart data is cached in redis. This continues until the file is completely generated.

How Has This Been Tested?

  • Tested by generating marc files locally with some production DB data
  • Unit tests

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 98.80342% with 7 lines in your changes missing coverage. Please review.

Project coverage is 90.67%. Comparing base (b190c49) to head (c1098b0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/palace/manager/service/redis/models/marc.py 97.63% 2 Missing and 2 partials ⚠️
src/palace/manager/marc/exporter.py 97.93% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2017      +/-   ##
==========================================
+ Coverage   90.59%   90.67%   +0.08%     
==========================================
  Files         338      342       +4     
  Lines       40135    40502     +367     
  Branches     8681     8777      +96     
==========================================
+ Hits        36360    36726     +366     
- Misses       2509     2510       +1     
  Partials     1266     1266              

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

@jonathangreen jonathangreen requested a review from a team August 28, 2024 23:03
@jonathangreen jonathangreen marked this pull request as ready for review August 28, 2024 23:03
@jonathangreen jonathangreen added the feature New feature label Aug 29, 2024
@dbernstein dbernstein self-requested a review September 3, 2024 15:50
Copy link
Contributor

@dbernstein dbernstein left a comment

Choose a reason for hiding this comment

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

That is an absolute beast. I like your batch + re-queueing approach. I think that pattern will likely come in handy in other places.

src/palace/manager/marc/settings.py Outdated Show resolved Hide resolved
@jonathangreen jonathangreen merged commit 1ac4d03 into main Sep 4, 2024
20 of 21 checks passed
@jonathangreen jonathangreen deleted the feature/marc-celery branch September 4, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants