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

Bagit export updates #677

Merged
merged 18 commits into from Dec 3, 2018
Merged

Bagit export updates #677

merged 18 commits into from Dec 3, 2018

Conversation

rstorey
Copy link
Member

@rstorey rstorey commented Nov 29, 2018

Closes #664

@rstorey
Copy link
Member Author

rstorey commented Nov 29, 2018

In the interest of making this project more reusable, should we have this as something like a dictionary in the settings file?

It seems that our BagIt export (at least for now) is going to be strictly for the purpose of getting transcription data into www.loc.gov. The most recent changes make it even more LC-specific.

When we are ready to talk about/implement public exports, I'm not sure that BagIt 1.0 bags are what we want to use. I think the CSV export is better, not the least of which is because it's a streaming response that won't OOM on large exports.

@coveralls
Copy link

coveralls commented Nov 29, 2018

Coverage Status

Coverage decreased (-0.4%) to 71.414% when pulling 292a451 on bagit-export-updates into 7121c49 on master.

@rstorey rstorey requested a review from acdha November 29, 2018 18:29
@rstorey rstorey self-assigned this Nov 29, 2018
Copy link
Member

@acdha acdha left a comment

Choose a reason for hiding this comment

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

Do we need to apply published checks here to exclude the campaign/project/item/asset(s) which aren't published yet?

@@ -35,13 +37,81 @@ def get_original_asset_id(download_url):
"""
if download_url.startswith("http://tile.loc.gov/"):
pattern = r"/service:([A-Za-z0-9:\-]*)/"
asset_id = re.search(pattern, download_url)
asset_id = re.search(pattern, download_url).group(1)
Copy link
Member

Choose a reason for hiding this comment

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

This will fail if it gets a value which doesn't match the pattern. We should probably do the if not match: … check even if that's unlikely.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it - let me know what you think.

exporter/views.py Outdated Show resolved Hide resolved
exporter/views.py Outdated Show resolved Hide resolved
exporter/views.py Outdated Show resolved Hide resolved
exporter/views.py Outdated Show resolved Hide resolved
exporter/views.py Outdated Show resolved Hide resolved
exporter/views.py Outdated Show resolved Hide resolved
exporter/views.py Outdated Show resolved Hide resolved
exporter/views.py Outdated Show resolved Hide resolved
@acdha
Copy link
Member

acdha commented Nov 29, 2018

When we are ready to talk about/implement public exports, I'm not sure that BagIt 1.0 bags are what we want to use. I think the CSV export is better, not the least of which is because it's a streaming response that won't OOM on large exports.

I suspect that the best answer here is going to be Celery and the work on bagit-python to make it upload directly to S3 (and that could be safely made public with some sort of throttle). That's definitely a separate project but we might want to see whether there's something we can do here to avoid OOMs — do you know where in the code it's hitting that limit?

acdha and others added 8 commits November 30, 2018 16:09
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
Co-Authored-By: rstorey <rstorey@users.noreply.github.com>
@rstorey
Copy link
Member Author

rstorey commented Nov 30, 2018

When we are ready to talk about/implement public exports, I'm not sure that BagIt 1.0 bags are what we want to use. I think the CSV export is better, not the least of which is because it's a streaming response that won't OOM on large exports.

I suspect that the best answer here is going to be Celery and the work on bagit-python to make it upload directly to S3 (and that could be safely made public with some sort of throttle). That's definitely a separate project but we might want to see whether there's something we can do here to avoid OOMs — do you know where in the code it's hitting that limit?

I haven't actually personally witnessed an OOM, so not sure.

@rstorey
Copy link
Member Author

rstorey commented Nov 30, 2018

SInce we're only getting completed transcriptions in the BagIt export, either the assets are published or were published. I think the scenario where something is published, completed, unpublished, and then exported might be a valid use case, so I'm not going to add a filter for publish status at this time. If @elainekamlley wants to weigh in, I defer to them.

@rstorey rstorey requested a review from acdha November 30, 2018 21:31
logger.error(
"Couldn't find a matching asset ID in download URL %s", download_url
)
raise AssertionError
Copy link
Member

Choose a reason for hiding this comment

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

This could be some other exception class but I care less about that than that it’s checked since it seems like this condition will usually be telling us that we got some bogus data from the API, and that edge case probably means we need to get some records fixed

Copy link
Member

@acdha acdha 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 cutting my review short for family reasons but it looks good enough to me to merge for testing

@rstorey rstorey merged commit b5f611a into master Dec 3, 2018
@rstorey rstorey deleted the bagit-export-updates branch December 3, 2018 14:46
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.

None yet

3 participants