<#1334 Support plugin_config in TaskTemplate.overr...
# flyte-github
a
#1334 Support plugin_config in TaskTemplate.override Pull request opened by pingsutw Why Setting
plugin_config
via
override()
had no effect — the task still ran as a plain python task. Plugin behavior lives on the template class, not on a field.
TaskEnvironment.task()
resolves the class from
TaskPluginRegistry
at decoration time (
_task_environment.py:343
), and that class carries the
task_type
and the custom config serialization (
RayFunctionTask
/
task_type="ray"
). Because
dataclasses.replace
preserves
type(self)
,
override(plugin_config=...)
produced an
AsyncFunctionTaskTemplate
with
task_type="python"
and empty custom config on the wire. What • Expose
plugin_config
as an explicit keyword argument on
TaskTemplate.override()
. • Look the plugin class up in the same
TaskPluginRegistry
that
TaskEnvironment.task()
uses, with the same error when no plugin is registered, and rebuild the overridden task as that class.
task_type
is dropped from the copied fields so the plugin's own default applies. • Overriding the config of a task that is already the plugin class keeps the class and replaces the config; omitting
plugin_config
preserves the existing one. • Update
examples/plugins/ray_example.py
to configure the plugin at call time. run = flyte.run(hello_ray_nested.override(plugin_config=ray_config)) Tests import asyncio import typing import ray from flyteplugins.ray.task import HeadNodeConfig, RayJobConfig, WorkerNodeConfig import flyte.remote import flyte.storage @ray.remote def f(x): return x * x ray_config = RayJobConfig( head_node_config=HeadNodeConfig(ray_start_params={"log-color": "True"}), worker_node_config=[WorkerNodeConfig(group_name="ray-group", replicas=2)], runtime_env={"pip": ["numpy", "pandas"]}, enable_autoscaling=False, shutdown_after_job_finishes=True, ttl_seconds_after_finished=300, ) image = ( flyte.Image.from_debian_base(name="ray") .with_apt_packages("wget") .with_pip_packages("ray[default]==2.46.0", "flyteplugins-ray", "pip", "mypy") ) task_env = flyte.TaskEnvironment( name="hello_ray", resources=flyte.Resources(cpu=(1, 2), memory=("400Mi", "1000Mi")), image=image ) ray_env = flyte.TaskEnvironment( name="ray_env", image=image, resources=flyte.Resources(cpu=(3, 4), memory=("3000Mi", "5000Mi")), depends_on=[task_env], ) @task_env.task() async def hello_ray(): await asyncio.sleep(20) print("Hello from the Ray task!") @ray_env.task async def hello_ray_nested(n: int = 3) -> typing.List[int]: print("running ray task") t = asyncio.create_task(hello_ray()) futures = [f.remote(i) for i in range(n)] res = ray.get(futures) await t return res if name == "__main__": flyte.init_from_config() run = flyte.run(hello_ray_nested.override(plugin_config=ray_config)) print("run name:", run.name) print("run url:", run.url) run.wait() action_details = flyte.remote.ActionDetails.get(run_name=run.name, name="a0") for log in action_details.pb2.attempts[-1].log_info: print(f"{log.name}: {log.uri}") Added to
tests/user_api/test_override.py
using a locally registered dummy plugin: class swap, re-override on a plugin task, preserve-on-omit, and the unregistered-config error. Full suite, this branch vs. a clean
main
worktree (
pytest tests/flyte tests/user_api
): | passed | failed | | | ----------- | ------ | -- | | this branch | 3633 | 18 | | main | 3630 | 18 | No regressions — the +3 passed are the new tests. All 18 failures reproduce on
main
and are environmental (docker
buildx --push
to a registry at
localhost:30000
, obstore/minio storage tests). The two failures that are not identical between the runs —
test_image.py::test_install_flyte_false_builds_full_image
and
test_int_image_builder.py::test_real_build
— are cwd-sensitive and flaky respectively; the first fails on unmodified
main
source too when run from the repo root. Verified against the real Ray plugin —
override(plugin_config=RayJobConfig(...))
now yields
RayFunctionTask
, and
get_proto_task
emits
type: "ray"
with a populated
rayCluster
custom config. https://claude.ai/code/session_01F4ZdQ2hENGqdWF57j1GfEt flyteorg/flyte-sdk