Adding Custom Code
Add code to a new or existing stage. If your module needs additional dependencies, package them with Add a Custom Environment.
Before You Start
Before you add code, prepare your development environment:
- Read the pipeline concepts and diagrams.
- Set up a NeMo Curator development environment.
- Create a custom environment if your code needs additional packages or system dependencies.
How to Add Custom Code
Define an importable class, then use it from a pipeline stage.
Define New Functionality
-
Create a
custom_codedirectory anywhere on your system to organize your custom pipeline code. -
Create a new folder for your environment, for example:
new_stage/. -
Create a new file, for example
my_file.py. This file must define a class (MyClass) made available for import. -
Import the class in your stage or pipeline code to use it.
-
Save the files.
Use Your Code in a Pipeline
Create or edit a stage to use your code, then assemble a pipeline and run it in Python:
If your stage needs additional dependencies, add them to a custom image by following Add a Custom Environment. Use the optional extras in pyproject.toml when they provide the packages you need.
Next Steps
Use your module in a custom stage.