Skip to content

Commit 01b8532

Browse files
authored
chore: switch from mypy to pyrefly (#675)
Signed-off-by: Terry Kong <terryk@nvidia.com>
1 parent 2b8b364 commit 01b8532

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+388
-234
lines changed

.github/workflows/cicd-main.yml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -139,31 +139,18 @@ jobs:
139139
uv venv
140140
uv run --group dev pre-commit install
141141
uv run --group dev pre-commit run --all-files --show-diff-on-failure --color=always
142-
- name: Minimize uv cache
143-
run: uv cache prune --ci
144-
145-
mypy-check:
146-
name: Mypy check
147-
needs: [pre-flight]
148-
runs-on: ubuntu-latest
149-
steps:
150-
- name: Checkout repository
151-
uses: actions/checkout@v4
152-
- name: Install uv
153-
uses: astral-sh/setup-uv@v5
154-
with:
155-
version: "0.7.2"
156-
enable-cache: true
157-
prune-cache: false
158-
# Faster than uv python install since it caches python alongside runner
159-
- name: "Set up Python"
160-
uses: actions/setup-python@v5
161-
with:
162-
python-version-file: ".python-version"
163-
- name: Check mypy
142+
# TODO: this is a temporary check and should be removed once we have 100% correctness
143+
- name: Check if any files with zero errors not in whitelist
164144
run: |
165-
uv venv
166-
uv run --group test mypy nemo_rl examples
145+
missing_count=0
146+
for file in $(uv run --group dev pyrefly check $(git ls-files 'nemo_rl/**/*.py' 'examples/**/*.py' 'docs/*.py' 'tools/**/*.py') --output-format json | jq -r --slurpfile all_files <(git ls-files 'nemo_rl/**/*.py' 'examples/**/*.py' 'docs/*.py' 'tools/**/*.py' | jq -R -s 'split("\n")[:-1]') --arg pwd "$(pwd)/" '(.errors | group_by(.path) | map({(.[0].path | sub($pwd; "")): length}) | add // {}) as $error_counts | $all_files[0][] | . as $file | if ($error_counts[$file] // 0) == 0 then $file else empty end'); do
147+
if ! fgrep -q "$file" pyrefly.toml; then
148+
echo "File $file has zero errors but is not in pyrefly.toml in the 'project-includes' list. Please add it to this whitelist."
149+
((missing_count++))
150+
fi
151+
done
152+
153+
exit $missing_count
167154
- name: Minimize uv cache
168155
run: uv cache prune --ci
169156

@@ -319,8 +306,7 @@ jobs:
319306
(
320307
needs.pre-flight.outputs.test_level != 'none' &&
321308
needs.sphinx-build.result == 'success' &&
322-
needs.tests.result == 'success' &&
323-
(needs.mypy-check.result == 'success' || true)
309+
needs.tests.result == 'success'
324310
)
325311
)
326312
}}

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ repos:
3535
files: '.*\/[^\/]*_[^\/]*\.md$'
3636
exclude: '^\.github/'
3737
types: [file]
38+
39+
- repo: https://github.com/facebook/pyrefly
40+
rev: 0.24.2
41+
hooks:
42+
- id: pyrefly-typecheck
43+
files: \.py$

examples/configs/dpo.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ logger:
156156
tensorboard_enabled: false
157157
mlflow_enabled: false # Disable MLflow logging
158158
monitor_gpus: true # If true, will monitor GPU usage and log to wandb and/or tensorboard
159+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
159160
wandb:
160161
project: "dpo-dev"
161162
name: "dpo"

examples/configs/recipes/llm/dpo-llama3.1-8b-instruct-4n8g-fsdp2tp1.v2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ logger:
8080
tensorboard_enabled: true
8181
mlflow_enabled: false
8282
monitor_gpus: true
83+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
8384
wandb:
8485
project: nemo-rl
8586
name: dpo-llama3.1-8b-instruct-4n8g-fsdp2tp1

examples/configs/recipes/llm/dpo-llama3.1-8b-instruct-4n8g-fsdp2tp2-quick.v2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ logger:
8080
tensorboard_enabled: true
8181
mlflow_enabled: false
8282
monitor_gpus: true
83+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
8384
wandb:
8485
project: nemo-rl
8586
name: dpo-llama3.1-8b-instruct-4n8g-fsdp2tp1

examples/configs/recipes/llm/dpo-llama3.1-8b-instruct-4n8g-megatron.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ logger:
113113
tensorboard_enabled: true
114114
mlflow_enabled: false
115115
monitor_gpus: true
116+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
116117
wandb:
117118
project: nemo-rl
118119
name: dpo-llama3.1-8b-instruct-4n8g-fsdp2tp1

examples/configs/recipes/llm/dpo-llama3.1-8b-instruct-4n8g-megatrontp2pp2-quick.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ logger:
113113
tensorboard_enabled: true
114114
mlflow_enabled: false
115115
monitor_gpus: true
116+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
116117
wandb:
117118
project: nemo-rl
118119
name: dpo-llama3.1-8b-instruct-4n8g-fsdp2tp1

examples/configs/recipes/llm/dpo-llama3.2-1b-instruct-1n8g-fsdp2tp1.v2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ logger:
8080
tensorboard_enabled: true
8181
mlflow_enabled: false
8282
monitor_gpus: true
83+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
8384
wandb:
8485
project: nemo-rl
8586
name: dpo-llama3.2-1b-instruct-1n8g-fsdp2tp1

examples/configs/recipes/llm/sft-llama3.1-8b-instruct-1n8g-fsdp2tp1-long.v2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ logger:
6060
tensorboard_enabled: true
6161
mlflow_enabled: false
6262
monitor_gpus: true
63+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
6364
wandb:
6465
project: nemo-rl
6566
name: sft-llama3.1-8b-instruct-1n8g-fsdp2tp1-long

examples/configs/recipes/llm/sft-llama3.1-8b-instruct-1n8g-fsdp2tp2sp.v2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ logger:
6060
tensorboard_enabled: true
6161
mlflow_enabled: false
6262
monitor_gpus: true
63+
num_val_samples_to_print: 0 # Number of validation samples to pretty print on terminal
6364
wandb:
6465
project: nemo-rl
6566
name: sft-llama3.1-8b-instruct-1n8g-fsdp2tp2sp

0 commit comments

Comments
 (0)