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

Offset shape bugfix #73

Merged
merged 6 commits into from
Oct 20, 2024
Merged

Offset shape bugfix #73

merged 6 commits into from
Oct 20, 2024

Conversation

charles-zhng
Copy link
Collaborator

@charles-zhng charles-zhng commented Oct 19, 2024

Reshape offset when saving from fit_offsets

Also updated run_stac.py and stac config files to work with renamed values

Summary by CodeRabbit

  • New Features
    • Updated parameter names for improved clarity in configuration settings.
      • Renamed fit_path to fit_offsets_path across multiple configuration files.
      • Replaced ik_only with skip_ik_only in relevant configurations to clarify functionality.
  • Bug Fixes
    • Updated test assertions to reflect the new naming conventions in configuration settings.

Copy link
Contributor

coderabbitai bot commented Oct 19, 2024

Walkthrough

The pull request introduces modifications across several configuration files. Key changes include renaming the fit_path parameter to fit_offsets_path and changing the ik_only parameter to skip_ik_only. Similar adjustments were made in other configuration files, reflecting a clearer naming convention and a shift in the logic concerning inverse kinematics processing. The remaining parameters in each file remain unchanged.

Changes

File Path Change Summary
configs/stac/demo.yaml - Renamed fit_path to fit_offsets_path
- Renamed ik_only to skip_ik_only
configs/stac/stac.yaml - Renamed fit_path to fit_offsets_path
configs/stac/stac_fly_tethered.yaml - Renamed fit_path to fit_offsets_path
- Renamed transform_path to ik_only_path
configs/stac/stac_fly_treadmill.yaml - Renamed fit_path to fit_offsets_path
- Renamed transform_path to ik_only_path
configs/stac/stac_mouse.yaml - Renamed fit_path to fit_offsets_path
tests/configs/stac/test_stac.yaml - Renamed fit_path to fit_offsets_path
tests/unit/test_main.py - Updated assertion from cfg.stac.fit_path to cfg.stac.fit_offsets_path

Possibly related PRs

Suggested reviewers

  • talmo

Poem

🐇 In the meadow, changes bloom,
Paths renamed to clear the gloom.
Offsets fit, and IK skips,
Logic flows like gentle dips.
Hopping forth, we celebrate,
Clarity makes our work first-rate! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

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: 1

🧹 Outside diff range and nitpick comments (5)
stac_mjx/main.py (2)

98-98: LGTM: Consistent return value and minor suggestion

The final return statement has been updated to use fit_offsets_path, maintaining consistency with the variable renaming throughout the function. The functionality remains unchanged.

Consider updating the function's docstring to reflect the change from fit_path to fit_offsets_path in the return value description. This will ensure complete consistency and improve documentation accuracy.


Inconsistent Renaming of fit_path Detected

