# Map-reduce / reduce: command mode and `tar_command_bootstrap` ## TypedJob vs command strings Production client (`client_prod`) treats each leg as either: - **`yt.TypedJob`** — pickled spec, typed table I/O helpers. - **Command string** — `JsonFormat` on stdin/stdout (e.g. `ytjobs.mapper.BatchMapper`). Mapper and reducer **must use the same kind** (both TypedJob or both strings). Mixing them raises `ValueError` from `run_map_reduce`. ```{note} Helpers such as `ytjobs.mapper.BatchMapper` are documented under [YT jobs library (`ytjobs`)](../reference/ytjobs.md). ``` ## Problem this solves For **map**, the framework always ships a bootstrap command: extract `source.tar.gz`, then run `operation_wrapper__map.sh`. Historically, **map_reduce** / **reduce** only listed the tarball as a file dependency without that bootstrap, so **command-string** legs could run with the archive present but **not extracted**. ## Opt-in: `tar_command_bootstrap` In `client.operations.map_reduce` or `client.operations.reduce`, set: ```yaml tar_command_bootstrap: true ``` `max_row_weight` is optional in both sections and defaults to `128M` when omitted. Behavior: | Leg kind | Effect | |----------|--------| | Both TypedJob (map-reduce) | Unchanged: no bash bootstrap; YT handles TypedJob. | | Both strings (map-reduce) | Each leg becomes `bash -c 'tar -xzf source.tar.gz && ./operation_wrapper__map_reduce_mapper.sh'` (mapper) and the analogous `_reducer.sh` for the reducer. | | TypedJob (reduce-only) | Flag ignored for packaging (TypedJob path unchanged). | | String (reduce-only) | Reducer becomes `bash -c '… && ./operation_wrapper__reduce.sh'`. | Default is `false` so existing TypedJob pipelines need no config change. ## Wrappers in the tarball `build_code_locally(..., create_wrappers=True)` (used before upload) generates: - `operation_wrapper__map_reduce_mapper.sh` - `operation_wrapper__map_reduce_reducer.sh` - `operation_wrapper__reduce.sh` They mirror map wrappers: `PYTHONPATH`, `JOB_CONFIG_PATH`, optional `pip install -r requirements.txt`, then `python3 stages//src/