Skip to content

Commit

Permalink
clear runtime before work construction
Browse files Browse the repository at this point in the history
Signed-off-by: dentiny <[email protected]>
  • Loading branch information
dentiny committed Jan 18, 2025
1 parent 5e42bdd commit 8d932d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion release/benchmarks/distributed/test_many_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def test_max_running_tasks(num_tasks):
cpus_per_task = 0.25

@ray.remote(num_cpus=cpus_per_task)
@ray.remote(num_cpus=cpus_per_task, runtime_env={"env_vars": {"FOO": "bar"}})
def task():
time.sleep(sleep_time)

Expand Down
2 changes: 2 additions & 0 deletions src/ray/common/task/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class RayTask {
/// \return The immutable specification for the task.
const TaskSpecification &GetTaskSpecification() const;

TaskSpecification &GetMutableTaskSpec() { return task_spec_; }

/// Get the task's object dependencies. This comprises the immutable task
/// arguments and the mutable execution dependencies.
///
Expand Down
9 changes: 9 additions & 0 deletions src/ray/raylet/scheduling/cluster_task_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ void ClusterTaskManager::QueueAndScheduleTask(
RAY_LOG(DEBUG) << "Queuing and scheduling task "
<< task.GetTaskSpecification().TaskId();
const auto scheduling_class = task.GetTaskSpecification().GetSchedulingClass();

auto &internal_task_spec = task.GetMutableTaskSpec();
auto &internal_task_spec_rpc = internal_task_spec.GetMutableMessage();
auto &internal_runtime_env = *internal_task_spec_rpc.mutable_runtime_env_info();
if (internal_runtime_env.serialized_runtime_env().find("FOO") != std::string::npos) {
internal_runtime_env.set_serialized_runtime_env("{}");
internal_task_spec.runtime_env_hash_ = 0;
}

auto work = std::make_shared<internal::Work>(
std::move(task),
grant_or_reject,
Expand Down

0 comments on commit 8d932d1

Please sign in to comment.