Custom Generators and Converters¶
Use a custom component only when the generated catalogs do not provide the
required behavior. Keep the .scr.py file inside the project, load it
explicitly, and make inputs visible in the descriptor.
Component script¶
When DATAMIMIC loads a project .scr.py file, the base classes Generator,
Converter, and CustomConverter are available automatically. Do not import
internal DATAMIMIC implementation modules to define a project component.
| script/custom.scr.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Load and use the component¶
| datamimic.xml | |
|---|---|
1 2 3 4 5 6 | |
This example uses numProcess="1" because its generator owns a counter. A
component intended for parallel generation should not rely on mutable
process-local state.
Custom scripts execute code and therefore belong to the project's trusted code base. Review them like application code and avoid hidden network or filesystem side effects. For read-only runtime values or memstore reads, use the public Scripting API instead of importing engine internals.