Skip to content

Commit e6df25c

Browse files
authored
Reformat files with black. Remove exclusion from black rules. (#15687)
* Remove black extend-exclude option * Reformat files with black * Exclude Jupyter Notebooks * Adjust AGENTS.md to allow using isort and black directly Signed-off-by: Vladimir Bataev <vbataev@nvidia.com> --------- Signed-off-by: Vladimir Bataev <vbataev@nvidia.com>
1 parent 44cb1c7 commit e6df25c

124 files changed

Lines changed: 1071 additions & 522 deletions

File tree

Some content is hidden

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

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Requires Python 3.10+, PyTorch 2.6+.
2121
- **Line length: 119** (not default 88) — consistent across black, isort, flake8
2222
- Black with `skip_string_normalization = true`
2323
- isort with `profile = black`
24-
- Check: `python setup.py style --scope <path>`
25-
- Fix: `python setup.py style --scope <path> --fix`
26-
- **Incremental reformatting**: most collections are excluded from black (see `extend-exclude` in pyproject.toml). The files are reformatted when somebody makes changes to avoid a single big reformatting PR. Do not reformat files outside your changes.
24+
- Check: `isort --check <path> && black --check <path>` or `isort --check . && black --check .`
25+
- Fix: `isort <path> && black <path>` or `isort . && black .`
26+
- Jupyter Notebooks are excluded from automatic black reformatting (see `extend-exclude`), but can be still reformatted when passed directly. Do not reformat notebooks outside your changes.
2727

2828
## Testing
2929

examples/asr/asr_adapters/scoring_and_analysis.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ def display_results(df_all: pd.DataFrame, category: str, best_config: pd.Series,
202202

203203

204204
def get_best_config(
205-
df_exp: pd.DataFrame, dataset_type_col: str, key_info: dict, topk: int, show_analysis: bool, exp_type: str,
205+
df_exp: pd.DataFrame,
206+
dataset_type_col: str,
207+
key_info: dict,
208+
topk: int,
209+
show_analysis: bool,
210+
exp_type: str,
206211
):
207212
"""Get the best hyperparameter configuration for a given subset of experiments.
208213

examples/asr/export/transducer/infer_transducer_onnx.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060
def parse_arguments():
6161
parser = ArgumentParser()
6262
parser.add_argument(
63-
"--nemo_model", type=str, default=None, required=False, help="Path to .nemo file",
63+
"--nemo_model",
64+
type=str,
65+
default=None,
66+
required=False,
67+
help="Path to .nemo file",
6468
)
6569
parser.add_argument(
6670
'--pretrained_model', type=str, default=None, required=False, help='Name of a pretrained NeMo file'

examples/asr/export/transducer/infer_transducer_ts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@
6363
def parse_arguments():
6464
parser = ArgumentParser()
6565
parser.add_argument(
66-
"--nemo_model", type=str, default=None, required=False, help="Path to .nemo file",
66+
"--nemo_model",
67+
type=str,
68+
default=None,
69+
required=False,
70+
help="Path to .nemo file",
6771
)
6872
parser.add_argument(
6973
'--pretrained_model', type=str, default=None, required=False, help='Name of a pretrained NeMo file'

examples/asr/speech_classification/vad_infer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ def main(cfg):
9191
'vad_stream': True,
9292
'sample_rate': 16000,
9393
'manifest_filepath': manifest_vad_input,
94-
'labels': ['infer',],
94+
'labels': [
95+
'infer',
96+
],
9597
'num_workers': cfg.num_workers,
9698
'shuffle': False,
9799
'window_length_in_sec': cfg.vad.parameters.window_length_in_sec,

examples/tts/aligner_heteronym_disambiguation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444

4545

4646
def get_args():
47-
"""Retrieve arguments for disambiguation.
48-
"""
47+
"""Retrieve arguments for disambiguation."""
4948
parser = argparse.ArgumentParser("G2P disambiguation using Aligner input embedding distances.")
5049
# TODO(jocelynh): Make this required=False with default download from NGC once ckpt uploaded
5150
parser.add_argument('--model', required=True, type=str, help="Path to Aligner model checkpoint (.nemo file).")
@@ -85,8 +84,7 @@ def get_args():
8584

8685

8786
def load_and_prepare_audio(aligner, audio_path, target_sr, device):
88-
"""Loads and resamples audio to target sample rate (if necessary), and preprocesses for Aligner input.
89-
"""
87+
"""Loads and resamples audio to target sample rate (if necessary), and preprocesses for Aligner input."""
9088
# Load audio and get length for preprocessing
9189
audio_data, orig_sr = sf.read(audio_path)
9290
if orig_sr != target_sr:
@@ -238,8 +236,7 @@ def disambiguate_candidates(aligner, text, spec, spec_len, confidence, device, h
238236
def disambiguate_dataset(
239237
aligner, manifest_path, out_path, sr, heteronyms, confidence, device, verbose, heteronyms_only=True
240238
):
241-
"""Disambiguates the phonemes for all words with ambiguous pronunciations in the given manifest.
242-
"""
239+
"""Disambiguates the phonemes for all words with ambiguous pronunciations in the given manifest."""
243240
log_file = open('disambiguation_logs.txt', 'w') if verbose else None
244241

245242
with open(out_path, 'w') as f_out:

external/get_collections.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626

2727
def process_collection(id, col):
28-
""" Helper function processing the collection.
29-
28+
"""Helper function processing the collection.
29+
3030
Args:
3131
id: (short) name of the collection.
3232
col: a collection (python module).
@@ -41,7 +41,7 @@ def process_collection(id, col):
4141

4242

4343
def main():
44-
""" Main function generating a JSON file with list of NeMo collections. """
44+
"""Main function generating a JSON file with list of NeMo collections."""
4545
# Parse filename.
4646
parser = argparse.ArgumentParser()
4747
parser.add_argument('--filename', help='Name of the output JSON file', type=str, default="collections.json")

external/get_modules.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727

2828
def process_member(name, obj, module_list):
29-
""" Helper function processing the passed object and, if ok, adding a record to the module list.
30-
29+
"""Helper function processing the passed object and, if ok, adding a record to the module list.
30+
3131
Args:
3232
name: name of the member
3333
obj: member (class/function etc.)
@@ -74,7 +74,7 @@ def process_member(name, obj, module_list):
7474

7575

7676
def main():
77-
""" Main function analysing the indicated NeMo collection and generating a JSON file with module descriptions. """
77+
"""Main function analysing the indicated NeMo collection and generating a JSON file with module descriptions."""
7878
# Parse filename.
7979
parser = argparse.ArgumentParser()
8080
parser.add_argument('--collection', help='ID of the collection', type=str)

nemo/collections/asr/data/audio_to_ctm_dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
@dataclass
2626
class FrameCtmUnit:
27-
"""A container class for one CTM unit with start and length countable in frames.
28-
"""
27+
"""A container class for one CTM unit with start and length countable in frames."""
2928

3029
label: str
3130
start_frame: int

nemo/collections/asr/data/audio_to_label_dataset.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ def get_tarred_classification_label_dataset(
131131

132132

133133
def get_concat_tarred_speech_label_dataset(
134-
featurizer, config: dict, shuffle_n: int, global_rank: int, world_size: int,
134+
featurizer,
135+
config: dict,
136+
shuffle_n: int,
137+
global_rank: int,
138+
world_size: int,
135139
):
136140
tarred_audio_filepaths = config['tarred_audio_filepaths']
137141
manifest_filepaths = config['manifest_filepath']
@@ -143,7 +147,11 @@ def get_concat_tarred_speech_label_dataset(
143147
conf['manifest_filepath'] = manifest_filepath
144148
conf['tarred_audio_filepaths'] = tarred_audio_filepath
145149
dataset = get_tarred_speech_label_dataset(
146-
config=conf, featurizer=featurizer, shuffle_n=shuffle_n, global_rank=global_rank, world_size=world_size,
150+
config=conf,
151+
featurizer=featurizer,
152+
shuffle_n=shuffle_n,
153+
global_rank=global_rank,
154+
world_size=world_size,
147155
)
148156
datasets.append(dataset)
149157

@@ -160,7 +168,11 @@ def get_concat_tarred_speech_label_dataset(
160168

161169

162170
def get_tarred_speech_label_dataset(
163-
featurizer, config: dict, shuffle_n: int, global_rank: int, world_size: int,
171+
featurizer,
172+
config: dict,
173+
shuffle_n: int,
174+
global_rank: int,
175+
world_size: int,
164176
) -> audio_to_label.TarredAudioToSpeechLabelDataset:
165177
"""
166178
InInstantiates a Speech Label (e.g. VAD, speaker recognition) TarredAudioLabelDataset.

0 commit comments

Comments
 (0)