Skip to content

RFC: Environment Wrap Task Run #132

@leongdl

Description

@leongdl

Description

Extend <EnvironmentActions> with a third session action, onWrapTaskRun, that lets an environment template intercept and wrap a task's onRun action. The runtime provides the wrap action with the task's command, args, timeout, cancelation method, and environment variables as template variables (Task.Command, Task.Args, Task.Environment, Env.Action.Timeout). This enables environment templates to execute tasks inside containers, virtual machines, or other execution contexts without modifying the job template.

The primary motivation is container support: a Docker or Apptainer environment template can start a container in onEnter, run each task inside it via onWrapTaskRun, and stop it in onExit. Job templates remain portable across Conda, Rez, Docker, and Apptainer environments. The mechanism is general enough for remote execution, instrumentation, and privilege isolation use cases as well.

Specification version: 2023-09 extension WRAP_TASK_RUN. Depends on RFC 0002 and the EXPR extension's repr_sh() function from RFC 0006.

Roles

Role User
Proposed By @leongdl
Author(s) @leongdl

Workflow

  • Tracking issue created (label: rfc/proposed)
  • RFC pull request submitted and ready for discussion (label: rfc/exploring)
  • Last call for comments (labels: rfc/exploring and rfc/final-comments)
  • Accepted and merged RFC pull request (label: rfc/accepted-future)
  • Green-light for inclusion in a draft specification, and the author is creating and iterating on pull requests (label: rfc/accepted-draft)
  • Pull requests are merged in to a draft specification (label: rfc/accepted-staged)
  • Officially published in a non-draft revision of the specification (label: rfc/released)

Please close this tracking issue when the proposal enters the Released stage of the process.

Open Points

  1. Single-layer vs. nested composition — Should multiple onWrapTaskRun actions compose as nested wrappers, or should only one active layer be allowed per session? The RFC recommends starting with a single-layer restriction for simplicity, relaxing it in a future RFC if real use cases for nesting emerge.

  2. Task monitoring / watchdog — Container workloads can stall silently (GPU crash, application deadlock). Consider adding a Task.Monitor variable or periodic onMonitor action for health-checking wrapped processes (e.g., via docker stats). The RFC recommends deferring this to a future RFC, but designing onWrapTaskRun so a monitoring mechanism can be added without breaking changes.


The author is responsible to progress the RFC according to this checklist, and
apply the relevant labels to this issue.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions