Skip to main content

Module rl_bundle

Module rl_bundle 

Source
Expand description

RL project bundle packaging + upload (LAB-2768)

mecha10 build rl packages a project’s configs/rl/ (job/task definitions - jobs/*.yml, tasks/*/task.json) and configs/simulation/{models,environments} (the assets those jobs reference) into a single tar.gz and uploads it, scoped by the project’s registered robot_id, via the endpoint LAB-2767 adds to mecha10-api. mecha10 run rl (on the trainer host) downloads and unpacks this same bundle before training starts - see “RL: Vision and Phased Roadmap” doc.

This bundle is deliberately separate from mecha10 config push’s configs/ archive (mecha10_robot_config::build_configs_archive): that one syncs the whole configs/ directory to the robot-config KV service for the robot/launcher to consume at runtime, while this one is a purpose-built blob (Minio-backed via LAB-2767, not the KV store) for exactly what a remote/Kestra-dispatched training run needs - replacing the old simulation-assets/* KV convention mecha10 sim push/pull used for this purpose (see LAB-2767’s context: that mechanism is real, working code, but nothing downstream ever reads what it pushes today).

Only models/environments ride along from configs/simulation/ - not images (the flat billboard-image pool environment.json/task.json objects reference by path elsewhere, already synced to the robot separately via mecha10 config push) - matching this ticket’s (LAB-2768) explicit requirement.

Functions§

build_rl_bundle_archive
Build the RL project bundle archive (tar.gz) for project_root, or Ok(None) if the project has neither a configs/rl/ directory nor any configs/simulation/{models,environments} content to package - callers should skip the upload step entirely in that case rather than upload an empty archive.
download_rl_bundle
Download the RL project bundle previously uploaded for robot_id via upload_rl_bundle - LAB-2769’s download side of LAB-2767’s endpoint, called by mecha10 run rl --download-bundle-only on the trainer host. Authenticated identically to upload_rl_bundle (Authorization: Bearer <api_key> + X-User-ID); returns the raw tar.gz bytes for unpack_rl_bundle_archive to unpack.
rl_bundle_tarball_name
Tarball filename for an RL project bundle - matches the <name>-v<version>-<suffix>.tar.gz convention scripts/release/build/package-templates.sh (mecha10-v{VERSION}-templates.tar.gz) and handlers::upload::handle_upload ({name}-v{version}-{platform}-{arch}.tar.gz) already use for versioned release archives.
unpack_rl_bundle_archive
Unpack an RL project bundle archive (as built by build_rl_bundle_archive and returned by download_rl_bundle) into dest_root - entries land at dest_root/configs/rl/... and/or dest_root/configs/simulation/{models,environments}/..., mirroring the project-relative layout the archive was built from (same “archive root mirrors project layout” convention as mecha10_robot_config::extract_configs_archive). Overwrites files already present at the destination; does not delete anything at the destination that’s absent from the archive.
upload_rl_bundle
Upload a pre-built RL project bundle archive for robot_id, authenticated the same way every other mecha10 CLI command talks to mecha10-api (Authorization: Bearer <api_key> + X-User-ID, see handlers::upload::upload_to_registry/services::publish_status).