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

added unzipping functionality for mimic iv example #31

Merged

Conversation

Oufattole
Copy link
Collaborator

@Oufattole Oufattole commented Jul 10, 2024

Resolves issue #30

Summary by CodeRabbit

  • New Features
    • Introduced an optional parameter to control the unzipping of .csv.gz files, enhancing user flexibility in data handling based on their storage preferences.
    • Expanded the terminology documentation to provide comprehensive definitions related to MEDS concepts, improving clarity and utility for users.

@Oufattole Oufattole linked an issue Jul 10, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update enhances the MIMIC-IV pipeline by introducing an optional parameter in joint_script.sh that allows users to control the unzipping of pre-MEDS gunzip CSV files. This functionality provides flexibility in managing disk space and memory usage, enabling users to customize their data preparation steps according to their needs.

Changes

Files/Directories Change Summary
MIMIC-IV_Example/joint_script.sh Introduced an optional DO_UNZIP parameter to control unzipping of .csv.gz files, defaulting to do_unzip=false. Conditional logic added to handle unzipping based on the parameter.
terminology.md Expanded definitions related to MEDS terminology, adding key terms and clarifying concepts such as Vocabulary Index, Measurement, Event, and more.

Poem

From compressed files, we take a leap,
To unzip and prep, our data we keep.
A toggle for ease, in the script we find,
Flexibility blooms, oh so kind! 🌿
With every change, new paths we pave,
In the world of data, we're bold and brave! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c96c948 and 2723b3e.

Files selected for processing (1)
  • MIMIC-IV_Example/joint_script.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • MIMIC-IV_Example/joint_script.sh

@mmcdermott
Copy link
Owner

Can you make this flag controlled, so that in the joint script someone can have this not be run if desired? Purely as a bash script thing, I mean, just with an optional 5th arg that must be "do_unzip=true" or "do_unzip=false" or something? This will cost a lot of disk, so some folks may not want to do it, is all.

@mmcdermott mmcdermott mentioned this pull request Jul 26, 2024
24 tasks
@mmcdermott
Copy link
Owner

@Oufattole can you merge the changes in main to this, make it go into dev instead of main, and make this flag controlled via the shell parameters? Then I'm happy to merge it.

@@ -42,6 +42,9 @@ shift 4
echo "Running pre-MEDS conversion."
./MIMIC-IV_Example/pre_MEDS.py raw_cohort_dir="$MIMICIV_RAW_DIR" output_dir="$MIMICIV_PREMEDS_DIR"

