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

docs: Add docs for plugin create #795

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open

docs: Add docs for plugin create #795

wants to merge 13 commits into from

Conversation

Czaki
Copy link
Collaborator

@Czaki Czaki commented Nov 15, 2022

Summary by CodeRabbit

  • Documentation

    • Updated setup instructions with a new pre-initialization task for system dependencies.
    • Enhanced Sphinx documentation with automatic section labeling for improved navigation.
    • Added a section on plugin creation, including development mode details for PartSeg plugins.
    • Provided a list of existing plugins with descriptions for extending application functionality.
  • Refactor

    • Deprecated certain algorithm enumeration values, introducing new terms for segmentation processes.
  • Chores

    • Improved documentation clarity by correcting grammatical errors in docstrings.

@Czaki Czaki added this to the 0.15.0 milestone Nov 15, 2022
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 15, 2022

Sourcery Code Quality Report

Merging this PR leaves code quality unchanged.

Quality metrics Before After Change
Complexity 5.74 ⭐ 5.67 ⭐ -0.07 👍
Method Length 69.00 🙂 68.02 🙂 -0.98 👍
Working memory 8.94 🙂 8.96 🙂 0.02 👎
Quality 65.57% 🙂 65.57% 🙂 0.00%
Other metrics Before After Change
Lines 680 700 20
Changed files Quality Before Quality After Quality Change
docs/conf.py 79.92% ⭐ 79.77% ⭐ -0.15% 👎
package/PartSegCore/algorithm_describe_base.py 66.67% 🙂 66.85% 🙂 0.18% 👍
package/PartSegCore/register.py 46.32% 😞 45.82% 😞 -0.50% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
package/PartSegCore/algorithm_describe_base.py ROIExtractionProfile._pretty_print 21 😞 224 ⛔ 12 😞 34.52% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
package/PartSegCore/algorithm_describe_base.py AlgorithmProperty.__init__ 8 ⭐ 163 😞 14 😞 47.14% 😞 Try splitting into smaller methods. Extract out complex expressions
package/PartSegCore/algorithm_describe_base.py _field_to_algorithm_property 8 ⭐ 162 😞 12 😞 50.22% 🙂 Try splitting into smaller methods. Extract out complex expressions
package/PartSegCore/algorithm_describe_base.py Register.__setitem__ 11 🙂 167 😞 9 🙂 52.66% 🙂 Try splitting into smaller methods
package/PartSegCore/algorithm_describe_base.py Register.register 11 🙂 125 😞 10 😞 55.15% 🙂 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@deprecated-napari-hub-preview-bot
Copy link

Preview page for your plugin is ready here:
https://preview.napari-hub.org/4DNucleome/PartSeg/795
Updated: 2022-12-07T12:29:17.337786

@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.95%. Comparing base (f014ed4) to head (d011273).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #795   +/-   ##
========================================
  Coverage    92.95%   92.95%           
========================================
  Files          205      205           
  Lines        32480    32484    +4     
========================================
+ Hits         30191    30195    +4     
  Misses        2289     2289           

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

@sonarcloud
Copy link

sonarcloud bot commented Dec 31, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Czaki Czaki modified the milestones: 0.15.0, 0.15 May 26, 2023
Copy link
Contributor

coderabbitai bot commented Dec 4, 2023

Walkthrough

The recent updates encompass a range of enhancements including the addition of a pre-initialization task, expansions in documentation covering plugin creation, and refinements in the codebase such as method additions and variable renamings. These changes indicate a strategic focus on extending functionality, improving user guidance, and enhancing the overall code structure for clarity and future maintenance.

Changes

File Path Change Summary
.gitpod.yml Added before task; updated initialization tasks with new commands.
docs/conf.py Included sphinx.ext.autosectionlabel module.
docs/index.rst Added plugins_creation to utilities list.
docs/plugins_creation.rst Documented plugin creation process for PartSeg.
package/.../algorithm_describe_base.py Renamed funcobj to func_obj; added get_fields method; various renamings and docstring update.
package/.../register.py Deprecated certain algorithm enums; introduced new segmentation algorithm enums.

🐇✨
In the realm of code, where rabbits dare,
We hop through updates with utmost care.
New tasks and docs, a plugin's birth,
Our burrow thrives with digital mirth. 🌟📜
🐇✨


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 79230b5 and d011273.
Files selected for processing (2)
  • docs/conf.py (1 hunks)
  • package/PartSegCore/algorithm_describe_base.py (3 hunks)
Files skipped from review due to trivial changes (1)
  • docs/conf.py
Additional comments not posted (4)
package/PartSegCore/algorithm_describe_base.py (4)

133-135: The changes to _partial_abstractmethod are correctly implemented.


141-147: The new method get_fields in AlgorithmDescribeBaseMeta is correctly defined as an abstract method.


130-161: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [158-225]

