Skip to content

Fix large data downloads#1863

Open
becky-gilbert wants to merge 12 commits intodevelopfrom
fix-large-data-downloads
Open

Fix large data downloads#1863
becky-gilbert wants to merge 12 commits intodevelopfrom
fix-large-data-downloads

Conversation

@becky-gilbert
Copy link
Copy Markdown
Contributor

@becky-gilbert becky-gilbert commented Apr 3, 2026

Fixes #1599

We've had a number of problems with data downloads timing out recently. This PR attempts to fix those issues by streaming to/from temp files, rather than concatenating very large strings that are fully stored in memory.

The temp files created with tempfile.NamedTemporaryFile will be deleted automatically. There a few places that use the delete=False argument because the data needs to be read back in later - these are cleaned up via a try/finally block, but we may need to check periodically to make sure that they do not persist if/when a download request fails.

Also, these changes reduce the peak memory usage, but there might still be issues with the response taking too long and hitting the response timeout. So if the problems continue, then we may need to turn some of the large/slow downloads into async tasks.

This PR also adds tests for the PsychDS zip file contents.

@becky-gilbert becky-gilbert self-assigned this Apr 3, 2026
@becky-gilbert becky-gilbert added the Bug [Work Type] An issue with the program label Apr 3, 2026
@becky-gilbert becky-gilbert added the Researcher [Audience] Researcher-facing label Apr 3, 2026
# Assumes n_previews fit on one page
self.assertEqual(n_matches, self.n_previews)

def _get_psychds_zip(self, query_string=""):
Copy link
Copy Markdown
Contributor Author

@becky-gilbert becky-gilbert Apr 3, 2026

Choose a reason for hiding this comment

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

@bleonar5 I was worried about modifying the content in psychds downloads, so I added some tests (starting here) to check that it's still correct. Can you let me know what you think, and if I should add any others? I want to make sure that I'm not missing any edge cases.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug [Work Type] An issue with the program Researcher [Audience] Researcher-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Response overview download times out

1 participant