forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Jobs] Make sure JobConfig specified in the init script is not being …
…overridden by the SupervisorActor (ray-project#38676) NOTE: This is a revert of the revert, addressing broken tests Currently when executing the job submitted via Ray Job submission API, SupervisorActor will be overriding whole of the JobConfig making it impossible to specify additional params like JobConfig.code_search_path for ex. --------- Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
- Loading branch information
1 parent
f3988eb
commit e063bd7
Showing
7 changed files
with
181 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
import ray | ||
from ray._private.gcs_utils import GcsAioClient | ||
from ray.dashboard.modules.job.job_manager import ( | ||
JobManager, | ||
) | ||
|
||
|
||
TEST_NAMESPACE = "jobs_test_namespace" | ||
|
||
|
||
def create_ray_cluster(_tracing_startup_hook=None): | ||
return ray.init( | ||
num_cpus=16, | ||
num_gpus=1, | ||
resources={"Custom": 1}, | ||
namespace=TEST_NAMESPACE, | ||
log_to_driver=True, | ||
_tracing_startup_hook=_tracing_startup_hook, | ||
) | ||
|
||
|
||
def create_job_manager(ray_cluster, tmp_path): | ||
address_info = ray_cluster | ||
gcs_aio_client = GcsAioClient( | ||
address=address_info["gcs_address"], nums_reconnect_retry=0 | ||
) | ||
return JobManager(gcs_aio_client, tmp_path) | ||
|
||
|
||
def _driver_script_path(file_name: str) -> str: | ||
return os.path.join( | ||
os.path.dirname(__file__), "subprocess_driver_scripts", file_name | ||
) |
31 changes: 31 additions & 0 deletions
31
...board/modules/job/tests/subprocess_driver_scripts/check_code_search_path_is_propagated.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
A dummy ray driver script that executes in subprocess. | ||
Prints global worker's `load_code_from_local` property that ought to be set | ||
whenever `JobConfig.code_search_path` is specified | ||
""" | ||
|
||
|
||
def run(): | ||
import ray | ||
from ray.job_config import JobConfig | ||
|
||
ray.init(job_config=JobConfig(code_search_path=["/home/code/"])) | ||
|
||
@ray.remote | ||
def foo() -> bool: | ||
return ray._private.worker.global_worker.load_code_from_local | ||
|
||
load_code_from_local = ray.get(foo.remote()) | ||
|
||
statement = "propagated" if load_code_from_local else "NOT propagated" | ||
|
||
# Step 1: Print the statement indicating that the code_search_path have been | ||
# properly respected | ||
print(f"Code search path is {statement}") | ||
# Step 2: Print the whole runtime_env to validate that it's been passed | ||
# appropriately from submit_job API | ||
print(ray.get_runtime_context().runtime_env) | ||
|
||
|
||
if __name__ == "__main__": | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
dashboard/modules/job/tests/test_job_manager_standalone.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import pytest | ||
import sys | ||
|
||
from ray._private.test_utils import ( | ||
async_wait_for_condition_async_predicate, | ||
) | ||
from ray.dashboard.modules.job.tests.conftest import ( | ||
create_ray_cluster, | ||
create_job_manager, | ||
_driver_script_path, | ||
) | ||
from ray.dashboard.modules.job.tests.test_job_manager import check_job_succeeded | ||
|
||
|
||
@pytest.mark.asyncio | ||
class TestRuntimeEnvStandalone: | ||
"""NOTE: PLEASE READ CAREFULLY BEFORE MODIFYING | ||
This test is extracted into a standalone module such that it can bootstrap its own | ||
(standalone) Ray cluster while avoiding affecting the shared one used by other | ||
JobManager tests | ||
""" | ||
|
||
@pytest.mark.parametrize( | ||
"tracing_enabled", | ||
[ | ||
False, | ||
# TODO(issues/38633): local code loading is broken when tracing is enabled | ||
# True, | ||
], | ||
) | ||
async def test_user_provided_job_config_honored_by_worker( | ||
self, tracing_enabled, tmp_path | ||
): | ||
"""Ensures that the JobConfig instance injected into ray.init in the driver | ||
script is honored even in case when job is submitted via JobManager.submit_job | ||
API (involving RAY_JOB_CONFIG_JSON_ENV_VAR being set in child process env) | ||
""" | ||
|
||
if tracing_enabled: | ||
tracing_startup_hook = ( | ||
"ray.util.tracing.setup_local_tmp_tracing:setup_tracing" | ||
) | ||
else: | ||
tracing_startup_hook = None | ||
|
||
with create_ray_cluster(_tracing_startup_hook=tracing_startup_hook) as cluster: | ||
job_manager = create_job_manager(cluster, tmp_path) | ||
|
||
driver_script_path = _driver_script_path( | ||
"check_code_search_path_is_propagated.py" | ||
) | ||
|
||
job_id = await job_manager.submit_job( | ||
entrypoint=f"python {driver_script_path}", | ||
# NOTE: We inject runtime_env in here, but also specify the JobConfig in | ||
# the driver script: settings to JobConfig (other than the | ||
# runtime_env) passed in via ray.init(...) have to be respected | ||
# along with the runtime_env passed from submit_job API | ||
runtime_env={"env_vars": {"TEST_SUBPROCESS_RANDOM_VAR": "0xDEEDDEED"}}, | ||
) | ||
|
||
await async_wait_for_condition_async_predicate( | ||
check_job_succeeded, job_manager=job_manager, job_id=job_id | ||
) | ||
|
||
logs = job_manager.get_job_logs(job_id) | ||
|
||
assert "Code search path is propagated" in logs, logs | ||
assert "0xDEEDDEED" in logs, logs | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(pytest.main(["-v", __file__])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters