mirror of
https://github.com/wassname/ray.git
synced 2026-07-10 18:08:04 +08:00
[Core] Added support for submission-time task names. (#10449)
* Added support for submission-time task names. * Suggestions from code review: add missing consts Co-authored-by: SangBin Cho <rkooo567@gmail.com> * Add num_returns arg to actor method options docstring example. * Add process name line and proctitle assertion to submission-time task name section of advanced docs. * Add submission-time task name --> proctitle test for Python worker. * Added Python actor options tests for num_returns and name. * Added Java test for submission-time task names. * Add dashboard image to task name docs section. * Move to fstrings. Co-authored-by: SangBin Cho <rkooo567@gmail.com>
This commit is contained in:
@@ -35,7 +35,7 @@ def attempt_to_load_balance(remote_function,
|
||||
[remote_function.remote(*args) for _ in range(total_tasks)])
|
||||
names = set(locations)
|
||||
counts = [locations.count(name) for name in names]
|
||||
logger.info("Counts are {}.".format(counts))
|
||||
logger.info(f"Counts are {counts}.")
|
||||
if (len(names) == num_nodes
|
||||
and all(count >= minimum_count for count in counts)):
|
||||
break
|
||||
@@ -346,6 +346,28 @@ def test_ray_setproctitle(ray_start_2_cpus):
|
||||
ray.get(unique_1.remote())
|
||||
|
||||
|
||||
def test_ray_task_name_setproctitle(ray_start_2_cpus):
|
||||
method_task_name = "foo"
|
||||
|
||||
@ray.remote
|
||||
class UniqueName:
|
||||
def __init__(self):
|
||||
assert setproctitle.getproctitle() == "ray::UniqueName.__init__()"
|
||||
|
||||
def f(self):
|
||||
assert setproctitle.getproctitle() == f"ray::{method_task_name}"
|
||||
|
||||
task_name = "bar"
|
||||
|
||||
@ray.remote
|
||||
def unique_1():
|
||||
assert task_name in setproctitle.getproctitle()
|
||||
|
||||
actor = UniqueName.remote()
|
||||
ray.get(actor.f.options(name=method_task_name).remote())
|
||||
ray.get(unique_1.options(name=task_name).remote())
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
os.getenv("TRAVIS") is None,
|
||||
reason="This test should only be run on Travis.")
|
||||
@@ -508,7 +530,7 @@ def test_invalid_unicode_in_worker_log(shutdown_only):
|
||||
|
||||
# Wait till first worker log file is created.
|
||||
while True:
|
||||
log_file_paths = glob.glob("{}/worker*.out".format(logs_dir))
|
||||
log_file_paths = glob.glob(f"{logs_dir}/worker*.out")
|
||||
if len(log_file_paths) == 0:
|
||||
time.sleep(0.2)
|
||||
else:
|
||||
@@ -546,13 +568,13 @@ def test_move_log_files_to_old(shutdown_only):
|
||||
|
||||
# Make sure no log files are in the "old" directory before the actors
|
||||
# are killed.
|
||||
assert len(glob.glob("{}/old/worker*.out".format(logs_dir))) == 0
|
||||
assert len(glob.glob(f"{logs_dir}/old/worker*.out")) == 0
|
||||
|
||||
# Now kill the actors so the files get moved to logs/old/.
|
||||
[a.__ray_terminate__.remote() for a in actors]
|
||||
|
||||
while True:
|
||||
log_file_paths = glob.glob("{}/old/worker*.out".format(logs_dir))
|
||||
log_file_paths = glob.glob(f"{logs_dir}/old/worker*.out")
|
||||
if len(log_file_paths) > 0:
|
||||
with open(log_file_paths[0], "r") as f:
|
||||
assert "function f finished\n" in f.readlines()
|
||||
@@ -641,7 +663,7 @@ Blacklisted: No
|
||||
"""
|
||||
constraints_dict = resource_spec._constraints_from_gpu_info(info_string)
|
||||
expected_dict = {
|
||||
"{}V100".format(ray_constants.RESOURCE_CONSTRAINT_PREFIX): 1
|
||||
f"{ray_constants.RESOURCE_CONSTRAINT_PREFIX}V100": 1,
|
||||
}
|
||||
assert constraints_dict == expected_dict
|
||||
|
||||
@@ -658,7 +680,7 @@ Blacklisted: No
|
||||
"""
|
||||
constraints_dict = resource_spec._constraints_from_gpu_info(info_string)
|
||||
expected_dict = {
|
||||
"{}T4".format(ray_constants.RESOURCE_CONSTRAINT_PREFIX): 1
|
||||
f"{ray_constants.RESOURCE_CONSTRAINT_PREFIX}T4": 1,
|
||||
}
|
||||
assert constraints_dict == expected_dict
|
||||
|
||||
|
||||
Reference in New Issue
Block a user