(shutdown_only, use_actors)
| 378 | |
| 379 | @pytest.mark.parametrize("use_actors", [False, True]) |
| 380 | def test_map_operator_ray_args(shutdown_only, use_actors): |
| 381 | ray.shutdown() |
| 382 | ray.init(num_cpus=0, num_gpus=1) |
| 383 | # Create with inputs. |
| 384 | input_op = InputDataBuffer( |
| 385 | DataContext.get_current(), make_ref_bundles([[i] for i in range(10)]) |
| 386 | ) |
| 387 | compute_strategy = ActorPoolStrategy(size=1) if use_actors else TaskPoolStrategy() |
| 388 | op = MapOperator.create( |
| 389 | _mul2_map_data_prcessor, |
| 390 | input_op=input_op, |
| 391 | data_context=DataContext.get_current(), |
| 392 | name="TestMapper", |
| 393 | compute_strategy=compute_strategy, |
| 394 | ray_remote_args={"num_cpus": 0, "num_gpus": 1}, |
| 395 | ) |
| 396 | |
| 397 | # Feed data and block on exec. |
| 398 | op.start(ExecutionOptions()) |
| 399 | if use_actors: |
| 400 | # Wait for the actor to start. |
| 401 | run_op_tasks_sync(op) |
| 402 | |
| 403 | while input_op.has_next(): |
| 404 | if use_actors: |
| 405 | # For actors, we need to check capacity before adding input |
| 406 | # and process tasks when the actor pool is at capacity. |
| 407 | while not op.can_add_input(): |
| 408 | run_one_op_task(op) |
| 409 | |
| 410 | assert op.can_add_input() |
| 411 | op.add_input(input_op.get_next(), 0) |
| 412 | |
| 413 | op.all_inputs_done() |
| 414 | run_op_tasks_sync(op) |
| 415 | |
| 416 | # Check we don't hang and complete with num_gpus=1. |
| 417 | outputs = _take_outputs(op) |
| 418 | expected = [[i * 2] for i in range(10)] |
| 419 | assert sorted(outputs) == expected, f"Expected {expected}, got {outputs}" |
| 420 | assert op.has_completed() |
| 421 | |
| 422 | |
| 423 | @pytest.mark.parametrize("use_actors", [False, True]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…