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

Series class accepts .slp files #79

Closed
wants to merge 13 commits into from

Conversation

eberrigan
Copy link
Collaborator

@eberrigan eberrigan commented May 8, 2024

  • h5 paths are optional in the Series class but necessary for the plotting function
  • series_name is now an attribute that uniquely identifies the sample
  • series_name can be found using the h5_path or directly input
  • find_all_slp_series added to find unique series_name from .slp files in a list of data folders

Summary by CodeRabbit

  • New Features

    • Enhanced the Series class with a new attribute for series naming and improved parameter handling in the loading method.
    • Introduced a new notebook Series.ipynb for managing series data using the sleap_roots package.
  • Enhancements

    • Updated support for Python versions 3.10 and 3.11 in the project configuration.
  • Refactor

    • Renamed function to better reflect its functionality from find_all_h5_series to find_all_slp_series.
  • Documentation

    • Updated README to reflect new Python version setup instructions.
  • Bug Fixes

    • Adjusted function calls in test files to align with updated method signatures and enhanced functionality.

Copy link
Contributor

coderabbitai bot commented May 8, 2024

Walkthrough

The recent updates focus on enhancing compatibility with newer Python versions, refining the handling of series data in the sleap_roots package, and improving file type specificity in function names. Changes also include method signature updates to better manage series names and prediction suffixes, ensuring smoother integration and usability.

Changes

File Path Change Summary
sleap_roots/series.py Added series_name attribute and updated method signatures and function names for clarity.
pyproject.toml, environment.yml, README.md Updated Python version support and dependency versions.
tests/... Updated tests to reflect new function names and method parameters.
notebooks/Series.ipynb Introduced a new notebook for series data management.

Poem

🐇✨
In the garden of code, where the data vines twirl,
A rabbit hopped by, updating the world.
With a tweak and a hop, Python versions align,
Series named, and tests redesigned.
Oh, how sleek these roots now grow,
In the digital burrow where the bytes do flow!
🌱🖥️


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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: 2

Out of diff range and nitpick comments (2)
sleap_roots/series.py (2)

45-45: Ensure the new attribute series_name is properly documented.

Consider adding a brief description in the class docstring for the series_name attribute to explain its purpose and usage.


Line range hint 387-387: Use isinstance() for type checking.

-    if type(data_folders) != list:
+    if not isinstance(data_folders, list):

Using isinstance() is more Pythonic and supports subclass checking.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9516f47 and ff5909f.
Files selected for processing (1)
  • sleap_roots/series.py (8 hunks)
Additional Context Used
Ruff (2)
sleap_roots/series.py (2)

387-387: Do not compare types, use isinstance()


405-405: Do not compare types, use isinstance()

Additional comments not posted (2)
sleap_roots/series.py (2)

56-57: Updated method signature for load to include series_name.

The inclusion of series_name as an optional parameter enhances flexibility in data handling.


396-412: Function find_all_slp_series correctly extracts unique series names from .slp files.

This function enhances the software's capability to handle .slp files, aligning with the PR's objectives.

Comment on lines +88 to +92
if series_name is None:
if h5_path is not None:
series_name = Path(h5_path).name.split(".")[0]
else:
raise ValueError("series_name or h5_path must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Add error handling for both series_name and h5_path being None.

-                raise ValueError("series_name or h5_path must be provided.")
+                raise ValueError("Either 'series_name' or 'h5_path' must be provided.")

This change clarifies the error message, making it more informative.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if series_name is None:
if h5_path is not None:
series_name = Path(h5_path).name.split(".")[0]
else:
raise ValueError("series_name or h5_path must be provided.")
if series_name is None:
if h5_path is not None:
series_name = Path(h5_path).name.split(".")[0]
else:
raise ValueError("Either 'series_name' or 'h5_path' must be provided.")

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 ff5909f and 5240c8b.
Files selected for processing (1)
  • pyproject.toml (2 hunks)
Files skipped from review due to trivial changes (1)
  • pyproject.toml

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 5240c8b and 305a813.
Files selected for processing (2)
  • environment.yml (1 hunks)
  • pyproject.toml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml
Additional comments not posted (1)
environment.yml (1)

8-8: Update to Python 3.11 noted. Ensure compatibility of all dependencies with this Python version.

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

Out of diff range and nitpick comments (10)
sleap_roots/__init__.py (2)

Line range hint 14-14: Consider removing or using the sleap_roots.trait_pipelines import as it is currently unused.


Line range hint 16-20: The specific imports from sleap_roots.trait_pipelines are unused. Consider removing them or adding them to __all__ if they need to be exposed as public API.

tests/test_series.py (1)

Line range hint 79-79: The function test_series_name is redefined. This could lead to unexpected behavior in testing. Consider renaming one of the functions or combining their logic if applicable.

README.md (6)

Line range hint 24-24: It seems there might be a missing closing bracket ] for the markdown link. Please check and correct if necessary.


