Skip to content

Commit 6ca24dd

Browse files
committed
Add ruff.toml, pre-commit
Signed-off-by: Hemil Desai <[email protected]>
1 parent 5cfcd7c commit 6ca24dd

File tree

105 files changed

+3676
-4052
lines changed

Some content is hidden

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

105 files changed

+3676
-4052
lines changed

.github/workflows/ruff-format.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/ruff-lint.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Ruff lint
1+
name: Ruff lint and format
22

33
on:
44
workflow_dispatch:
@@ -8,16 +8,17 @@ on:
88
pull_request:
99

1010
jobs:
11-
lint:
11+
lint-check:
12+
name: Lint check
1213
runs-on: ubuntu-latest
13-
1414
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Install the latest version of uv
18-
uses: astral-sh/setup-uv@v3
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
1917
with:
20-
version: "latest"
18+
submodules: 'recursive'
2119

22-
- name: Ruff lint
23-
run: uv run --group lint -- ruff check
20+
- name: Check lint
21+
run: |
22+
pip install pre-commit==3.6.0
23+
pre-commit install
24+
pre-commit run --all-files --show-diff-on-failure --color=always

.pre-commit-config.yaml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
11
repos:
2-
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
# Ruff version.
4-
rev: v0.6.1
5-
hooks:
6-
# Run the linter.
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
# only include python files
7+
files: \.py$
8+
- id: trailing-whitespace
9+
# only include python files
10+
files: \.py$
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: "v0.9.9" # Use the appropriate version
14+
hooks:
715
- id: ruff
8-
args: [ --fix ]
9-
# Run the formatter.
16+
args: ["--fix"]
17+
- id: ruff
18+
args: ["check", "--select", "I", "--fix"]
1019
- id: ruff-format
20+
21+
- repo: local
22+
hooks:
23+
- id: no-underscore-md
24+
name: "Disallow '_' in Markdown filenames"
25+
language: system
26+
entry: |
27+
bash -c '
28+
# Report the offending files
29+
echo "[pre-commit] ERROR: Found Markdown files with underscores:" >&2
30+
for file in "$@"; do
31+
echo " - $file (use hyphens instead)" >&2
32+
done
33+
exit 1
34+
'
35+
files: '.*\/[^\/]*_[^\/]*\.md$'
36+
exclude: '^\.github/'
37+
types: [file]

examples/docker/hello_docker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import nemo_run as run
22

3+
34
if __name__ == "__main__":
45
inline_script = run.Script(
56
inline="""

examples/entrypoint/experiment.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ def train_models_experiment(
9494

9595
with run.Experiment("train_models_experiment") as exp:
9696
for i, (model, optimizer) in enumerate(zip(models, optimizers)):
97-
train = run.Partial(
98-
train_model, model=model, optimizer=optimizer, epochs=epochs, batch_size=batch_size
99-
)
97+
train = run.Partial(train_model, model=model, optimizer=optimizer, epochs=epochs, batch_size=batch_size)
10098

10199
exp.add(train, name=f"train_model_{i}", executor=ctx.executor)
102100

examples/entrypoint/task.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def my_optimizer(
3636
learning_rate: float = 0.001, weight_decay: float = 1e-5, betas: List[float] = [0.9, 0.999]
3737
) -> run.Config[Optimizer]:
3838
"""Create an optimizer configuration."""
39-
return run.Config(
40-
Optimizer, learning_rate=learning_rate, weight_decay=weight_decay, betas=betas
41-
)
39+
return run.Config(Optimizer, learning_rate=learning_rate, weight_decay=weight_decay, betas=betas)
4240

4341

4442
def train_model(

examples/entrypoint/task_with_defaults.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def my_optimizer(
3636
learning_rate: float = 0.001, weight_decay: float = 1e-5, betas: List[float] = [0.9, 0.999]
3737
) -> run.Config[Optimizer]:
3838
"""Create an optimizer configuration."""
39-
return run.Config(
40-
Optimizer, learning_rate=learning_rate, weight_decay=weight_decay, betas=betas
41-
)
39+
return run.Config(Optimizer, learning_rate=learning_rate, weight_decay=weight_decay, betas=betas)
4240

4341

4442
def train_model(

examples/hello-world/hello_scripts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import nemo_run as run
1919

20+
2021
# This script defines an experiment that invokes three tasks in parallel, two scripts and a run.Partial.
2122
# The example demonstrates how you can use scripts and run.Partial.
2223
if __name__ == "__main__":

nemo_run/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from nemo_run.run.experiment import Experiment
3939
from nemo_run.run.plugin import ExperimentPlugin as Plugin
4040

41+
4142
__all__ = [
4243
"autoconvert",
4344
"cli",

nemo_run/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
import os
1616
import warnings
1717

18+
1819
if "NEMORUN_SHOW_WARNINGS" not in os.environ:
1920
warnings.simplefilter(action="ignore", category=DeprecationWarning)
2021
warnings.simplefilter(action="ignore", category=FutureWarning)
2122

2223
from nemo_run.cli.api import create_cli # noqa: E402
2324

25+
2426
app = create_cli()

0 commit comments

Comments
 (0)