Skip to content

Custom context: document flyte run --custom-context and --custom-context-from-env - #1943

Merged
unionai-docsy-agent[bot] merged 1 commit into
mainfrom
docsy/case-2025
Nov 9, 2026
Merged

unionai-docsy-agent[bot] merged 1 commit into
mainfrom
docsy/case-2025

Conversation

@unionai-docsy-agent

Copy link
Copy Markdown
Contributor

What changed in the product

flyteorg/flyte-sdk#1713 was opened and merged on 2026-10-26 (signals 2025 and 2026). It adds two repeatable options to flyte run:

  • --custom-context KEY=VALUE
  • --custom-context-from-env VAR or KEY=VAR

With these flags you can set a run's custom context without a Python launcher. The change first shipped in flyte-sdk v2.12.2 and is in every later release. The October release notes already list the flags, but the Custom context guide covered only with_runcontext and flyte.custom_context.

Changes

content/user-guide/tasks/task-programming/custom-context.md

  • In Setting custom context, the first way to set context (at launch) now also points to the flyte run flags.
  • Added a From the CLI subsection under Run-level context. It covers:
    • both flags and their formats
    • the requirement for flyte 2.12.2 or later
    • the PR's example command
    • that for file tasks, --local/--tui runs and deployed-task, the flags pass the merged values to with_runcontext(custom_context=...)
    • that --custom-context wins when both flags set the same key
    • that reserved keys are rejected
    • that custom context is run metadata and must not hold secrets

Evidence

The source is RunArguments in src/flyte/cli/_run.py in flyteorg/flyte-sdk at main (9ff526b6). I also ran flyte run --local ... ctx_task.py main with flyte==2.12.4. In that script, a child task returns flyte.get_custom_context(). Results:

Invocation Result
--custom-context experiment=calibration --custom-context-from-env API_BASE_URL (env set) child sees {'API_BASE_URL': 'https://x', 'experiment': 'calibration'}
--custom-context-from-env base=API_BASE_URL {'base': 'https://x'} (the KEY=VAR form renames the key)
--custom-context k=fromflag --custom-context-from-env k=MYVAR {'k': 'fromflag'} (--custom-context wins)
--custom-context q=a=b {'q': 'a=b'} (the value is everything after the first =)
--custom-context-from-env UNSET_VAR_XYZ exits with code 1: environment variable 'UNSET_VAR_XYZ' is not set.
--custom-context _u_kickoff_time_input_arg=x exits with code 1: Custom context key(s) ['_u_kickoff_time_input_arg'] are reserved by Flyte.

Other statements and their sources:

  • The flags pass their values to with_runcontext(custom_context=...) for file tasks, --local/--tui and deployed-task: _run.py calls parsed_custom_context() in three places, one for each of these run types. For remote runs, _run_remote in src/flyte/_run.py passes custom_context=self._custom_context into convert_from_native_to_inputs_binding_artifacts. It does this both for fetched tasks (LazyEntity/TaskDetails) and for TaskTemplate. I ran only the --local path.
  • The secrets warning: comes from the --custom-context-from-env help text ("Custom context is stored as run metadata, so do not use it for secrets").
  • The example command: copied from the PR description.

Open questions

  • No one has launched a remote run with these flags, either deployed-task or a file task. Because of that, the page describes the CLI path by its mechanism (the same with_runcontext(custom_context=...) call as Python) and does not claim end-to-end remote behavior. One remote launch would settle it: deployed-task with --custom-context, then check that the child task's flyte.get_custom_context() has the key. The PR author (dansola) is not on the contact list, so no one is addressed here.

Pre-flight review

Docsy's reviewer read this draft before it was opened and found 2 problems to fix. The draft was amended for them, and a check of the amendment found nothing left to fix.

Its optional suggestions, which the page doesn't need to be right; take them or not:

  • content/user-guide/tasks/task-programming/custom-context.md line 98: The page uses two terms for the same storage. The Overview says custom context "is stored in the blob store of your Union/Flyte instance together with the task's inputs", and this line says "run metadata". The style guide asks for one term per concept. Reusing the Overview's description also makes the warning concrete: anyone who can read the run's inputs can read the value.

Docsy case 2025: https://docsy.apps.demo.hosted.unionai.cloud/cases/2025

Drafted by Docsy, Union.ai's documentation agent, from the product changes and requests in this case. Review it like any PR; close it if it's not wanted.

…ontext-from-env`

Drafted by Docsy for case 2025.

Signed-off-by: unionai-docsy-agent[bot] <336110417+unionai-docsy-agent[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

GHA build & deploy preview

Built by .github/workflows/build-pr.yml and deployed to the docs CF Pages project by .github/workflows/deploy-pr-preview.yml.

Branch alias https://pr-1943-docsy-case-2025.docs-dog.pages.dev
This commit https://99dcfc8a.docs-dog.pages.dev
Commit SHA 11a9cb73d9c5983fbe0a32c3a62f17262f548bee

Updated automatically on every push.

@unionai-docsy-agent
unionai-docsy-agent Bot marked this pull request as ready for review November 9, 2026 13:51
Copilot AI balanced review requested due to automatic review settings November 9, 2026 13:51
@unionai-docsy-agent
unionai-docsy-agent Bot merged commit d83527a into main Nov 9, 2026
17 checks passed
@unionai-docsy-agent

Copy link
Copy Markdown
Contributor Author

Docsy actions: what Docsy did on this PR, and at whose direction. Docsy adds a line for each.

  • 2026-11-09 13:51 UTC · merged it (squash), after marking it ready for review, without an approving review · at the direction of Peeter Piegaze (ppiegaze)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the Flyte CLI run-level context documentation update.

No open issues 🎉

What changed in this PR

Updates the Custom context guide to explain how to set run-level context directly from the Flyte CLI, complementing the existing Python examples.

Changes:

  • Documents both repeatable flags, their formats, and the minimum version requirement.
  • Adds a CLI example and explains precedence, missing environment variables, and reserved-key validation.
  • Describes integration with with_runcontext and warns against storing secrets.
File Description
content/​user-guide/​tasks/​task-programming/​custom-context.md Adds CLI instructions and links them from the run-level context overview.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant