From db1cb9b3d15f1e0c7ad87f99731c67315d0692ae Mon Sep 17 00:00:00 2001 From: root Date: Mon, 28 Jul 2025 22:33:45 +0000 Subject: [PATCH 1/4] try this out --- .pre-commit-config.yaml | 58 ++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a67d723a..129e8ee4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,30 +12,42 @@ repos: hooks: - id: yapf name: yapf - description: A formatter for Python files. + description: "A formatter for Python files." entry: yapf - args: [-i, -vv, -p] # inplace + args: [-i, -vv, -p] # inplace language: python types: [python] additional_dependencies: - - toml -- repo: https://github.com/hadialqattan/pycln - rev: v2.5.0 - hooks: - - id: pycln - args: [. --all] + - "toml" - repo: https://github.com/pycqa/isort hooks: - id: isort rev: 5.12.0 +- repo: https://github.com/PyCQA/pydocstyle + hooks: + - id: pydocstyle + name: pydocstyle + entry: pydocstyle + language: python + types: [python] + additional_dependencies: + - "toml" + rev: 6.1.1 +- repo: https://github.com/adrienverge/yamllint.git + rev: v1.28.0 + hooks: + - id: yamllint + name: yamllint + description: This hook runs yamllint. + entry: yamllint + language: python + types: [file, yaml] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: check-added-large-files - id: check-ast - id: check-builtin-literals - args: - - --no-allow-dict-kwargs - id: check-case-conflict - id: check-docstring-first - id: check-executables-have-shebangs @@ -54,7 +66,6 @@ repos: - id: check-yaml - id: debug-statements - id: destroyed-symlinks - - id: double-quote-string-fixer - id: end-of-file-fixer - id: fix-byte-order-marker - id: mixed-line-ending @@ -70,31 +81,6 @@ repos: - "#" - --allow-past-years types: [python] -- repo: https://github.com/PyCQA/docformatter - rev: v1.5.0 - hooks: - - id: docformatter - args: [--in-place, --wrap-summaries=80, --wrap-descriptions=80] -- repo: https://github.com/PyCQA/pydocstyle - hooks: - - id: pydocstyle - name: pydocstyle - entry: pydocstyle - language: python - types: [python] - exclude: (.ci|.github) - additional_dependencies: - - toml - rev: 6.1.1 -- repo: https://github.com/adrienverge/yamllint.git - rev: v1.28.0 - hooks: - - id: yamllint - name: yamllint - description: This hook runs yamllint. - entry: yamllint - language: python - types: [file, yaml] - repo: local hooks: - id: pyright From 726a50607c2a39551ae759a147c7a6787d03c7b1 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 29 Jul 2025 00:22:54 +0000 Subject: [PATCH 2/4] maybe this will work --- .pre-commit-config.yaml | 58 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 129e8ee4..cb4f191b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,42 +12,30 @@ repos: hooks: - id: yapf name: yapf - description: "A formatter for Python files." + description: A formatter for Python files. entry: yapf - args: [-i, -vv, -p] # inplace + args: [-i, -vv, -p] # inplace language: python types: [python] additional_dependencies: - - "toml" + - toml +- repo: https://github.com/hadialqattan/pycln + rev: v2.5.0 + hooks: + - id: pycln + args: [. --all] - repo: https://github.com/pycqa/isort hooks: - id: isort rev: 5.12.0 -- repo: https://github.com/PyCQA/pydocstyle - hooks: - - id: pydocstyle - name: pydocstyle - entry: pydocstyle - language: python - types: [python] - additional_dependencies: - - "toml" - rev: 6.1.1 -- repo: https://github.com/adrienverge/yamllint.git - rev: v1.28.0 - hooks: - - id: yamllint - name: yamllint - description: This hook runs yamllint. - entry: yamllint - language: python - types: [file, yaml] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: check-added-large-files - id: check-ast - id: check-builtin-literals + args: + - --no-allow-dict-kwargs - id: check-case-conflict - id: check-docstring-first - id: check-executables-have-shebangs @@ -66,6 +54,7 @@ repos: - id: check-yaml - id: debug-statements - id: destroyed-symlinks + - id: double-quote-string-fixer - id: end-of-file-fixer - id: fix-byte-order-marker - id: mixed-line-ending @@ -81,6 +70,31 @@ repos: - "#" - --allow-past-years types: [python] +- repo: https://github.com/PyCQA/docformatter + rev: v1.7.7 + hooks: + - id: docformatter + args: [--in-place, --wrap-summaries=80, --wrap-descriptions=80] +- repo: https://github.com/PyCQA/pydocstyle + hooks: + - id: pydocstyle + name: pydocstyle + entry: pydocstyle + language: python + types: [python] + exclude: (.ci|.github) + additional_dependencies: + - toml + rev: 6.1.1 +- repo: https://github.com/adrienverge/yamllint.git + rev: v1.28.0 + hooks: + - id: yamllint + name: yamllint + description: This hook runs yamllint. + entry: yamllint + language: python + types: [file, yaml] - repo: local hooks: - id: pyright From 5da680d601d944d532597f0e4fe88dd1247c815c Mon Sep 17 00:00:00 2001 From: root Date: Tue, 29 Jul 2025 23:06:57 +0000 Subject: [PATCH 3/4] removed nested quotes --- compose_rl/algorithms/online/model_methods.py | 6 +++++- compose_rl/algorithms/reward_modeling/model.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/compose_rl/algorithms/online/model_methods.py b/compose_rl/algorithms/online/model_methods.py index acd00f4e..04a8970f 100644 --- a/compose_rl/algorithms/online/model_methods.py +++ b/compose_rl/algorithms/online/model_methods.py @@ -247,7 +247,11 @@ def policy_loss( logits=gen_logits, ) assert token_entropies.shape == batch['action_mask'].shape, ( - f'Token entropies shape {token_entropies.shape} does not match action mask shape {batch["action_mask"].shape}.', + 'Token entropies shape {token_entropies_shape} does not match action mask shape {action_mask_shape}.' + .format( + token_entropies_shape=token_entropies.shape, + action_mask_shape=batch['action_mask'].shape, + ), ) seq_entropies = utils.get_sequence_entropies( token_entropies=token_entropies, diff --git a/compose_rl/algorithms/reward_modeling/model.py b/compose_rl/algorithms/reward_modeling/model.py index 2d3637ee..8387889b 100644 --- a/compose_rl/algorithms/reward_modeling/model.py +++ b/compose_rl/algorithms/reward_modeling/model.py @@ -1,6 +1,5 @@ # Copyright 2024 MosaicML ComposeRL authors # SPDX-License-Identifier: Apache-2.0 - """Reward Model Composer Implementation.""" import logging @@ -329,7 +328,7 @@ def forward( batch['input_ids'], attention_mask=batch['attention_mask'], ).logits - logits = logits[:, :, self.eos_token_id] + logits = logits[:, :, self.eos_token_id] # type: ignore if self.min_threshold is not None and self.max_threshold is not None: logits: torch.Tensor = torch.clamp( logits, From 1b18a46d6da9acb854b9cd9066fcb7cddbd0a764 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 29 Jul 2025 23:10:06 +0000 Subject: [PATCH 4/4] removed docformatter --- .pre-commit-config.yaml | 5 ----- compose_rl/algorithms/reward_modeling/model.py | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb4f191b..0d78ce85 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,11 +70,6 @@ repos: - "#" - --allow-past-years types: [python] -- repo: https://github.com/PyCQA/docformatter - rev: v1.7.7 - hooks: - - id: docformatter - args: [--in-place, --wrap-summaries=80, --wrap-descriptions=80] - repo: https://github.com/PyCQA/pydocstyle hooks: - id: pydocstyle diff --git a/compose_rl/algorithms/reward_modeling/model.py b/compose_rl/algorithms/reward_modeling/model.py index 8387889b..cb6dc449 100644 --- a/compose_rl/algorithms/reward_modeling/model.py +++ b/compose_rl/algorithms/reward_modeling/model.py @@ -1,5 +1,6 @@ # Copyright 2024 MosaicML ComposeRL authors # SPDX-License-Identifier: Apache-2.0 + """Reward Model Composer Implementation.""" import logging