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

Remove pydocstyle and configure ruff check for D rules #3384

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ repos:
# types: [python]
# require_serial: true
# rev: v2.12.2
- repo: https://github.com/PyCQA/pydocstyle
hooks:
- id: pydocstyle
name: pydocstyle
entry: pydocstyle
language: python
types: [python]
exclude: "(?:tests|.ci|composer\/algorithms|composer\/datasets|composer\/models)\/.*|composer\/trainer\/activation_checkpointing.py"
additional_dependencies:
- "toml"
rev: 6.1.1
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
Expand Down
2 changes: 0 additions & 2 deletions composer/core/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def sort_to_front(list_to_sort: Sequence[T], cls: Any) -> Sequence[T]:
"""Helper function to sort instances of a provided class to the front.

Example:

.. testsetup::

from composer.core.passes import sort_to_front
Expand All @@ -58,7 +57,6 @@ def sort_to_back(list_to_sort: Sequence[T], cls: Any) -> Sequence[T]:
"""Helper function to sort instances of a provided class to the back.

Example:

.. testsetup::

from composer.core.passes import sort_to_back
Expand Down
6 changes: 2 additions & 4 deletions composer/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,8 @@ class Trainer:
The :class:`.Trainer` is highly customizable and can support a wide variety of workloads.
See the :doc:`training guide</trainer/using_the_trainer>` for more information.

Example
Example:
--------

Train a model and save a checkpoint:

.. testcode::
Expand Down Expand Up @@ -747,8 +746,7 @@ class Trainer:
Ignored if ``load_path`` is ``None``.
(default: ``None``)

Example:

Example:
.. testsetup::

import composer.trainer
Expand Down
1 change: 1 addition & 0 deletions composer/utils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def all_reduce(
enum. Specifies an operation used for element-wise reductions.
group (ProcessGroup, optional): The process group to work on. If ``None``,
the default process group will be used. Default is ``None``.

Args:
tensor (torch.Tensor): Tensor to reduce. The function operates in-place.
reduce_operation (str, optional): The reduction operation (default: ``SUM``).
Expand Down
1 change: 1 addition & 0 deletions composer/utils/eval_client/eval_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def invoke(self, payload: list[list[list[dict[str, str]]]]) -> list[list[list[bo

The JSON is formatted as [[[request]]] so that the client can batch requests. The outermost list is for the generations of a
given prompt, the middle list is for the beam generations of a given prompt, and the innermost list is for each test cases.

Args:
payload: the materials of the batched HTTPS request to the client organized by prompt, beam generation, and test case.

Expand Down
3 changes: 1 addition & 2 deletions composer/utils/import_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def import_object(name: str) -> Any:

Separate the module name and class name with a ``':'`` (e.g. ``'path.to.module:function_name'``).

Example:

Example:
>>> from composer.utils import import_object
>>> import_object('functools:partial')
<class 'functools.partial'>
Expand Down
2 changes: 1 addition & 1 deletion composer/utils/module_surgery.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
instances of the module type have been seen. The function should return a replacement
:class:`torch.nn.Module` if the module type should be replaced, or ``None`` otherwise.

Args:
Args:
module (torch.nn.Module): Source module
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird indenting here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it weird?

Copy link
Contributor

Choose a reason for hiding this comment

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

module is double indented after Args

module_index (int): The i-th instance of module class.

Expand Down
35 changes: 28 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ split_on_trailing_comma = true
[tool.ruff.lint]
select = [
"C4",
# TODO port pydocstyle
# "D", # pydocstyle
"D",
eracah marked this conversation as resolved.
Show resolved Hide resolved
"LOG",
"PERF",
"PLE",
Expand All @@ -27,7 +26,34 @@ ignore = [
"C408",
"PERF2",
"PERF4",
"D102",
"D105",
"D107",
"D401",
"D203",
"D204",
"D213",
"D215",
"D401",
"D406",
"D407",
"D408",
"D409",
"D413",
"D417",
"D103"
eracah marked this conversation as resolved.
Show resolved Hide resolved
]

[tool.ruff.lint.per-file-ignores]
".ci*" = ["D"]
"tests/*" = ["D"]
"composer/algorithms/*" = ["D"]
"composer/datasets/*" = ["D"]
"composer/models/*" = ["D"]
"composer/trainer/activation_checkpointing.py" = ["D"]
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also just add a specific noqa comment at the top of the file to disable it directly in the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why ignore algorithms/datasets/models?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just used the same ignoring that pydocstyle used. See the lines removed from the the pre-commit yaml

[tool.ruff.lint.pydocstyle]
convention = "google"

eracah marked this conversation as resolved.
Show resolved Hide resolved
[tool.ruff]
exclude = [
"build/**",
Expand Down Expand Up @@ -1075,8 +1101,3 @@ min-public-methods=2
# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions="BaseException,Exception"

[tool.pydocstyle]
convention="google"
add_ignore="D102,D105,D107,D401"
add_select="D400,D404"
Loading