fix(audio): lazy-load audio stages and fix tutorial notebook paths#1835
fix(audio): lazy-load audio stages and fix tutorial notebook paths#1835mohammadaaftabv wants to merge 7 commits intoNVIDIA-NeMo:mainfrom
Conversation
…and standardized sections - Add decision table, data availability, and system deps tables to top-level audio README - Create shared README_TEMPLATE.md for consistent tutorial documentation - Standardize fleurs/README.md: add pipeline flow diagram, full output schema, composability section, WER threshold justification, and troubleshooting table Signed-off-by: aaftaabv@gmail.com <aaftaabv@gmail.com>
…hooting Signed-off-by: aaftaabv@gmail.com <aaftaabv@gmail.com>
Signed-off-by: aaftaabv@gmail.com <aaftaabv@gmail.com>
Signed-off-by: aaftaabv@gmail.com <aaftaabv@gmail.com>
- Empty nemo_curator/stages/audio/__init__.py to prevent eager imports of optional deps (onnxruntime) at package load time, matching the image modality pattern. - Update readspeech/pipeline.py to import from specific subpackage. - Fix ALM notebook: use relative paths and correct ALMManifestReader API. - Fix FLEURS notebook: use relative paths for data directory. Signed-off-by: aaftaabv@gmail.com <aaftaabv@gmail.com>
Greptile SummaryThis PR fixes two root causes of tutorial breakage: eager imports in
Confidence Score: 4/5Safe to merge after fixing the stale composability example in the ALM README. All runtime fixes (lazy loading, import paths, notebook relative paths) are correct and verified by the embedded execution output. One P1 documentation bug remains: the composability block in README.md uses the wrong class and a non-existent constructor parameter, which will copy-paste directly to a TypeError for users. tutorials/audio/alm/README.md (lines 561–573 composability example) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["User imports audio stage\n(e.g. ALMManifestReader)"] --> B{Before PR}
B --> C["nemo_curator.stages.audio.__init__\neager-loads ALL 13 stages"]
C --> D["Transitive import of onnxruntime\nSIGMOS, UTMOS, etc."]
D --> E["ModuleNotFoundError\n(optional deps not installed)"]
A --> F{After PR}
F --> G["nemo_curator.stages.audio.__init__\n(empty — license header only)"]
G --> H["User imports directly from submodule\ne.g. stages.audio.alm.alm_manifest_reader"]
H --> I["Only that submodule's deps\nare loaded on demand"]
I --> J["✅ No spurious import errors"]
Reviews (4): Last reviewed commit: "fix(tutorials): use absolute paths in FL..." | Re-trigger Greptile |
…ovements Signed-off-by: aaftaabv@gmail.com <aaftaabv@gmail.com>
|
/ok to test dd0986b |
| from nemo_curator.pipeline import Pipeline | ||
| from nemo_curator.stages.audio.alm.alm_manifest_reader import ALMManifestReaderStage | ||
| from nemo_curator.stages.audio.alm.alm_data_builder import ALMDataBuilderStage | ||
| from nemo_curator.stages.audio.alm.alm_data_overlap import ALMDataOverlapStage | ||
|
|
||
| pipeline = Pipeline( | ||
| name="custom-alm", | ||
| stages=[ | ||
| ALMManifestReaderStage(manifest_paths=["data.jsonl"]), | ||
| ALMDataBuilderStage(target_window_duration=120.0), | ||
| ALMDataOverlapStage(overlap_percentage=50), | ||
| # Add downstream stages: sharding, feature extraction, etc. | ||
| ], | ||
| ) | ||
| ``` |
There was a problem hiding this comment.
Composability example uses wrong class and non-existent parameter
ALMManifestReaderStage is the low-level inner stage that receives a FileGroupTask via its process() method — it has no constructor argument at all. Passing manifest_paths=["data.jsonl"] will cause a TypeError at instantiation, and even if it didn't, the pipeline would stall waiting for a FileGroupTask that never arrives. The user-facing composite stage (corrected in the notebook in this very PR) is ALMManifestReader, which accepts manifest_path (singular, str | list[str]).
- FLEURS: use os.path.abspath() for RAW_DATA_DIR so Ray workers resolve the same path as the notebook kernel. - ALM: add RAY_MAX_LIMIT_FROM_API_SERVER env var to avoid Xenna monitoring hitting the Ray API server limit. Signed-off-by: aaftaabv@gmail.com <aaftaabv@gmail.com>
eb870af to
0fecc0c
Compare
| from nemo_curator.stages.audio.alm.alm_manifest_reader import ALMManifestReaderStage | ||
| from nemo_curator.stages.audio.alm.alm_data_builder import ALMDataBuilderStage | ||
| from nemo_curator.stages.audio.alm.alm_data_overlap import ALMDataOverlapStage | ||
|
|
||
| pipeline = Pipeline( | ||
| name="custom-alm", | ||
| stages=[ | ||
| ALMManifestReaderStage(manifest_paths=["data.jsonl"]), | ||
| ALMDataBuilderStage(target_window_duration=120.0), |
There was a problem hiding this comment.
Composability example still uses wrong class and parameter
The composability snippet on line 568 instantiates ALMManifestReaderStage(manifest_paths=["data.jsonl"]). ALMManifestReaderStage is the low-level inner stage that expects a FileGroupTask via process() — it accepts no constructor arguments. The notebook was corrected in this PR to use ALMManifestReader(manifest_path=MANIFEST_PATH) (the composite, user-facing stage), but this documentation block was not updated.
| from nemo_curator.stages.audio.alm.alm_manifest_reader import ALMManifestReaderStage | |
| from nemo_curator.stages.audio.alm.alm_data_builder import ALMDataBuilderStage | |
| from nemo_curator.stages.audio.alm.alm_data_overlap import ALMDataOverlapStage | |
| pipeline = Pipeline( | |
| name="custom-alm", | |
| stages=[ | |
| ALMManifestReaderStage(manifest_paths=["data.jsonl"]), | |
| ALMDataBuilderStage(target_window_duration=120.0), | |
| from nemo_curator.pipeline import Pipeline | |
| from nemo_curator.stages.audio.alm.alm_manifest_reader import ALMManifestReader | |
| from nemo_curator.stages.audio.alm.alm_data_builder import ALMDataBuilderStage | |
| from nemo_curator.stages.audio.alm.alm_data_overlap import ALMDataOverlapStage | |
| pipeline = Pipeline( | |
| name="custom-alm", | |
| stages=[ | |
| ALMManifestReader(manifest_path="data.jsonl"), | |
| ALMDataBuilderStage(target_window_duration=120.0), | |
| ALMDataOverlapStage(overlap_percentage=50), | |
| # Add downstream stages: sharding, feature extraction, etc. | |
| ], | |
| ) |
| } | ||
| ], | ||
| "source": [ | ||
| "os.environ[\"RAY_MAX_LIMIT_FROM_API_SERVER\"] = \"100000\"\n", |
There was a problem hiding this comment.
You might be getting the error since you are setting RAY_MAX_LIMIT_FROM_API_SERVER after Curator and Ray have been imported. Maybe setting it in the very first cell of the notebook, before any other imports, might help?
I also noticed there isn't a RayClient in this notebook?
Summary
Empty
nemo_curator/stages/audio/__init__.py— removes eager imports of all 13 audio stages at package load time. Previously, importing any audio stage transitively pulled in every optional dependency (e.g.onnxruntimeforSIGMOSFilterStage), causingModuleNotFoundErrorin tutorials that only need a subset. This now follows the same pattern used by theimagemodality.Fix
tutorials/audio/readspeech/pipeline.py— the only internal consumer of the old top-level import. Updated to importAudioDataFilterStagefrom its specific subpackage (nemo_curator.stages.audio.advanced_pipelines).Fix ALM tutorial notebook — use relative paths (
../../../tests/fixtures/...) instead of relying onsubprocess/git rev-parsefor repo root discovery. Also corrects the API to useALMManifestReader(composite stage) instead ofALMManifestReaderStage.Fix FLEURS tutorial notebook — use simple relative path (
./example_audio/fleurs) for data directory.Test Plan
jupyter nbconvert --executejupyter nbconvert --executepytest tests/stages/audio/alm/ -vpasses