echo "Unzipping the pre-MEDS gunzip csv files."
for file in ${MIMICIV_PREMEDS_DIR}/*/*.csv.gz; do gzip -d --force "$file"; done
Copy link
Owner

Choose a reason for hiding this comment

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

actually, you probably want to do this on the raw data, right? That way the pre-meds can benefit from faster processing too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@Oufattole Oufattole force-pushed the 30-mimic-iv-example-has-high-memory-usage-due-to-csvgz-files branch from 2723b3e to 1ba3135 Compare July 29, 2024 14:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2723b3e and 1ba3135.

Files selected for processing (1)
  • MIMIC-IV_Example/joint_script.sh (1 hunks)
Additional comments not posted (1)
MIMIC-IV_Example/joint_script.sh (1)

39-39: LGTM! The parameter DO_UNZIP is correctly introduced.

The default value ensures backward compatibility.

MIMIC-IV_Example/joint_script.sh Show resolved Hide resolved
MIMIC-IV_Example/joint_script.sh Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1ba3135 and 8510f9d.

Files selected for processing (1)
  • MIMIC-IV_Example/joint_script.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • MIMIC-IV_Example/joint_script.sh

@mmcdermott
Copy link
Owner

@Oufattole the test failure here is due to a polars versioning issue. I'm going to fix it directly then you can merge that change in and we'll push this.

@@ -36,9 +36,17 @@ MIMICIV_RAW_DIR="$1"
MIMICIV_PREMEDS_DIR="$2"
MIMICIV_MEDS_DIR="$3"
N_PARALLEL_WORKERS="$4"
DO_UNZIP="${5:-do_unzip=false}" # Default to 'do_unzip=false' if not provided, this uses more disk space but reduces memory usage
Copy link
Owner

Choose a reason for hiding this comment

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

You need to change one more thing here -- this script is set up so that the first 4 args are mandatory, and all others are sent to the scripts as arguments via the "$@" thing. Right now, your DO_UNZIP will absorb all of those other kwargs. You should either:

  1. Make sure that DO_UNZIP only absorbs the fifth argument if the arg there starts with --do_unzip or something.
  • or -
  1. Make there be a mandatory 5th arg that is DO_UNZIP and then replace the shift 4 with shift 5 so that it isn't used again below in the "$@"

@mmcdermott
Copy link
Owner

@Oufattole I fixed the test issue but added one comment on your param and also you should update the display help function for this param.

@mmcdermott mmcdermott added Computational Performance Issues relating to efficient computational performance of MEDS_transforms pipelines priority:low A low priority issue. MIMIC-IV labels Jul 30, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
terminology.md (2)

14-20: Consider replacing repetitive word.

The words ‘observations’ and ‘observing’ are quite similar. Consider replacing ‘observing’ with a different word to improve readability.

- such as observing a diagnostic code being applied to the patient, observing a patient's admission or transfer from one unit to another, observing a laboratory test result
+ such as noting a diagnostic code being applied to the patient, recording a patient's admission or transfer from one unit to another, observing a laboratory test result
Tools
LanguageTool

[style] ~17-~17: The words ‘observations’ and ‘observing’ are quite similar. Consider replacing ‘observing’ with a different word.
Context: ...vations can take on many forms, such as observing a diagnostic code being applied to the ...

(VERB_NOUN_SENT_LEVEL_REP)


33-36: Simplify the phrase "at any point in time".

The phrase "at any point in time" is redundant. Consider simplifying it to "at any time".

- that can be interpreted as being applicable to the patient at any point in time during their care.
+ that can be interpreted as being applicable to the patient at any time during their care.
Tools
LanguageTool

[style] ~36-~36: This phrase is redundant. Consider writing “point” or “time”.
Context: ... being applicable to the patient at any point in time during their care. #### A _time-derive...

(MOMENT_IN_TIME)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8510f9d and 3c87b44.

Files selected for processing (1)
  • terminology.md (1 hunks)
Additional context used
LanguageTool
terminology.md

[style] ~17-~17: The words ‘observations’ and ‘observing’ are quite similar. Consider replacing ‘observing’ with a different word.
Context: ...vations can take on many forms, such as observing a diagnostic code being applied to the ...

(VERB_NOUN_SENT_LEVEL_REP)


[style] ~36-~36: This phrase is redundant. Consider writing “point” or “time”.
Context: ... being applicable to the patient at any point in time during their care. #### A _time-derive...

(MOMENT_IN_TIME)

Markdownlint
terminology.md

7-7: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)

Additional comments not posted (5)
terminology.md (5)

7-13: LGTM!

The definition of "vocabulary index" is clear and well-explained.

Tools
Markdownlint

7-7: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


22-25: LGTM!

The definition of "event" or "patient event" is clear and well-explained.


27-31: LGTM!

The definition of "event index" is clear and well-explained.


38-43: LGTM!

The definition of "time-derived measurement" is clear and well-explained.


45-48: LGTM!

The definition of "dynamic measurement" is clear and well-explained.

@mmcdermott mmcdermott changed the base branch from main to dev August 2, 2024 02:06
@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.48%. Comparing base (07140c1) to head (6eaecb6).
Report is 125 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #31      +/-   ##
==========================================
+ Coverage   84.85%   92.48%   +7.63%     
==========================================
  Files          17       24       +7     
  Lines        1096     1664     +568     
==========================================
+ Hits          930     1539     +609     
+ Misses        166      125      -41     

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

@mmcdermott
Copy link
Owner

@Oufattole, @EthanSteinberg discovered that this won't work even as implemented here b/c pre_MEDS.py only looks for csv.gz files, not csv files. I'm going to debug and try to fix and push this in today.

@mmcdermott mmcdermott closed this Aug 4, 2024
…ted input file encodings so that unzipping works. Also made the bash arg (I think) work. Also removed rootutils to help address #114
@mmcdermott mmcdermott reopened this Aug 4, 2024
@mmcdermott
Copy link
Owner

Re-opened with changes to pre_MEDS.py and some other changes which seems to be working in that unzipping can occur and the extraction pipeline proceeds through the shard_events stage with the unzipped files. I haven't profiled the impact this has on memory but I believe it should be non-trivial.

@mmcdermott mmcdermott merged commit 600d20e into dev Aug 5, 2024
4 checks passed
@mmcdermott mmcdermott deleted the 30-mimic-iv-example-has-high-memory-usage-due-to-csvgz-files branch August 5, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Computational Performance Issues relating to efficient computational performance of MEDS_transforms pipelines MIMIC-IV priority:low A low priority issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MIMIC IV Example has high memory usage due to *.csv.gz files
3 participants