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

Remove aggregation of code metadata from default extraction ETL. #157

Merged
merged 4 commits into from
Aug 14, 2024

Conversation

mmcdermott
Copy link
Owner

@mmcdermott mmcdermott commented Aug 14, 2024

Closes #110

Copy link
Contributor

coderabbitai bot commented Aug 14, 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.


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.

@codecov-commenter
Copy link

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 77 tests with 1 failed, 76 passed and 0 skipped.

View the full list of failed tests

pytest

  • Class name: tests.test_fit_vocabulary_indices
    Test name: test_fit_vocabulary_indices_with_default_stage_config

    want = shape: (12, 9)
    ┌───────────────────────┬────────────────────┬─────────────────┬──────────────────────┬─────────────┬──...───────────────────┴─────────────┴────────────────┴─────────────────────────────────┴──────────────┴──────────────────┘
    got = shape: (12, 9)
    ┌───────────────────────┬────────────────────┬─────────────────┬──────────────────────┬─────────────┬──...───────────────┴─────────────┴────────────────┴─────────────────────────────────┴──────────────────┴──────────────────┘
    msg = 'Expected the dataframe at .../output_cohort/metadata/codes.parquet to be equal to the target.\nScript st...it_vocabulary_indices\x1b[0m:\x1b[36mmain\x1b[0m:\x1b[36m237\x1b[0m - \x1b[1mDone with fit_vocabulary_indices\x1b[0m\n'
    kwargs = {'check_column_order': False, 'check_row_order': True}

    def assert_df_equal(want: pl.DataFrame, got: pl.DataFrame, msg: str = None, **kwargs):
    try:
    > assert_frame_equal(want, got, **kwargs)

    tests/utils.py:172:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    args = (shape: (12, 9)
    ┌───────────────────────┬────────────────────┬─────────────────┬──────────────────────┬─────────────┬─...──────────────┴─────────────┴────────────────┴─────────────────────────────────┴──────────────────┴──────────────────┘)
    kwargs = {'check_column_order': False, 'check_row_order': True}

    @wraps(function)
    def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
    _rename_keyword_argument(
    old_name, new_name, kwargs, function.__qualname__, version
    )
    > return function(*args, **kwargs)
    E AssertionError: DataFrames are different (dtypes do not match)
    E [left]: {'code': String, 'code/n_occurrences': UInt8, 'code/n_patients': UInt8, 'values/n_occurrences': UInt8, 'values/sum': Float32, 'values/sum_sqd': Float32, 'description': String, 'parent_codes': String, 'code/vocab_index': UInt8}
    E [right]: {'code': String, 'code/n_occurrences': UInt8, 'code/n_patients': UInt8, 'values/n_occurrences': UInt8, 'values/sum': Float32, 'values/sum_sqd': Float32, 'description': String, 'parent_codes': List(String), 'code/vocab_index': UInt8}

    .../hostedtoolcache/Python/3.12.4.../x64/lib/python3.12.../polars/_utils/deprecation.py:91: AssertionError

    The above exception was the direct cause of the following exception:

    def test_fit_vocabulary_indices_with_default_stage_config():
    > single_stage_transform_tester(
    transform_script=FIT_VOCABULARY_INDICES_SCRIPT,
    stage_name="fit_vocabulary_indices",
    transform_stage_kwargs=None,
    want_outputs=WANT_DF,
    )

    tests/test_fit_vocabulary_indices.py:42:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    tests/transform_tester_base.py:387: in single_stage_transform_tester
    check_df_output(cohort_metadata_dir / "codes.parquet", want_outputs, stderr, stdout)
    tests/transform_tester_base.py:285: in check_df_output
    assert_df_equal(
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    want = shape: (12, 9)
    ┌───────────────────────┬────────────────────┬─────────────────┬──────────────────────┬─────────────┬──...───────────────────┴─────────────┴────────────────┴─────────────────────────────────┴──────────────┴──────────────────┘
    got = shape: (12, 9)
    ┌───────────────────────┬────────────────────┬─────────────────┬──────────────────────┬─────────────┬──...───────────────┴─────────────┴────────────────┴─────────────────────────────────┴──────────────────┴──────────────────┘
    msg = 'Expected the dataframe at .../output_cohort/metadata/codes.parquet to be equal to the target.\nScript st...it_vocabulary_indices\x1b[0m:\x1b[36mmain\x1b[0m:\x1b[36m237\x1b[0m - \x1b[1mDone with fit_vocabulary_indices\x1b[0m\n'
    kwargs = {'check_column_order': False, 'check_row_order': True}

    def assert_df_equal(want: pl.DataFrame, got: pl.DataFrame, msg: str = None, **kwargs):
    try:
    assert_frame_equal(want, got, **kwargs)
    except AssertionError as e:
    pl.Config.set_tbl_rows(-1)
    print(f"DFs are not equal: {msg}\nwant:")
    print(want)
    print("got:")
    print(got)
    > raise AssertionError(f"{msg}\n{e}") from e
    E AssertionError: Expected the dataframe at .../output_cohort/metadata/codes.parquet to be equal to the target.
    E Script stdout:
    E [2024-08-14 01:14:07,212][HYDRA] Hydra 1.3.2
    E [2024-08-14 01:14:07,212][HYDRA] ===========
    E [2024-08-14 01:14:07,212][HYDRA] Installed Hydra Plugins
    E [2024-08-14 01:14:07,212][HYDRA] ***********************
    E [2024-08-14 01:14:07,212][HYDRA] ConfigSource:
    E [2024-08-14 01:14:07,212][HYDRA] -------------
    E [2024-08-14 01:14:07,212][HYDRA] FileConfigSource
    E [2024-08-14 01:14:07,212][HYDRA] ImportlibResourcesConfigSource
    E [2024-08-14 01:14:07,212][HYDRA] StructuredConfigSource
    E [2024-08-14 01:14:07,212][HYDRA] CompletionPlugin:
    E [2024-08-14 01:14:07,212][HYDRA] -----------------
    E [2024-08-14 01:14:07,212][HYDRA] BashCompletion
    E [2024-08-14 01:14:07,212][HYDRA] FishCompletion
    E [2024-08-14 01:14:07,213][HYDRA] ZshCompletion
    E [2024-08-14 01:14:07,213][HYDRA] Launcher:
    E [2024-08-14 01:14:07,213][HYDRA] ---------
    E [2024-08-14 01:14:07,213][HYDRA] BasicLauncher
    E [2024-08-14 01:14:07,213][HYDRA] Sweeper:
    E [2024-08-14 01:14:07,213][HYDRA] --------
    E [2024-08-14 01:14:07,213][HYDRA] BasicSweeper
    E [2024-08-14 01:14:07,213][HYDRA]
    E [2024-08-14 01:14:07,213][HYDRA] Config search path
    E [2024-08-14 01:14:07,213][HYDRA] ******************
    E [2024-08-14 01:14:07,502][HYDRA] | Provider | Search path |
    E [2024-08-14 01:14:07,502][HYDRA] ---------------------------------------------------------------------------------------------------
    E [2024-08-14 01:14:07,502][HYDRA] | hydra | pkg://hydra.conf |
    E [2024-08-14 01:14:07,502][HYDRA] | main | file:.../src/MEDS_transforms/configs |
    E [2024-08-14 01:14:07,502][HYDRA] | schema | structured:// |
    E [2024-08-14 01:14:07,502][HYDRA] ---------------------------------------------------------------------------------------------------
    E [2024-08-14 01:14:07,646][HYDRA]
    E [2024-08-14 01:14:07,646][HYDRA] Defaults Tree
    E [2024-08-14 01:14:07,646][HYDRA] *************
    E [2024-08-14 01:14:07,646][HYDRA] <root>:
    E [2024-08-14 01:14:07,646][HYDRA] hydra/config:
    E [2024-08-14 01:14:07,646][HYDRA] hydra/output: default
    E [2024-08-14 01:14:07,646][HYDRA] hydra/launcher: basic
    E [2024-08-14 01:14:07,646][HYDRA] hydra/sweeper: basic
    E [2024-08-14 01:14:07,647][HYDRA] hydra/help: default
    E [2024-08-14 01:14:07,647][HYDRA] hydra/hydra_help: default
    E [2024-08-14 01:14:07,647][HYDRA] hydra/hydra_logging: default
    E [2024-08-14 01:14:07,647][HYDRA] hydra/job_logging: default
    E [2024-08-14 01:14:07,647][HYDRA] hydra/callbacks: null
    E [2024-08-14 01:14:07,647][HYDRA] hydra/env: default
    E [2024-08-14 01:14:07,647][HYDRA] _self_
    E [2024-08-14 01:14:07,647][HYDRA] preprocess:
    E [2024-08-14 01:14:07,647][HYDRA] pipeline
    E [2024-08-14 01:14:07,647][HYDRA] stage_configs/reshard_to_split
    E [2024-08-14 01:14:07,647][HYDRA] stage_configs/filter_patients
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/add_time_derived_measurements
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/count_code_occurrences
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/filter_measurements
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/fit_outlier_detection
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/occlude_outliers
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/fit_normalization
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/fit_vocabulary_indices
    E [2024-08-14 01:14:07,648][HYDRA] stage_configs/reorder_measurements
    E [2024-08-14 01:14:07,648][HYDRA] _self_
    E [2024-08-14 01:14:07,791][HYDRA]
    E [2024-08-14 01:14:07,791][HYDRA] Defaults List
    E [2024-08-14 01:14:07,791][HYDRA] *************
    E [2024-08-14 01:14:07,791][HYDRA] | Config path | Package | _self_ | Parent |
    E [2024-08-14 01:14:07,791][HYDRA] ----------------------------------------------------------------------------------------------
    E [2024-08-14 01:14:07,791][HYDRA] | hydra/output/default | hydra | False | hydra/config |
    E [2024-08-14 01:14:07,791][HYDRA] | hydra/launcher/basic | hydra.launcher | False | hydra/config |
    E [2024-08-14 01:14:07,791][HYDRA] | hydra/sweeper/basic | hydra.sweeper | False | hydra/config |
    E [2024-08-14 01:14:07,791][HYDRA] | hydra/help/default | hydra.help | False | hydra/config |
    E [2024-08-14 01:14:07,791][HYDRA] | hydra/hydra_help/default | hydra.hydra_help | False | hydra/config |
    E [2024-08-14 01:14:07,791][HYDRA] | hydra/hydra_logging/default | hydra.hydra_logging | False | hydra/config |
    E [2024-08-14 01:14:07,792][HYDRA] | hydra/job_logging/default | hydra.job_logging | False | hydra/config |
    E [2024-08-14 01:14:07,792][HYDRA] | hydra/env/default | hydra.env | False | hydra/config |
    E [2024-08-14 01:14:07,792][HYDRA] | hydra/config | hydra | True | <root> |
    E [2024-08-14 01:14:07,792][HYDRA] | pipeline | | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/reshard_to_split | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/filter_patients | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/add_time_derived_measurements | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/count_code_occurrences | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/filter_measurements | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/fit_outlier_detection | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/occlude_outliers | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/fit_normalization | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/fit_vocabulary_indices | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | stage_configs/reorder_measurements | stage_configs | False | preprocess |
    E [2024-08-14 01:14:07,792][HYDRA] | preprocess | | True | <root> |
    E [2024-08-14 01:14:07,792][HYDRA] ----------------------------------------------------------------------------------------------
    E [2024-08-14 01:14:08,064][HYDRA] Config
    E [2024-08-14 01:14:08,064][HYDRA] ******
    E [2024-08-14 01:14:08,077][HYDRA] input_dir: ....../tmp/tmpewm0iuof/MEDS_cohort
    E cohort_dir: ........./tmp/tmpewm0iuof/output_cohort
    E _default_description: 'This is a MEDS pipeline ETL. Please set a more detailed description
    E at the top of your specific pipeline
    E
    E configuration file.'
    E log_dir: ${stage_cfg.output_dir}/.logs
    E do_overwrite: false
    E seed: 1
    E stages:
    E - fit_vocabulary_indices
    E stage_configs:
    E reshard_to_split:
    E n_patients_per_shard: 50000
    E filter_patients:
    E min_events_per_patient: null
    E min_measurements_per_patient: null
    E add_time_derived_measurements:
    E age:
    E DOB_code: MEDS_BIRTH
    E age_code: AGE
    E age_unit: years
    E time_of_day:
    E time_of_day_code: TIME_OF_DAY
    E endpoints:
    E - 6
    E - 12
    E - 18
    E - 24
    E count_code_occurrences:
    E aggregations:
    E - code/n_occurrences
    E - code/n_patients
    E do_summarize_over_all_codes: true
    E filter_measurements:
    E min_patients_per_code: null
    E min_occurrences_per_code: null
    E fit_outlier_detection:
    E aggregations:
    E - values/n_occurrences
    E - values/sum
    E - values/sum_sqd
    E occlude_outliers:
    E stddev_cutoff: 4.5
    E fit_normalization:
    E aggregations:
    E - code/n_occurrences
    E - code/n_patients
    E - values/n_occurrences
    E - values/sum
    E - values/sum_sqd
    E fit_vocabulary_indices:
    E is_metadata: true
    E ordering_method: lexicographic
    E output_dir: ${cohort_dir}
    E reorder_measurements:
    E ordered_code_patterns: &&&
    E worker: 0
    E polling_time: 300
    E stage: ${current_script_name:}
    E stage_cfg: ${oc.create:${populate_stage:${stage}, ${input_dir}, ${cohort_dir}, ${stages},
    E ${stage_configs}}}
    E etl_metadata:
    E pipeline_name: &&&
    E dataset_name: &&&
    E dataset_version: &&&
    E package_name: ${get_package_name:}
    E package_version: ${get_package_version:}
    E etl_metadata.pipeline_name: preprocess
    E code_modifiers: &&&
    E
    E
    E Script stderr:
    E #x1B[32m2024-08-14 01:14:08.218#x1B[0m | #x1B[1mINFO #x1B[0m | #x1B[36mMEDS_transforms.fit_vocabulary_indices#x1B[0m:#x1B[36mmain#x1B[0m:#x1B[36m203#x1B[0m - #x1B[1mRunning with config:
    E input_dir: ....../tmp/tmpewm0iuof/MEDS_cohort
    E cohort_dir: ........./tmp/tmpewm0iuof/output_cohort
    E _default_description: 'This is a MEDS pipeline ETL. Please set a more detailed description
    E at the top of your specific pipeline
    E
    E configuration file.'
    E log_dir: ${stage_cfg.output_dir}/.logs
    E do_overwrite: false
    E seed: 1
    E stages:
    E - fit_vocabulary_indices
    E stage_configs:
    E reshard_to_split:
    E n_patients_per_shard: 50000
    E filter_patients:
    E min_events_per_patient: null
    E min_measurements_per_patient: null
    E add_time_derived_measurements:
    E age:
    E DOB_code: MEDS_BIRTH
    E age_code: AGE
    E age_unit: years
    E time_of_day:
    E time_of_day_code: TIME_OF_DAY
    E endpoints:
    E - 6
    E - 12
    E - 18
    E - 24
    E count_code_occurrences:
    E aggregations:
    E - code/n_occurrences
    E - code/n_patients
    E do_summarize_over_all_codes: true
    E filter_measurements:
    E min_patients_per_code: null
    E min_occurrences_per_code: null
    E fit_outlier_detection:
    E aggregations:
    E - values/n_occurrences
    E - values/sum
    E - values/sum_sqd
    E occlude_outliers:
    E stddev_cutoff: 4.5
    E fit_normalization:
    E aggregations:
    E - code/n_occurrences
    E - code/n_patients
    E - values/n_occurrences
    E - values/sum
    E - values/sum_sqd
    E fit_vocabulary_indices:
    E is_metadata: true
    E ordering_method: lexicographic
    E output_dir: ${cohort_dir}
    E reorder_measurements:
    E ordered_code_patterns: &&&
    E worker: 0
    E polling_time: 300
    E stage: ${current_script_name:}
    E stage_cfg: ${oc.create:${populate_stage:${stage}, ${input_dir}, ${cohort_dir}, ${stages},
    E ${stage_configs}}}
    E etl_metadata:
    E pipeline_name: &&&
    E dataset_name: &&&
    E dataset_version: &&&
    E package_name: ${get_package_name:}
    E package_version: ${get_package_version:}
    E etl_metadata.pipeline_name: preprocess
    E code_modifiers: &&&
    E
    E Stage: fit_vocabulary_indices
    E
    E Stage config:
    E is_metadata: true
    E ordering_method: lexicographic
    E output_dir: ........./tmp/tmpewm0iuof/output_cohort
    E data_input_dir: ........./tmpewm0iuof/MEDS_cohort/data
    E metadata_input_dir: ........./tmpewm0iuof/MEDS_cohort/metadata
    E reducer_output_dir: ............/tmpewm0iuof/output_cohort/metadata
    E train_only: true
    E #x1B[0m
    E #x1B[32m2024-08-14 01:14:08.473#x1B[0m | #x1B[1mINFO #x1B[0m | #x1B[36mMEDS_transforms.fit_vocabulary_indices#x1B[0m:#x1B[36mmain#x1B[0m:#x1B[36m222#x1B[0m - #x1B[1mAssigning code vocabulary indices via a lexicographic order.#x1B[0m
    E #x1B[32m2024-08-14 01:14:08.477#x1B[0m | #x1B[1mINFO #x1B[0m | #x1B[36mMEDS_transforms.fit_vocabulary_indices#x1B[0m:#x1B[36mmain#x1B[0m:#x1B[36m233#x1B[0m - #x1B[1mIndices assigned. Writing to .../output_cohort/metadata/codes.parquet#x1B[0m
    E #x1B[32m2024-08-14 01:14:08.479#x1B[0m | #x1B[1mINFO #x1B[0m | #x1B[36mMEDS_transforms.fit_vocabulary_indices#x1B[0m:#x1B[36mmain#x1B[0m:#x1B[36m237#x1B[0m - #x1B[1mDone with fit_vocabulary_indices#x1B[0m
    E
    E DataFrames are different (dtypes do not match)
    E [left]: {'code': String, 'code/n_occurrences': UInt8, 'code/n_patients': UInt8, 'values/n_occurrences': UInt8, 'values/sum': Float32, 'values/sum_sqd': Float32, 'description': String, 'parent_codes': String, 'code/vocab_index': UInt8}
    E [right]: {'code': String, 'code/n_occurrences': UInt8, 'code/n_patients': UInt8, 'values/n_occurrences': UInt8, 'values/sum': Float32, 'values/sum_sqd': Float32, 'description': String, 'parent_codes': List(String), 'code/vocab_index': UInt8}

    tests/utils.py:179: AssertionError

@mmcdermott mmcdermott merged commit a751f72 into dev Aug 14, 2024
6 checks passed
@mmcdermott mmcdermott deleted the 110_remove_agg_from_default_extract branch August 14, 2024 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants