gigl.src.common.custom_launcher#
Subprocess dispatch for CustomLauncherConfig-backed launchers.
Takes CustomLauncherConfig.command and CustomLauncherConfig.args
verbatim and shells out via subprocess.run(shell_line, shell=True).
The shell-style invocation honors leading KEY=VALUE env-var
assignments in command so callers can self-document required env
without forcing the dispatcher to parse env separately.
The receiving subprocess has no special protocol — it is expected to be
a plain CLI that argparses whatever flags the YAML wires up via
args[]. The dispatcher performs no template substitution; any
dynamic content (runtime URIs, image refs, etc.) is the caller’s
responsibility — typically resolved at YAML-load time before the
proto reaches this module.
The dispatcher exports its context args as GIGL_* environment
variables on the subprocess env (see gigl.env.constants) so
receiving CLIs can os.environ.get(...) whatever runtime context
they need. The parent process’s os.environ is never mutated; the
GIGL_* keys live only in the per-call env passed to
subprocess.run.
Attributes#
Functions#
|
Shell out to |
Module Contents#
- gigl.src.common.custom_launcher.launch_custom(custom_launcher_config, applied_task_identifier, task_config_uri, resource_config_uri, cpu_docker_uri, cuda_docker_uri, component)[source]#
Shell out to
custom_launcher_config.commandwithargs[]appended.Composes a shell line as
commandfollowed by eachargs[]element passed throughshlex.quote, then invokessubprocess.run(shell_line, shell=True, check=True, env=env).The dispatcher takes
commandandargs[]verbatim — no template substitution of any kind. Any placeholder text in those fields reachessubprocess.runliterally; consumers that want substitution should resolve it at YAML-load time before the proto reaches this module.The subprocess env is built per-call from
os.environ.copy()plus theGIGL_*keys defined ingigl.env.constants. The parent process’sos.environis never mutated. WhenNoneis passed forcpu_docker_uri/cuda_docker_uri, the corresponding env var falls back togigl.common.constants.DEFAULT_GIGL_RELEASE_SRC_IMAGE_CPU/gigl.common.constants.DEFAULT_GIGL_RELEASE_SRC_IMAGE_CUDAso receivers always observe a usable image URI.- Parameters:
custom_launcher_config (snapchat.research.gbml.gigl_resource_config_pb2.CustomLauncherConfig) – Proto whose
commandis the shell snippet to execute and whoseargsare positional arguments appended verbatim.applied_task_identifier (str) – Exported to the subprocess as
GIGL_APPLIED_TASK_IDENTIFIER.task_config_uri (gigl.common.Uri) – Exported to the subprocess as
GIGL_TASK_CONFIG_URI(stringified).resource_config_uri (gigl.common.Uri) – Exported to the subprocess as
GIGL_RESOURCE_CONFIG_URI(stringified).cpu_docker_uri (Optional[str]) – Exported as
GIGL_CPU_DOCKER_URI. Falls back toDEFAULT_GIGL_RELEASE_SRC_IMAGE_CPUwhenNone.cuda_docker_uri (Optional[str]) – Exported as
GIGL_CUDA_DOCKER_URI. Falls back toDEFAULT_GIGL_RELEASE_SRC_IMAGE_CUDAwhenNone.component (gigl.src.common.constants.components.GiGLComponents) – Which GiGL component is being launched. Must be in
_LAUNCHABLE_COMPONENTS. Exported asGIGL_COMPONENTusingcomponent.name(e.g."Trainer").
- Raises:
ValueError – If
componentis not Trainer or Inferencer, or ifcustom_launcher_config.commandis empty.subprocess.CalledProcessError – If the spawned subprocess exits non-zero.
- Return type:
None