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

Standardize docstrings and improve coverage #21983

Closed
baskaryan opened this issue May 21, 2024 · 2 comments
Closed

Standardize docstrings and improve coverage #21983

baskaryan opened this issue May 21, 2024 · 2 comments
Labels
🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder good first issue Good for newcomers help wanted Good issue for contributors

Comments

@baskaryan
Copy link
Collaborator

baskaryan commented May 21, 2024

Issue

Every public module, class, method and attribute should have a docstring.

Requirements

NOTE!

RST code block must have a newline between .. code-block:: python and the code example, and code example must be tabbed, to render correctly!

Examples

Module

langchain/foo/__init__.py

""""One line summary.

More detailed paragraph.
"""

Class and attributes

Not Pydantic class

class Foo:
  """One line summary.

  More detailed paragraph.
  
  Attributes:
    first_attr: does first thing.
    second_attr: does second thing.

  Example:
    .. code-block:: python
    
      from langchain.foo import Foo
  
      f = Foo(1, 2, "bar")
      ...
  """
  
  def __init__(self, a: int, b: int, c: str) -> None:
    """Initialize using a, b, c.
   
    Args:
      a: ...
      b: ...
      c: ...
   """
    self.first_attr = a + b
    self.second_attr = c

NOTE

If the object attributes and init args are the same then you can just document the init args for non-Pydantic classes and just document the attributes for Pydantic classes.

Pydantic class

from typing import Any

from langchain_core.base_models import BaseModel

class FooPydantic(BaseModel):
  """One line summary.

  More detailed paragraph.

  Example:
    .. code-block:: python
    
      from langchain.foo import Foo
  
      f = Foo(1, 2, "bar")
      ...
  """

  first_attr: int
  """Does first thing."""
  second_attr: str
  """Does second thing.

  Additional info if needed.
  """

    def __init__(self, a: int, b: int, c: str, **kwargs: Any) -> None:
    """Initialize using a, b, c.
   
    Args:
      a: ...
      b: ...
      c: ...
      **kwargs: ...
   """
    first_attr = a + b
    second_attr = c
    super().__init__(first_attr=first_attr, second_attr=second_attr, **kwargs)

Function/method

def bar(a: int, b: str) -> float:
  """One line description.

  More description if needed.

  Args:
    a: ...
    b: ...

  Returns:
    A float of ...

  Raises:
    ValueError: If a is negative.

  Example:
    .. code-block:: python
      
      from langchain.foo import bar

      bar(1, "foo")
      # -> 14.381
  """
@baskaryan baskaryan added documentation Improvements or additions to documentation help wanted Good issue for contributors labels May 21, 2024
@baskaryan baskaryan pinned this issue May 21, 2024
@baskaryan baskaryan changed the title Standardize and improve docstring coverage Standardize docstrings and improve coverage May 21, 2024
@dosubot dosubot bot added the 🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder label May 21, 2024
@eyurtsev eyurtsev added the good first issue Good for newcomers label May 21, 2024
@klaudialemiec
Copy link
Contributor

I will start!

baskaryan pushed a commit that referenced this issue May 22, 2024
Thank you for contributing to LangChain!

- [X] **PR title**: "docs: Chroma docstrings update"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
  - Example: "community: add foobar LLM"


- [X] **PR message**: 
    - **Description:** Added and updated Chroma docstrings
    - **Issue:** #21983


- [X] **Add tests and docs**: If you're adding a new integration, please
include
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in
`docs/docs/integrations` directory.
  - only docs


