Skip to content

component how-to guide#667

Merged
atravitz merged 23 commits intomainfrom
docs/component_howto
Feb 18, 2026
Merged

component how-to guide#667
atravitz merged 23 commits intomainfrom
docs/component_howto

Conversation

@atravitz
Copy link
Copy Markdown
Contributor

@atravitz atravitz commented Oct 29, 2025

resolves #521

Tips

  • Comment "pre-commit.ci autofix" to have pre-commit.ci atomically format your PR.
    Since this will create a commit, it is best to make this comment when you are finished with your work.

Checklist

  • Added a news entry

Developers certificate of origin

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.88%. Comparing base (b738422) to head (0b16dcb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #667   +/-   ##
=======================================
  Coverage   98.88%   98.88%           
=======================================
  Files          42       42           
  Lines        2685     2685           
=======================================
  Hits         2655     2655           
  Misses         30       30           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@atravitz atravitz self-assigned this Dec 18, 2025
@atravitz atravitz force-pushed the docs/component_howto branch from c4e738d to e5065d4 Compare December 19, 2025 15:58
@atravitz atravitz force-pushed the docs/component_howto branch from 2277562 to 04f32d9 Compare January 7, 2026 15:44
@atravitz atravitz changed the title [WIP] component how-to guide component how-to guide Jan 7, 2026
@atravitz atravitz marked this pull request as ready for review January 8, 2026 01:00
@atravitz atravitz marked this pull request as draft January 8, 2026 01:01
@atravitz atravitz marked this pull request as ready for review January 23, 2026 18:33
Copy link
Copy Markdown
Member

@dotsdl dotsdl left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements to this how-to! I've found several critical technical issues that need fixing before merge. I'm also creating a companion PR with additional enhancements (Overview section, Best Practices, etc.) that you can reference or cherry-pick from.

@dotsdl
Copy link
Copy Markdown
Member

dotsdl commented Jan 23, 2026

Critical Fix 1: Wrong method names (Line ~90)

CRITICAL: The method names are incorrect. Should be _to_dict() and _from_dict() (with leading underscores), not to_dict() and from_dict().

Current line says:

in this case to_dict() and from_dict().

These are the actual private method names that need to be implemented for serialization. If users follow this as written, their code won't work.

Suggested fix:

In other cases, such as when inheriting from ``ExplicitMoleculeComponent``, you will only need to define methods specifically not implemented - in this case ``_to_dict()`` and ``_from_dict()``.

@dotsdl
Copy link
Copy Markdown
Member

dotsdl commented Jan 23, 2026

Critical Fix 2: Missing imports (Line ~45)

CRITICAL: The first test example is missing required imports. As written, this code won't run because GufeTokenizableTestsMixin, pytest, and Chem are not imported but are used in the code.

Current code is missing these imports:

from gufe.tests import GufeTokenizableTestsMixin
import pytest
from rdkit import Chem

Suggested fix: Add all imports at the top of the test file example in Step 2.

@dotsdl
Copy link
Copy Markdown
Member

dotsdl commented Jan 23, 2026

Critical Fix 3: Missing serialization warning (After Step 4 example)

CRITICAL: Need to warn users that adding custom attributes (like custom_attribute in the Step 4 example) requires implementing _to_dict(), _from_dict(), and _gufe_tokenize() methods. Without this warning, users will create components that fail to serialize/deserialize correctly.

Suggested addition after the print_custom_attribute method example:

.. warning::
   If you add custom attributes like ``custom_attribute`` above, you must also implement
   ``_to_dict()``, ``_from_dict()``, and ``_gufe_tokenize()`` methods to properly handle
   serialization and hashing. See the :ref:`serialization how-to <howto-serialization>`
   for details. The example above is simplified to demonstrate adding methods; in practice,
   you may want to add only methods (not attributes) to avoid serialization complexity.

@dotsdl
Copy link
Copy Markdown
Member

dotsdl commented Jan 23, 2026

Critical Fix 4: Broken Sphinx reference (Line 6)

The Sphinx reference syntax is malformed - missing space in :ref:\Component`andGufeTokenizable` isn't cross-referenced at all.

Current:

The **gufe**  :ref:`Component<component>` is a GufeTokenizable intended to be used...

Should be:

The **gufe**  :ref:`Component <component>` is a :ref:`GufeTokenizable <understanding_gufetokenizables>` intended to be used as an *extensible point* of the library, so that you can describe a simulated system in terms of ``GufeTokenizable``\s that are compatible with **gufe** and the rest of the OpenFE ecosystem.

This ensures proper cross-linking in the rendered documentation.

@dotsdl
Copy link
Copy Markdown
Member

dotsdl commented Jan 23, 2026

Critical Fix 5: Missing news entry

PR checklist requires a news entry but none exists. Please create news/component-howto.rst:

**Added:**

* Added how-to guide for defining custom ``Component`` subclasses, covering extensible base classes, required methods, testing strategies, and serialization considerations.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>

Copy link
Copy Markdown
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Couple of comments / nits, otherwise it looks good to me.

Comment thread docs/how-tos/component.rst
Comment thread docs/how-tos/component.rst Outdated
Comment thread docs/how-tos/component.rst
Comment thread docs/how-tos/component.rst Outdated
@github-actions
Copy link
Copy Markdown

No API break detected ✅

@atravitz atravitz enabled auto-merge (squash) February 18, 2026 20:58
@atravitz atravitz merged commit c81a810 into main Feb 18, 2026
13 of 14 checks passed
@atravitz atravitz deleted the docs/component_howto branch February 18, 2026 21:08
@github-project-automation github-project-automation Bot moved this from Sprint - In Review to Done in gufe : advancement sprints Feb 18, 2026
atravitz added a commit that referenced this pull request Mar 2, 2026
* starting component how-to

* add list

* add cat example

* update example

* fix docs formatting

* clean up names

* improve descriptions

* add TODO

* clean up formatting and language for clarity

* fix space

* a word

* address review comments

* address review comments

* add _to_dict and _from_dict for attributes

* add _to_dict and _from_dict in minimal example

* address review comments

* add clarifying sentence in response to review

* clarify docstring

* fix accidental commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add how-to doc for defining a new Component

3 participants