Fix --limit subject filter dropped for chunked tables in sqlite import.py#1993
Open
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Open
Fix --limit subject filter dropped for chunked tables in sqlite import.py#1993Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Conversation
main() passes subjects=subjects to process_dataframe for small tables (read_csv in one shot), but the chunked branch for large tables calls process_dataframe(chunk) with no subjects argument. The default subjects=None disables the 'df.loc[df["subject_id"].isin(subjects)]' filter inside process_dataframe, so --limit N correctly trims small tables (admissions, patients, etc.) but silently imports every row of any table large enough to trigger the chunked path (chartevents, labevents, emar, etc.). Pass subjects=subjects to process_dataframe in the chunked branch so the subject filter is applied consistently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
mimic-iv/buildmimic/sqlite/import.py's--limit Noption is silently ignored for any table large enough to trigger chunked reading (chartevents, labevents, emar, …). The resulting SQLite database contains every row of those tables, defeating the purpose of--limit.https://github.com/MIT-LCP/mimic-code/blob/5706978/mimic-iv/buildmimic/sqlite/import.py#L160-L170
The small-file branch passes
subjects=subjectstoprocess_dataframe, but the chunked branch callsprocess_dataframe(chunk).process_dataframe'ssubjectsparameter defaults toNone, and itsdf.loc[df['subject_id'].isin(subjects)]filter is a no-op whensubjectsisNone.Root cause
Missing
subjects=subjectsargument in the chunked call, so chunked tables skip thesubject_idfilter entirely.Fix
Pass
subjects=subjectsin the chunked branch, matching the non-chunked branch so the--limit Nfilter is applied consistently.