The implementation of AlgorithmDescribeBase correctly uses abstract methods and the _partial_abstractmethod decorator.


479-487: The modification to the __init__ method in ROIExtractionProfileMeta to warn about positional arguments is correctly implemented.


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.

Review Status

Actionable comments generated: 5

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fd6e1b8 and 79230b5.
Files selected for processing (6)
  • .gitpod.yml (1 hunks)
  • docs/conf.py (1 hunks)
  • docs/index.rst (1 hunks)
  • docs/plugins_creation.rst (1 hunks)
  • package/PartSegCore/algorithm_describe_base.py (3 hunks)
  • package/PartSegCore/register.py (2 hunks)
Additional comments: 7
.gitpod.yml (1)
  • 1-4: The changes to the .gitpod.yml file align with the PR objectives of updating configuration files to enhance the documentation and setup for plugin creation. The addition of the before task for system dependencies and the init task for project setup are appropriate and there are no apparent issues with these changes.
docs/index.rst (1)
  • 19-22: The addition of plugins_creation to the documentation index aligns with the PR objectives to introduce documentation for plugin creation. This change is correctly implemented and follows the Sphinx documentation structure.
docs/plugins_creation.rst (1)
  • 1-116: The documentation is clear and seems to align with the PR objectives of enhancing the documentation for plugin creation in the PartSeg application. It covers the areas where plugins can contribute, the plugin detection process, and the "develop" mode for reloading plugins. It also lists existing plugins, which can serve as examples for new plugin creators.
package/PartSegCore/algorithm_describe_base.py (4)
  • 113-127: The addition of the get_fields method and the renaming of the function parameter from funcobj to func_obj in the _partial_abstractmethod decorator function align with the PR objectives and the summary provided. This change enhances the codebase in line with the goal of improving plugin creation support.

  • 129-138: The renaming of cls2 to cls in the __new__ method of AlgorithmDescribeBaseMeta is consistent with the summary and does not appear to introduce any issues. This change improves the readability of the code.

  • 239-245: The modification of the docstring in the Register class constructor from "may be initial elements" to "maybe initial elements" is a grammatical correction that improves the clarity of the documentation. This change is consistent with the PR objectives of enhancing documentation.

  • 441-453: The renaming of kwargs to kwargs_ in the allow_positional_args decorator function is consistent with the summary and does not introduce any issues. This change avoids potential conflicts with keyword arguments.

Comment on lines 43 to 47
"sphinx_autodoc_typehints",
"PartSegCore.sphinx.auto_parameters",
"sphinxcontrib.autodoc_pydantic",
"sphinx.ext.autosectionlabel",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of "sphinx.ext.autosectionlabel" to the extensions list is correct and aligns with the PR objective of enhancing documentation. Ensure that if there are any documents with duplicate section names, the configuration option "autosectionlabel_prefix_document" is set to True to avoid conflicts.

Comment on lines 44 to 62
flow = 0 #: algorithm for calculation flow from core object to borders. For spiting touching objects, deprecated
threshold = 1 #: threshold algorithms. From greyscale array to binary array
noise_filtering = 2 #: filter noise from image
analysis_algorithm = 3 #: algorithm for creating segmentation in analysis PartSeg part
mask_algorithm = 4 #: algorithm for creating segmentation in mask PartSeg part
analysis_algorithm = 3
"""
algorithm for creating segmentation in analysis PartSeg part
(deprecated in favour of roi_analysis_segmentation_algorithm)
"""
mask_algorithm = 4
"""
algorithm for creating segmentation in mask PartSeg part
(deprecated in favour of roi_mask_segmentation_algorithm)
"""
analysis_save = 5 #: save functions for analysis part
analysis_load = 6 #: load functions for analysis part
mask_load = 7 #: load functions for mask part
mask_load = 7 #: load functions for mask part)
image_transform = 8 #: transform image, like interpolation
mask_save_parameters = 9 #: save metadata for mask part (currently creating json file)
mask_save_components = 10 #: save each segmentation component in separate file. Save location is directory
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The deprecation of analysis_algorithm and mask_algorithm is noted, but references to these deprecated enums are still present in the code. The following locations should be reviewed and updated to use the new roi_analysis_segmentation_algorithm and roi_mask_segmentation_algorithm:

  • ./package/PartSegCore/register.py: lines 77, 97 (for analysis_algorithm)
  • ./package/PartSegCore/register.py: lines 78, 98 (for mask_algorithm)

Comment on lines +4 to +6
PartSeg has a plugin system, but because of a lack of documentation, it is not very popular.
This document is an attempt to explain how to create plugins for PartSeg. The list of good plugins that could be inspirration
is available at the :ref:`end of this document<Already existing plugins>`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor grammatical error.