- [X] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/

Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.
@baskaryan baskaryan unpinned this issue May 29, 2024
baskaryan added a commit that referenced this issue Jun 4, 2024
- [x] **PR title**: Update docstrings for OpenAI base.py
-**Description:** Updated the docstring of few OpenAI functions for a
better understanding of the function.
    - **Issue:** #21983

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
eyurtsev pushed a commit that referenced this issue Jun 5, 2024
…Embeddings (#22031)

- **Description:** add detailed paragraph and example for
BaichuanTextEmbeddings
   - **Issue:** the issue #21983
hinthornw pushed a commit that referenced this issue Jun 20, 2024
Thank you for contributing to LangChain!

- [X] **PR title**: "docs: Chroma docstrings update"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
  - Example: "community: add foobar LLM"


- [X] **PR message**: 
    - **Description:** Added and updated Chroma docstrings
    - **Issue:** #21983


- [X] **Add tests and docs**: If you're adding a new integration, please
include
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in
`docs/docs/integrations` directory.
  - only docs


- [X] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/

Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.
hinthornw pushed a commit that referenced this issue Jun 20, 2024
- [x] **PR title**: Update docstrings for OpenAI base.py
-**Description:** Updated the docstring of few OpenAI functions for a
better understanding of the function.
    - **Issue:** #21983

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
hinthornw pushed a commit that referenced this issue Jun 20, 2024
…Embeddings (#22031)

- **Description:** add detailed paragraph and example for
BaichuanTextEmbeddings
   - **Issue:** the issue #21983
eyurtsev added a commit that referenced this issue Jul 11, 2024
- **Description:** Add SQLChatMessageHistory docstring.
- **Issue:** the issue #21983

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
ccurme added a commit that referenced this issue Jul 23, 2024
- **Description:** Add `RedisChatMessageHistory ` rich docstrings.
- **Issue:** the issue #21983

Co-authored-by: ccurme <chester.curme@gmail.com>
ccurme pushed a commit that referenced this issue Jul 24, 2024
- **Description:** Add MongoDBChatMessageHistory rich docstrings.
- **Issue:** the issue #21983
ccurme pushed a commit that referenced this issue Jul 25, 2024
- **Description:** Standardize BaichuanTextEmbeddings docstrings.
- **Issue:** the issue #21983
ccurme pushed a commit that referenced this issue Jul 29, 2024
- **Description:** Standardize QianfanEmbeddingsEndpoint, include:
  - docstrings, the issue #21983 
  - model init arg names, the issue #20085
@efriis efriis mentioned this issue Jul 30, 2024
2 tasks
@baskaryan baskaryan pinned this issue Jul 31, 2024
@baskaryan baskaryan removed the documentation Improvements or additions to documentation label Jul 31, 2024
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
- **Description:** Add `RedisChatMessageHistory ` rich docstrings.
- **Issue:** the issue langchain-ai#21983

Co-authored-by: ccurme <chester.curme@gmail.com>
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
- **Description:** Add MongoDBChatMessageHistory rich docstrings.
- **Issue:** the issue langchain-ai#21983
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
- **Description:** Standardize BaichuanTextEmbeddings docstrings.
- **Issue:** the issue langchain-ai#21983
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
- **Description:** Standardize QianfanEmbeddingsEndpoint, include:
  - docstrings, the issue langchain-ai#21983 
  - model init arg names, the issue langchain-ai#20085
ccurme added a commit that referenced this issue Oct 30, 2024
- **Description:** add/improve docstrings of OpenAIAssistantV2Runnable
- **Issue:** the issue #21983

Co-authored-by: Chester Curme <chester.curme@gmail.com>
Copy link

dosubot bot commented Oct 30, 2024

Hi, @baskaryan. I'm helping the LangChain team manage their backlog and am marking this issue as stale.

Your issue highlights the need for standardizing docstrings across all public modules, classes, methods, and attributes to align with the Google Python Style Guide. You mentioned specific formatting requirements for examples using RST code-block format, and @klaudialemiec has expressed their intention to begin addressing this.

Could you please let us know if this issue is still relevant to the latest version of the LangChain repository? If it is, feel free to comment here to keep it open. Otherwise, you can close it yourself, or it will be automatically closed in 7 days. Thank you!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Oct 30, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder good first issue Good for newcomers help wanted Good issue for contributors
Projects
None yet
Development

No branches or pull requests

3 participants