The verification revealed that not all instances of fit_path have been renamed to fit_offsets_path. Specifically:

  • Remaining Instances of fit_path:

    • demos/run_stac_fly_model.py: Line with fit_path, transform_path = stac_mjx.run_stac(
    • tests/unit/test_main.py: Line with assert cfg.stac.fit_path == "fit.p"
    • run_stac.py: Multiple lines referencing fit_path
  • Verified Renamed Instances:

    • All occurrences of fit_offsets_path in stac_mjx/main.py are correctly updated.

Please address the remaining instances of fit_path to ensure consistent renaming across the codebase.

🔗 Analysis chain

Line range hint 1-98: Summary: Consistent renaming improves code clarity

The changes in this file primarily involve renaming fit_path to fit_offsets_path. This renaming has been consistently applied throughout the run_stac function, affecting variable initialization, logging, file operations, and return statements. The changes align with the PR objectives and improve code clarity by using a more descriptive variable name.

Key points:

  1. All occurrences of fit_path have been updated to fit_offsets_path.
  2. The functionality of the run_stac function remains unchanged.
  3. The changes are consistent with the configuration update mentioned in the PR summary.

To ensure the renaming has been applied consistently across the codebase, please run the following verification script:

This script will help ensure that the renaming has been applied consistently across the entire codebase and that no instances of the old naming convention remain.


Action Required: Update Verification Script to Handle File Type Issue

The initial verification script failed because the python file type is unrecognized. To address this, please use the updated script below that targets Python files by their .py extension:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all occurrences of 'fit_path' have been renamed to 'fit_offsets_path'

# Test 1: Check for any remaining instances of 'fit_path'
echo "Checking for remaining instances of 'fit_path':"
rg --type python 'fit_path'

# Test 2: Verify the usage of 'fit_offsets_path'
echo "Verifying usage of 'fit_offsets_path':"
rg --type python 'fit_offsets_path'

# Test 3: Check for any references to 'cfg.stac.fit_path'
echo "Checking for any references to 'cfg.stac.fit_path':"
rg --type python 'cfg\.stac\.fit_path'

# Test 4: Verify the usage of 'cfg.stac.fit_offsets_path'
echo "Verifying usage of 'cfg.stac.fit_offsets_path':"
rg --type python 'cfg\.stac\.fit_offsets_path'

Length of output: 711


Script:

#!/bin/bash
# Description: Verify that all occurrences of 'fit_path' have been renamed to 'fit_offsets_path'

# Test 1: Check for any remaining instances of 'fit_path'
echo "Checking for remaining instances of 'fit_path' in Python files:"
rg 'fit_path' --glob '*.py'

# Test 2: Verify the usage of 'fit_offsets_path'
echo "Verifying usage of 'fit_offsets_path' in Python files:"
rg 'fit_offsets_path' --glob '*.py'

# Test 3: Check for any references to 'cfg.stac.fit_path'
echo "Checking for any references to 'cfg.stac.fit_path' in Python files:"
rg 'cfg\.stac\.fit_path' --glob '*.py'

# Test 4: Verify the usage of 'cfg.stac.fit_offsets_path'
echo "Verifying usage of 'cfg.stac.fit_offsets_path' in Python files:"
rg 'cfg\.stac\.fit_offsets_path' --glob '*.py'

Length of output: 1575

stac_mjx/stac.py (3)

Line range hint 416-428: Consider addressing the commented-out FLY_MODEL section

There's a commented-out section for handling FLY_MODEL type errors in h5 files. It might be beneficial to either implement this functionality if it's needed or remove the commented code if it's no longer relevant. This will improve code clarity and maintainability.

Would you like assistance in implementing the FLY_MODEL handling or removing the commented code?


Line range hint 1-589: Consider further modularization and addressing TODOs

  1. The Stac class handles a wide range of functionality. Consider splitting it into smaller, more focused classes to improve maintainability and readability.

  2. Long methods like fit_offsets and render could be broken down into smaller, more focused methods. This would enhance readability and make the code easier to maintain and test.

  3. There are TODO comments in the fit_offsets method. It would be beneficial to address these items or create issues to track them for future implementation.

Would you like assistance in modularizing the class or addressing the TODO items?


Line range hint 1-589: Enhance input validation and error handling

While the render method includes good input validation, other methods like fit_offsets and ik_only could benefit from similar checks. Consider adding input validation and consistent error handling across all methods in the Stac class. This would improve the robustness and reliability of the code, making it easier to debug and maintain.

Would you like assistance in implementing input validation for the other methods?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between de8217b and 32a83c4.

📒 Files selected for processing (3)
  • configs/stac/demo.yaml (1 hunks)
  • stac_mjx/main.py (3 hunks)
  • stac_mjx/stac.py (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
configs/stac/demo.yaml (1)

Line range hint 1-12: Verify removal of ik_only parameter

The AI summary mentions that ik_only was renamed to skip_ik_only, but the removal of ik_only is not visible in the provided code. We need to confirm if this removal occurred.

Let's search for any remaining instances of ik_only:

If this search returns results, it might indicate that the renaming was not complete or consistent across all configuration files.

✅ Verification successful

📄 Verification Successful: ik_only Parameter Removed

All instances of the ik_only parameter have been successfully removed and renamed to skip_ik_only in the YAML configuration files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for ik_only in YAML files
rg --type yaml 'ik_only:' configs/

Length of output: 210

stac_mjx/main.py (4)

59-59: LGTM: Improved variable naming

The change from fit_path to fit_offsets_path enhances code clarity by using a more descriptive variable name. This is consistent with the renaming mentioned in the PR summary.


72-73: LGTM: Consistent variable usage

The logging statement and save operation have been updated to use fit_offsets_path, maintaining consistency with the earlier variable renaming. The functionality remains unchanged.


78-78: LGTM: Consistent return value

The return statement has been updated to use fit_offsets_path, maintaining consistency with the variable renaming throughout the function. The functionality remains unchanged.


86-86: LGTM: Consistent file path usage

The file opening operation has been updated to use fit_offsets_path, maintaining consistency with the variable renaming. The functionality remains unchanged.

stac_mjx/stac.py (2)

393-393: Approved: Consistent reshaping of offsets

The change to reshape self._offsets to (-1, 3) ensures a consistent 2D array format for the offsets, regardless of their original shape. This improvement aligns with the PR objective of addressing offset reshaping issues and enhances data structure consistency throughout the code.


Line range hint 1-589: Summary of review

  1. The main change to reshape offsets in the _package_data method has been approved and improves data consistency.
  2. Suggestions for improvement include:
    • Addressing the commented-out FLY_MODEL section
    • Further modularizing the Stac class and breaking down long methods
    • Addressing TODO comments
    • Enhancing input validation and error handling across all methods

Overall, the changes in this PR address the stated objective of fixing offset shape issues. The additional suggestions, if implemented, would further improve the code quality and maintainability.

configs/stac/demo.yaml Show resolved Hide resolved
Copy link

codecov bot commented Oct 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 39.93%. Comparing base (de8217b) to head (d7cd44a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
stac_mjx/main.py 0.00% 6 Missing ⚠️
stac_mjx/stac.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #73      +/-   ##
==========================================
- Coverage   40.95%   39.93%   -1.03%     
==========================================
  Files          10       10              
  Lines         586      576      -10     
==========================================
- Hits          240      230      -10     
  Misses        346      346              

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

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 and nitpick comments (1)
configs/stac/demo.yaml (1)

Line range hint 1-13: Summary of changes and recommendations

The changes in this configuration file align with the PR objectives and improve clarity. However, there are a few important points to address:

  1. Ensure that all references to fit_path have been updated to fit_offsets_path throughout the codebase.
  2. Verify that the change from ik_only to skip_ik_only has been consistently applied across all relevant files.
  3. Review and update any logic that depends on these parameters, especially considering the inversion of the ik_only logic.

These changes have the potential to impact the behavior of the system, so thorough testing is recommended to ensure everything functions as expected with the new configuration.

Consider adding a deprecation warning for any code that still uses the old parameter names to ease the transition and catch any missed updates.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 45a1770 and e499a50.

📒 Files selected for processing (1)
  • configs/stac/demo.yaml (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
configs/stac/demo.yaml (2)

7-7: ⚠️ Potential issue

Verify the consistency of skip_ik_only across the codebase.

The change from ik_only to skip_ik_only represents a logical inversion. While this change improves clarity, it's crucial to ensure that:

  1. All instances of ik_only have been replaced with skip_ik_only throughout the codebase.
  2. The logic in the code has been updated to reflect this inversion (i.e., where if ik_only was used, it should now be if not skip_ik_only).

To verify this change, please run the following script:

Review the output to ensure all instances have been updated correctly and the logic has been adjusted as needed.


1-1: Approve the parameter renaming and verify its usage.

The renaming of fit_path to fit_offsets_path improves clarity. However, ensure that all references to this parameter in the codebase are updated accordingly.

Run the following script to verify the parameter usage:

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: 4

🧹 Outside diff range and nitpick comments (2)
configs/stac/stac.yaml (1)

Line range hint 10-16: Suggestion: Update commented FLY_MODEL configuration

The commented FLY_MODEL section contains the outdated fit_path key. Consider updating it to fit_offsets_path for consistency with the recent changes. This will ensure that if the FLY_MODEL configuration is uncommented in the future, it will use the correct key names.

Here's the suggested change:

 ##FLY_MODEL
-# fit_path: "fit_tethered.p"
+# fit_offsets_path: "fit_tethered.p"
 # transform_path: "transform_tethered.p"
 # data_path: "tests/data/test_rodent_mocap_1000_frames.nwb"
 #
 #n_fit_frames: 601
 #skip_fit_offsets: False
 #skip_ik_only: False
configs/stac/stac_fly_treadmill.yaml (1)

Line range hint 3-7: Consider updating data download instructions.

While not directly related to the changes made, the comment about downloading data could be improved for clarity and ease of use.

Consider updating the comment to include:

  1. A brief description of what the data file contains.
  2. The expected file name after download.
  3. Instructions on where to place the downloaded file relative to the project structure.

For example:

# Download fly treadmill dataset:
# 1. Visit: https://datadryad.org/stash/dataset/doi:10.5061/dryad.mpg4f4r73
# 2. Download file: https://datadryad.org/stash/downloads/file_stream/3361804
# 3. Rename downloaded file to "wt_berlin_linear_treadmill_dataset.csv"
# 4. Place the file in the "tests/data/" directory of this project
data_path: "/tests/data/wt_berlin_linear_treadmill_dataset.csv"

This will help future users or contributors to set up the environment more easily.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e499a50 and cf99810.

📒 Files selected for processing (4)
  • configs/stac/stac.yaml (1 hunks)
  • configs/stac/stac_fly_tethered.yaml (1 hunks)
  • configs/stac/stac_fly_treadmill.yaml (1 hunks)
  • configs/stac/stac_mouse.yaml (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
configs/stac/stac_mouse.yaml (1)

Line range hint 2-13: Configuration appears appropriate and consistent

The remaining configuration parameters are unchanged and seem appropriate for the STAC mouse model. The skip_ik_only parameter set to True is consistent with the PR objectives mentioning updates to accommodate renamed values. No further changes are required in this file based on the PR objectives and AI summary.

configs/stac/stac.yaml (2)

1-1: Approved: Improved naming for better clarity and consistency

The change from fit_path to fit_offsets_path is a good improvement. It makes the configuration more descriptive and aligns with the fit_offsets function mentioned in the PR objectives. This change also maintains consistency with similar modifications in other configuration files, enhancing overall code readability and maintainability.


Line range hint 7-7: Verify: Confirm the skip_ik_only flag setting

The skip_ik_only flag is set to True. Please confirm that this is the intended setting for this configuration. If it's meant to be False or if it should be configurable, consider updating it accordingly.

configs/stac/stac_mouse.yaml Show resolved Hide resolved
configs/stac/stac_fly_treadmill.yaml Show resolved Hide resolved
configs/stac/stac_fly_tethered.yaml Show resolved Hide resolved
configs/stac/stac_fly_tethered.yaml Show resolved Hide resolved
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cf99810 and d7cd44a.

📒 Files selected for processing (2)
  • tests/configs/stac/test_stac.yaml (1 hunks)
  • tests/unit/test_main.py (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
tests/configs/stac/test_stac.yaml (2)

Line range hint 1-13: Overall, the changes look good with a minor verification needed.

The renaming of fit_path to fit_offsets_path improves clarity and aligns with the PR objectives. The rest of the file remains unchanged and appears to be in order. The only point that needs verification is the consistency of ik_only_path and skip_ik_only usage across the codebase.


2-2: Verify intention: ik_only_path unchanged

While fit_path was renamed to fit_offsets_path, ik_only_path remains unchanged. This might be intentional, but it's worth verifying to ensure consistency across the codebase.

Please run the following script to check for consistency:

#!/bin/bash
# Description: Verify the usage of 'ik_only_path' and 'skip_ik_only' across the codebase.

# Test 1: Check for 'ik_only_path' usage
echo "Checking 'ik_only_path' usage:"
rg 'ik_only_path' --type yaml --type py

# Test 2: Check for 'skip_ik_only' usage
echo "Checking 'skip_ik_only' usage:"
rg 'skip_ik_only' --type yaml --type py

# Test 3: Check for any remaining 'ik_only' (not path) references
echo "Checking for remaining 'ik_only' references:"
rg '\bik_only\b' --type yaml --type py

This script will help ensure that the naming conventions for ik_only_path and skip_ik_only are consistent across the project.

tests/unit/test_main.py (1)

21-21: LGTM: Test updated to reflect configuration changes.

The change from cfg.stac.fit_path to cfg.stac.fit_offsets_path in the assertion is consistent with the broader changes made across configuration files in this PR. This update ensures that the test accurately reflects the new configuration structure, maintaining the integrity of the test suite.

tests/configs/stac/test_stac.yaml Show resolved Hide resolved
Copy link
Contributor

@jf514 jf514 left a comment

Choose a reason for hiding this comment

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

LTGM. Note: this process is a real paint! We need to figure out a way to manage this better. Grr.

@jf514 jf514 merged commit 36ab413 into main Oct 20, 2024
5 checks passed
@jf514 jf514 deleted the offset-shape-bugfix branch October 25, 2024 19:51
jf514 pushed a commit that referenced this pull request Oct 25, 2024
* fix offset shape when saving

* update demo config

* linter

* fix demo.yaml

* update configs

* update config test

---------

Co-authored-by: Charles Zhang <[email protected]>
This was referenced Oct 25, 2024
jf514 pushed a commit that referenced this pull request Oct 26, 2024
* fix offset shape when saving

* update demo config

* linter

* fix demo.yaml

* update configs

* update config test

---------

Co-authored-by: Charles Zhang <[email protected]>
jf514 pushed a commit that referenced this pull request Oct 26, 2024
* fix offset shape when saving

* update demo config

* linter

* fix demo.yaml

* update configs

* update config test

---------

Co-authored-by: Charles Zhang <[email protected]>
jf514 added a commit that referenced this pull request Nov 1, 2024
* Model runs + draws in notebook, no data output

* Configs etc - model not yet working.

* Disable energy

* Offset shape bugfix (#73)

* fix offset shape when saving

* update demo config

* linter

* fix demo.yaml

* update configs

* update config test

---------

Co-authored-by: Charles Zhang <[email protected]>

* Smoke test (#74)

* run stac experiment

* Fixed yaml

* Test fail with bad input.

* Should fail.

* Corrected input - test should pass.

* Update demo.yaml - enable ik_only()

* Revert update demo.yaml

* IT'S WORKING

* Offset shape bugfix (#73)

* fix offset shape when saving

* update demo config

* linter

* fix demo.yaml

* update configs

* update config test

---------

Co-authored-by: Charles Zhang <[email protected]>

* Configs etc - model not yet working.

* Offset shape bugfix (#73)

* fix offset shape when saving

* update demo config

* linter

* fix demo.yaml

* update configs

* update config test

---------

Co-authored-by: Charles Zhang <[email protected]>

* Configs etc - model not yet working.

* Fix weird merge.

* Clean up synth_model config file.

* Remove TIME_BINS (which was a merge accident.)

* Fix smoke test.

* Fix smoke test.

* Clean up.

* Fixed root optimization, but still some debug code.

* Add root_kp_index

* Forgot model yaml.

* Reset rodent configs, enable synth config.

* Add synth_data smoke test.

* Missed data file.

* Clean up.

* Add root opt keypoint to model configs + clean up.

* Clean up.

* CR feedback.

* Add synth data generation program.

* Add comments.

---------

Co-authored-by: Charles Zhang <[email protected]>
Co-authored-by: Charles Zhang <[email protected]>
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.

2 participants