- This document is an attempt to explain how to create plugins for PartSeg. The list of good plugins that could be inspirration
+ This document is an attempt to explain how to create plugins for PartSeg. The list of good plugins that could be inspiration

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
PartSeg has a plugin system, but because of a lack of documentation, it is not very popular.
This document is an attempt to explain how to create plugins for PartSeg. The list of good plugins that could be inspirration
is available at the :ref:`end of this document<Already existing plugins>`.
PartSeg has a plugin system, but because of a lack of documentation, it is not very popular.
This document is an attempt to explain how to create plugins for PartSeg. The list of good plugins that could be inspiration
is available at the :ref:`end of this document<Already existing plugins>`.

* **ROI Mask save method** - method to save data in *ROI Mask* GUI.


A person interested in developing a plugin could wound the whole list in :py:mod:`PartSegCore.register` module.
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible typo or incorrect word usage.

- A person interested in developing a plugin could wound the whole list in :py:mod:`PartSegCore.register` module.
+ A person interested in developing a plugin could find the whole list in :py:mod:`PartSegCore.register` module.

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
A person interested in developing a plugin could wound the whole list in :py:mod:`PartSegCore.register` module.
A person interested in developing a plugin could find the whole list in :py:mod:`PartSegCore.register` module.


PartSeg-bioimageio
~~~~~~~~~~~~~~~~~~
PartSeg plugin to run bioimage.io deep learning models. It could be found under https:/github.com/czaki/PartSeg-bioimageio/ page
Copy link
Contributor

Choose a reason for hiding this comment

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

The URL provided seems to be missing a colon, which could lead to a broken link.

- PartSeg plugin to run bioimage.io deep learning models. It could be found under https:/github.com/czaki/PartSeg-bioimageio/ page
+ PartSeg plugin to run bioimage.io deep learning models. It could be found under https://github.com/czaki/PartSeg-bioimageio/ page

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
PartSeg plugin to run bioimage.io deep learning models. It could be found under https:/github.com/czaki/PartSeg-bioimageio/ page
PartSeg plugin to run bioimage.io deep learning models. It could be found under https://github.com/czaki/PartSeg-bioimageio/ page

@Czaki Czaki changed the title Add docs for plugin create docs: Add docs for plugin create Dec 4, 2023
Copy link

sonarcloud bot commented Dec 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

sonarcloud bot commented Apr 22, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

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

Comment on lines +149 to +158
def __new__(mcs, name, bases, attrs, **kwargs):
cls = super().__new__(mcs, name, bases, attrs, **kwargs)
if (
not inspect.isabstract(cls2)
and hasattr(cls2.get_fields, "__is_partial_abstractmethod__")
and cls2.__argument_class__ is None
not inspect.isabstract(cls)
and hasattr(cls.get_fields, "__is_partial_abstractmethod__")
and cls.__argument_class__ is None
):
raise RuntimeError("class need to have __argument_class__ set or get_fields functions defined")
cls2.__new_style__ = getattr(cls2.get_fields, "__is_partial_abstractmethod__", False)
return cls2
cls.__new_style__ = getattr(cls.get_fields, "__is_partial_abstractmethod__", False)
return cls
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure correct attribute access in the __new__ method of AlgorithmDescribeBaseMeta. Use hasattr(cls, 'get_fields') and hasattr(cls.get_fields, '__is_partial_abstractmethod__') to check the attribute on the method.

- and hasattr(cls.get_fields, "__is_partial_abstractmethod__")
+ and hasattr(cls, 'get_fields') and hasattr(cls.get_fields, '__is_partial_abstractmethod__')

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
def __new__(mcs, name, bases, attrs, **kwargs):
cls = super().__new__(mcs, name, bases, attrs, **kwargs)
if (
not inspect.isabstract(cls2)
and hasattr(cls2.get_fields, "__is_partial_abstractmethod__")
and cls2.__argument_class__ is None
not inspect.isabstract(cls)
and hasattr(cls.get_fields, "__is_partial_abstractmethod__")
and cls.__argument_class__ is None
):
raise RuntimeError("class need to have __argument_class__ set or get_fields functions defined")
cls2.__new_style__ = getattr(cls2.get_fields, "__is_partial_abstractmethod__", False)
return cls2
cls.__new_style__ = getattr(cls.get_fields, "__is_partial_abstractmethod__", False)
return cls
def __new__(mcs, name, bases, attrs, **kwargs):
cls = super().__new__(mcs, name, bases, attrs, **kwargs)
if (
not inspect.isabstract(cls)
and hasattr(cls, 'get_fields') and hasattr(cls.get_fields, '__is_partial_abstractmethod__')
and cls.__argument_class__ is None
):
raise RuntimeError("class need to have __argument_class__ set or get_fields functions defined")
cls.__new_style__ = getattr(cls.get_fields, "__is_partial_abstractmethod__", False)
return cls

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.

None yet

1 participant