Line range hint 141-141: Consider adding a comma after "environment" for better readability: "activate your conda environment, which includes JupyterLab (recommended)".


Line range hint 157-157: Remove the trailing space at the end of this line to maintain clean and consistent formatting.


Line range hint 207-207: Remove the trailing space at the end of this line to maintain clean and consistent formatting.


Line range hint 27-27: Multiple consecutive blank lines found. Consider reducing to a single blank line to maintain clean formatting.


Line range hint 160-160: Multiple consecutive blank lines found. Consider reducing to a single blank line to maintain clean formatting.

sleap_roots/series.py (1)

Line range hint 388-388: Use isinstance() for type checking instead of comparing types directly. This is more Pythonic and supports subclass checking.

-    if type(data_folders) != list:
+    if not isinstance(data_folders, list):
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 305a813 and 0e5d34d.
Files selected for processing (5)
  • README.md (1 hunks)
  • sleap_roots/init.py (1 hunks)
  • sleap_roots/series.py (8 hunks)
  • tests/test_series.py (4 hunks)
  • tests/test_trait_pipelines.py (5 hunks)
Additional Context Used
LanguageTool (2)
README.md (2)

Near line 24: Unpaired symbol: ‘]’ seems to be missing
Context: ...ntation per pipeline is available here: [sleap-roots HackMD](https://hackmd.io/DM...


Near line 141: Possible missing comma found.
Context: ...oks`. To use them, activate your conda environment which includes JupyterLab (recommended)...

Ruff (15)
sleap_roots/__init__.py (9)

14-14: sleap_roots.trait_pipelines imported but unused; consider removing, adding to __all__, or using a redundant alias


16-16: sleap_roots.trait_pipelines.DicotPipeline imported but unused; consider removing, adding to __all__, or using a redundant alias


17-17: sleap_roots.trait_pipelines.TraitDef imported but unused; consider removing, adding to __all__, or using a redundant alias


18-18: sleap_roots.trait_pipelines.YoungerMonocotPipeline imported but unused; consider removing, adding to __all__, or using a redundant alias


19-19: sleap_roots.trait_pipelines.OlderMonocotPipeline imported but unused; consider removing, adding to __all__, or using a redundant alias


20-20: sleap_roots.trait_pipelines.MultipleDicotPipeline imported but unused; consider removing, adding to __all__, or using a redundant alias


22-22: sleap_roots.series.Series imported but unused; consider removing, adding to __all__, or using a redundant alias


22-22: sleap_roots.series.find_all_h5_series imported but unused; consider removing, adding to __all__, or using a redundant alias


22-22: sleap_roots.series.find_all_slp_series imported but unused; consider removing, adding to __all__, or using a redundant alias

sleap_roots/series.py (2)

388-388: Do not compare types, use isinstance()


406-406: Do not compare types, use isinstance()

tests/test_series.py (3)

2-2: numpy imported but unused


4-4: sleap_roots.series.find_all_slp_series imported but unused


79-79: Redefinition of unused test_series_name from line 60

tests/test_trait_pipelines.py (1)

9-9: sleap_roots.series.find_all_slp_series imported but unused

@@ -19,7 +19,7 @@
OlderMonocotPipeline,
MultipleDicotPipeline,
)
from sleap_roots.series import Series, find_all_series
from sleap_roots.series import Series, find_all_h5_series, find_all_slp_series
Copy link
Contributor

Choose a reason for hiding this comment

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

The imports from sleap_roots.series are unused in this file. Consider removing them or using them appropriately.

@@ -1,7 +1,7 @@
import sleap_io as sio
import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

The numpy import is unused in this file. Consider removing it unless it's needed for future tests.

@@ -1,7 +1,7 @@
import sleap_io as sio
import numpy as np
import pytest
from sleap_roots.series import Series, find_all_series
from sleap_roots.series import Series, find_all_h5_series, find_all_slp_series
Copy link
Contributor

Choose a reason for hiding this comment

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

The import find_all_slp_series is unused in this file. Consider removing it to clean up the code.

@@ -6,13 +6,19 @@
OlderMonocotPipeline,
MultipleDicotPipeline,
)
from sleap_roots.series import Series, find_all_series
from sleap_roots.series import Series, find_all_h5_series, find_all_slp_series
Copy link
Contributor

Choose a reason for hiding this comment

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

The import find_all_slp_series is unused in this file. Consider removing it to clean up the code.

Returns:
A list of unique series names derived from the filenames.
"""
if type(data_folders) != list:
Copy link
Contributor

Choose a reason for hiding this comment

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

Use isinstance() for type checking instead of comparing types directly. This is more Pythonic and supports subclass checking.

-    if type(data_folders) != list:
+    if not isinstance(data_folders, list):

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if type(data_folders) != list:
if not isinstance(data_folders, list):

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 0e5d34d and 4708eec.
Files selected for processing (4)
  • notebooks/Series.ipynb (1 hunks)
  • sleap_roots/series.py (9 hunks)
  • tests/test_series.py (4 hunks)
  • tests/test_trait_pipelines.py (5 hunks)
Files not reviewed due to errors (3)
  • notebooks/Series.ipynb (no review received)
  • tests/test_trait_pipelines.py (no review received)
  • sleap_roots/series.py (no review received)
Additional Context Used
Ruff (6)
sleap_roots/series.py (2)

388-388: Do not compare types, use isinstance()


406-406: Do not compare types, use isinstance()

tests/test_series.py (3)

2-2: numpy imported but unused


4-4: sleap_roots.series.find_all_slp_series imported but unused


74-74: Redefinition of unused test_series_name from line 60

tests/test_trait_pipelines.py (1)

9-9: sleap_roots.series.find_all_slp_series imported but unused

Additional comments not posted (12)
tests/test_series.py (12)

12-12: LGTM! The fixture correctly initializes a Series instance with dummy data.


17-17: LGTM! The fixture correctly creates a dummy video file path.


Line range hint 25-25: LGTM! The fixture correctly creates a dummy labels file path.


Line range hint 33-33: LGTM! The fixture correctly creates a Series instance using dummy paths.


Line range hint 41-41: LGTM! The fixture correctly creates a dummy CSV file path.


Line range hint 49-49: LGTM! The test correctly checks the series_name attribute.


Line range hint 57-57: LGTM! The test correctly checks the get_frame method.


89-89: LGTM! The test correctly checks the load method with specific parameters.


97-97: LGTM! The test correctly checks the find_all_h5_series function with a specific folder.


Line range hint 105-105: LGTM! The test correctly checks the load method with specific parameters for rice data.


Line range hint 113-113: LGTM! The test correctly checks the get_frame method with specific parameters for rice data.


136-136: LGTM! The test correctly checks the find_all_h5_series function with a specific folder for rice data.

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 4708eec and 5aa38e1.
Files selected for processing (1)
  • notebooks/Series.ipynb (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • notebooks/Series.ipynb

@eberrigan eberrigan closed this May 13, 2024
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.

1 participant