<#7482 Support offloaded trigger inputs at registr...
# flyte-github
a
#7482 Support offloaded trigger inputs at registration time. Pull request opened by katrogan Why are the changes needed? Required for low trust environments where the SDK uploads inputs upon trigger registration time. What changes were proposed in this pull request? This PR introduces a new
run_start_time
to the RunSpec. The scheduler now reads the filled in run_start_time and templatizes the trigger task args at kickoff time. How was this patch tested? Several scenarios: [x] regular trigger (TaskTriggerSpec) Ran https://github.com/flyteorg/flyte-sdk/blob/main/examples/triggers/basic.py and verified output included valid kickoff time [x] deployed trigger (TriggerSpec) Using
Copy code
import flyte
from flyte.remote import Trigger

CONFIG = ".flyte/config-oss-local.yaml"
TASK_NAME = "cached_example_task.cached_task"

TRIGGER_NAME = "standalone_minutely"  # distinct from the embedded trigger names

flyte.init_from_config(CONFIG)

Trigger.create(
    trigger=flyte.Trigger.minutely("start_time", name=TRIGGER_NAME),
    task_name=TASK_NAME,
)

print(f"Created standalone trigger '{TRIGGER_NAME}' on task '{TASK_NAME}'.")
[x] cached trigger (TaskTriggerSpec) Using this script
Copy code
import flyte

env = flyte.TaskEnvironment(
    name="cached_example_task",
    env_vars={"_U_USE_ACTIONS": "1"},
)


@env.task(
    cache=flyte.Cache(behavior="auto", ignored_inputs="start_time"),
    triggers=flyte.Trigger.minutely("start_time", name="minutely_cached"),
)
def cached_task(start_time: datetime, x: int = 1) -> str:
    return f"Cached task executed at {start_time.isoformat()} with x={x}"


if __name__ == "__main__":
    flyte.init_from_config()
    flyte.deploy(env)
And verified subsequent runs used cached output from the first run. [x] run time always injected: Using this script
Copy code
import flyte

env = flyte.TaskEnvironment(
    name="hello_run_start_time",
)


@env.task()
async def hello_run_start_time() -> str:
    ctx = flyte.ctx()
    assert ctx is not None
    # run_start_time is populated by the backend from the run's start time (for scheduled-trigger
    # runs, the trigger's fire time) via the {{.runStartTime}} container arg. For ad-hoc runs it
    # defaults to the run-creation time.
    run_start_time = ctx.run_start_time
    print(f"Run start time: {run_start_time.isoformat()}")
    return run_start_time.isoformat()


if __name__ == "__main__":
    flyte.init_from_config()

    run = flyte.run(hello_run_start_time)
    print(run.name)
    print(run.url)
    run.wait()
Verified individual runs output the kickoff time Labels Please add one or more of the following labels to categorize your PR: • added: For new features. • changed: For changes in existing functionality. • deprecated: For soon-to-be-removed features. • removed: For features being removed. • fixed: For any bug fixed. • security: In case of vulnerabilities This is important to improve the readability of release notes. Setup process Screenshots Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. Related PRs Stack If you do use
git town
to manage PR Stacks, the stack relevant to this PR will show below. Otherwise, you can ignore this section. Docs link flyteorg/flyte