mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 12:45:44 +08:00
[Core] Multi-tenancy: Pass env variables from job config to worker processes (#10022)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# coding: utf-8
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import grpc
|
||||
@@ -112,5 +113,23 @@ ray.shutdown()
|
||||
all_worker_pids.add(worker_pid)
|
||||
|
||||
|
||||
def test_worker_env(shutdown_only):
|
||||
ray.init(
|
||||
job_config=ray.job_config.JobConfig(worker_env={
|
||||
"foo1": "bar1",
|
||||
"foo2": "bar2"
|
||||
}),
|
||||
_internal_config=json.dumps({
|
||||
"enable_multi_tenancy": True
|
||||
}))
|
||||
|
||||
@ray.remote
|
||||
def get_env(key):
|
||||
return os.environ.get(key)
|
||||
|
||||
assert ray.get(get_env.remote("foo1")) == "bar1"
|
||||
assert ray.get(get_env.remote("foo2")) == "bar2"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main(["-v", __file__]))
|
||||
|
||||
Reference in New Issue
Block a user