hi @KepingYan, yes, the runtime environment is inheritable, so it will apply to all tasks/actors within a job and all child tasks/actors of a task or actor once set, unless it is overridden.
https://docs.ray.io/en/latest/ray-core/handling-dependencies.html#inheritance
you can verify the behavior with the following code:
import ray
import os
@ray.remote
class B:
def echo(self):
return os.environ.get("env_set")
@ray.remote
class A:
def __init__(self):
pass
def create(self):
return B.remote()
@ray.remote
def foo():
return B.remote()
a = A.options(runtime_env={"env_vars": {"env_set": "actor"}}).remote()
b = ray.get(a.create.remote())
print(ray.get(b.echo.remote()))
b1 = ray.get(foo.options(runtime_env={"env_vars": {"env_set": "task"}}).remote())
print(ray.get(b1.echo.remote()))