diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0def3aaf15..817eea6b0e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/composer/core/passes.py b/composer/core/passes.py index a8fb9f2743..bb9eb8a2a3 100644 --- a/composer/core/passes.py +++ b/composer/core/passes.py @@ -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 @@ -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 diff --git a/composer/trainer/trainer.py b/composer/trainer/trainer.py index 4447698beb..144a16acc3 100644 --- a/composer/trainer/trainer.py +++ b/composer/trainer/trainer.py @@ -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` for more information. - Example + Example: -------- - Train a model and save a checkpoint: .. testcode:: @@ -747,8 +746,7 @@ class Trainer: Ignored if ``load_path`` is ``None``. (default: ``None``) - Example: - + Example: .. testsetup:: import composer.trainer diff --git a/composer/utils/dist.py b/composer/utils/dist.py index 95a95835f4..58ecd33524 100644 --- a/composer/utils/dist.py +++ b/composer/utils/dist.py @@ -321,6 +321,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``). diff --git a/composer/utils/eval_client/eval_client.py b/composer/utils/eval_client/eval_client.py index 8701a2cbad..ad717d2ab6 100644 --- a/composer/utils/eval_client/eval_client.py +++ b/composer/utils/eval_client/eval_client.py @@ -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. diff --git a/composer/utils/import_helpers.py b/composer/utils/import_helpers.py index 8f084e2edb..a009af514c 100644 --- a/composer/utils/import_helpers.py +++ b/composer/utils/import_helpers.py @@ -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') diff --git a/composer/utils/module_surgery.py b/composer/utils/module_surgery.py index 48caa51f22..14958fc216 100644 --- a/composer/utils/module_surgery.py +++ b/composer/utils/module_surgery.py @@ -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 module_index (int): The i-th instance of module class. diff --git a/pyproject.toml b/pyproject.toml index 3b2469b935..3295d1425a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,8 +15,8 @@ split_on_trailing_comma = true [tool.ruff.lint] select = [ "C4", - # TODO port pydocstyle - # "D", # pydocstyle + "D400", + "D404", "LOG", "PERF", "PLE", @@ -27,7 +27,22 @@ ignore = [ "C408", "PERF2", "PERF4", + "D102", + "D105", + "D107", + "D401", ] + +[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"] +[tool.ruff.lint.pydocstyle] +convention = "google" + [tool.ruff] exclude = [ "build/**", @@ -1075,8 +1090,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"