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

Tokenization Stage Misalignment Fix #198

Merged
merged 4 commits into from
Sep 1, 2024
Merged

Conversation

Oufattole
Copy link
Collaborator

@Oufattole Oufattole commented Sep 1, 2024

Resolves issue #197

Added doctests and integration tests that reproduced the issue and resolve it.

Summary by CodeRabbit

  • New Features

    • Enhanced data processing capabilities with a new full outer join, allowing for more comprehensive data inclusion.
    • Introduced coalescing of null values to improve data output integrity.
    • Added a new test function to validate tokenization under scenarios with missing static data.
  • Bug Fixes

    • Improved robustness of the tokenization process by handling missing static data scenarios effectively.
  • Tests

    • Expanded test suite with new data structures and scenarios to enhance validation of the tokenization process.

@Oufattole Oufattole self-assigned this Sep 1, 2024
Copy link
Contributor

coderabbitai bot commented Sep 1, 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

The changes involve significant modifications to the extract_statics_and_schema function, including a transition from an inner join to a full outer join in data processing. Additionally, new test cases and data structures have been introduced to enhance the testing of tokenization processes, particularly in scenarios where static data may be missing.

Changes

Files Change Summary
src/MEDS_transforms/transforms/tokenization.py Modified extract_statics_and_schema to use a full outer join and added coalesce=True for null handling. Enhanced with doctests for clarity.
tests/MEDS_Transforms/test_tokenization.py Introduced new DataFrame and dictionary for expected outputs, and added test_tokenization_missing_static function to validate tokenization with missing static data.

Sequence Diagram(s)

sequenceDiagram
    participant A as DataFrame
    participant B as extract_statics_and_schema
    participant C as Output DataFrame

    A->>B: Input DataFrame with static and schema data
    B->>B: Perform full outer join
    B->>B: Coalesce null values
    B->>C: Return processed Output DataFrame
Loading

🐇
In the meadow, changes bloom,
With joins that sweep away the gloom.
Data flows, both wide and free,
A rabbit hops with glee, you see!
New tests to check, all snug and bright,
In the fields of code, all feels just right! 🌼


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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@Oufattole Oufattole changed the base branch from main to dev September 1, 2024 18:31
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 9588583 and 8724aa0.

Files selected for processing (2)
  • src/MEDS_transforms/transforms/tokenization.py (2 hunks)
  • tests/MEDS_Transforms/test_tokenization.py (4 hunks)
Additional comments not posted (6)
tests/MEDS_Transforms/test_tokenization.py (5)

15-18: LGTM!

The code changes are approved.


82-91: LGTM!

The code changes are approved. The new DataFrame WANT_SCHEMAS_TRAIN_0_MISSING_STATIC is well-defined and will be useful for validating the tokenization process against expected outputs when static data is missing.


227-232: LGTM!

The code changes are approved. The new dictionary WANT_SCHEMAS_MISSING_STATIC is well-defined and will enhance the organization of expected schema outputs.


241-281: LGTM!

The code changes are approved. The new string WANT_TRAIN_0 and variable NORMALIZED_SHARDS_MISSING_STATIC are well-defined and will be useful for testing the tokenization process when static data is missing.


302-321: LGTM!

The code changes are approved. The new test function test_tokenization_missing_static is well-defined and will significantly improve the robustness of the testing framework by ensuring that edge cases related to missing static data are adequately covered.

src/MEDS_transforms/transforms/tokenization.py (1)

147-178: LGTM! The changes improve the function's robustness and maintainability.

The key improvements are:

  1. Changing from inner join to full outer join allows the function to handle scenarios where there are no matching entries between the static_by_subject and schema_by_subject DataFrames. This enhances the function's ability to handle diverse data scenarios.

  2. The coalesce=True parameter ensures that any null values resulting from the join are handled appropriately, improving the output's integrity.

  3. The extensive doctests provide clear examples of the function's expected behavior with sample data. They illustrate how the function processes and transforms the data, and demonstrate the output shapes and types. This greatly improves the code's maintainability.

Also applies to: 193-193

@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 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 94.38%. Comparing base (cab6ecb) to head (df86efb).
Report is 6 commits behind head on dev.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #198      +/-   ##
==========================================
+ Coverage   94.23%   94.38%   +0.14%     
==========================================
  Files          27       27              
  Lines        2100     2100              
==========================================
+ Hits         1979     1982       +3     
+ Misses        121      118       -3     

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

Copy link
Owner

@mmcdermott mmcdermott left a comment

Choose a reason for hiding this comment

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

Tiny fix requested re the naming of the imported shards from the normalization test otherwise this looks good to go in.

tests/MEDS_Transforms/test_tokenization.py Outdated Show resolved Hide resolved
tests/MEDS_Transforms/test_tokenization.py Outdated Show resolved Hide resolved
tests/MEDS_Transforms/test_tokenization.py Show resolved Hide resolved
@mmcdermott mmcdermott linked an issue Sep 1, 2024 that may be closed by this pull request
@mmcdermott mmcdermott merged commit b43abd1 into dev Sep 1, 2024
7 checks passed
@mmcdermott mmcdermott deleted the tokenization_alignment_fix branch September 1, 2024 19:01
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.

Misalignment Between Static and Event Sequence DataFrames
3 participants