Skip to content

Commit

Permalink
Resloved comments
Browse files Browse the repository at this point in the history
Signed-off-by: win5923 <[email protected]>
  • Loading branch information
win5923 committed Jan 24, 2025
1 parent 4373b3a commit 0d22a3a
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def py_func_pass_python_actor_handle():

@ray.remote
def py_func_python_raise_exception():
raise ZeroDivisionError
_ = 1 / 0


@ray.remote
Expand Down
8 changes: 4 additions & 4 deletions python/ray/dag/tests/experimental/test_accelerated_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2539,14 +2539,14 @@ async def main():
match=(expected_error_message),
):
_ = await async_compiled_dag.execute_async(1)
(ref1, ref2) # noqa: B018
_ = (ref1, ref2)

loop = get_or_create_event_loop()
loop.run_until_complete(main())
# to show variables are being used and avoid destruction since
# CompiledDagRef __del__ will release buffers and
# increment _max_finished_execution_index
(ref1, ref2) # noqa: B018
_ = (ref1, ref2)


def test_result_buffer_exceeds_capacity(ray_start_regular):
Expand Down Expand Up @@ -2587,12 +2587,12 @@ async def main():
match=(expected_error_message),
):
_ = await async_compiled_dag.execute_async(4)
(ref1, ref3) # noqa: B018
_ = (ref1, ref3)

loop = get_or_create_event_loop()
loop.run_until_complete(main())
# same reason as comment for test_inflight_requests_exceed_capacity
(ref1, ref3) # noqa: B018
_ = (ref1, ref3)


def test_event_profiling(ray_start_regular, monkeypatch):
Expand Down
5 changes: 3 additions & 2 deletions python/ray/data/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_user_exception(
ctx.log_internal_stack_trace_to_stdout = log_internal_stack_trace_to_stdout

def f(row):
raise ZeroDivisionError
_ = 1 / 0

with pytest.raises(UserCodeException) as exc_info:
ray.data.range(1).map(f).take_all()
Expand Down Expand Up @@ -79,7 +79,8 @@ def test_full_traceback_logged_with_ray_debugger(
monkeypatch.setenv("RAY_DEBUG_POST_MORTEM", 1)

def f(row):
raise ZeroDivisionError
_ = 1 / 0
return row

with pytest.raises(Exception) as exc_info:
ray.data.range(1).map(f).take_all()
Expand Down
2 changes: 1 addition & 1 deletion python/ray/data/tests/test_execution_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_read_tasks(self, parallelism: int) -> List[ReadTask]:
large_object = np.zeros((128, 1024, 1024), dtype=np.uint8) # 128 MiB

def read_fn():
large_object # noqa : B018
_ = large_object
yield pd.DataFrame({"column": [0]})

return [ReadTask(read_fn, BlockMetadata(1, None, None, None, None))]
Expand Down
2 changes: 1 addition & 1 deletion python/ray/serve/tests/test_config_files/fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@serve.deployment
class A:
def __init__(self):
raise ZeroDivisionError
_ = 1 / 0


node = A.bind()
2 changes: 1 addition & 1 deletion python/ray/serve/tests/test_config_files/fail_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class A:
def __init__(self):
time.sleep(5)
raise ZeroDivisionError
_ = 1 / 0


node = A.bind()
2 changes: 1 addition & 1 deletion python/ray/serve/tests/test_config_files/import_error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ray import serve

raise ZeroDivisionError
_ = 1 / 0


@serve.deployment(ray_actor_options={"num_cpus": 0.1})
Expand Down
2 changes: 1 addition & 1 deletion python/ray/serve/tests/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_fastapi_init_lifespan_should_not_shutdown(serve_instance):

@app.on_event("shutdown")
async def shutdown():
raise ZeroDivisionError
_ = 1 / 0

@serve.deployment
@serve.ingress(app)
Expand Down
2 changes: 1 addition & 1 deletion python/ray/serve/tests/test_http_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def redirect_twice(self, request: Request):
def test_default_error_handling(serve_instance):
@serve.deployment
def f():
raise ZeroDivisionError
_ = 1 / 0

serve.run(f.bind())
r = requests.get("http://localhost:8000/f")
Expand Down
4 changes: 2 additions & 2 deletions python/ray/serve/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def test_proxy_metrics_fields_not_found(serve_start_shutdown):

# Should generate 404 responses
broken_url = "http://127.0.0.1:8000/fake_route"
requests.get(broken_url)
_ = requests.get(broken_url).text
print("Sent requests to broken URL.")

# Ping gRPC proxy for not existing application.
Expand Down Expand Up @@ -540,7 +540,7 @@ def f(*args):

# Deployment should generate divide-by-zero errors
correct_url = "http://127.0.0.1:8000/real_route"
requests.get(correct_url)
_ = requests.get(correct_url).text
print("Sent requests to correct URL.")

# Ping gPRC proxy for broken app
Expand Down
12 changes: 6 additions & 6 deletions python/ray/serve/tests/unit/test_batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ async def test_batch_size_one_long_timeout(use_class):
@serve.batch(max_batch_size=1, batch_wait_timeout_s=1000)
async def long_timeout(requests):
if "raise" in requests:
raise ZeroDivisionError
_ = 1 / 0
return requests

class LongTimeout:
@serve.batch(max_batch_size=1, batch_wait_timeout_s=1000)
async def long_timeout(self, requests):
if "raise" in requests:
raise ZeroDivisionError
_ = 1 / 0
return requests

cls = LongTimeout()
Expand All @@ -158,15 +158,15 @@ async def test_batch_size_multiple_zero_timeout(use_class):
async def zero_timeout(requests):
await block_execution_event.wait()
if "raise" in requests:
raise ZeroDivisionError
_ = 1 / 0
return requests

class ZeroTimeout:
@serve.batch(max_batch_size=2, batch_wait_timeout_s=0)
async def zero_timeout(self, requests):
await block_execution_event.wait()
if "raise" in requests:
raise ZeroDivisionError
_ = 1 / 0
return requests

cls = ZeroTimeout()
Expand Down Expand Up @@ -262,14 +262,14 @@ async def test_batch_size_multiple_long_timeout(use_class):
@serve.batch(max_batch_size=3, batch_wait_timeout_s=1000)
async def long_timeout(requests):
if "raise" in requests:
raise ZeroDivisionError
_ = 1 / 0
return requests

class LongTimeout:
@serve.batch(max_batch_size=3, batch_wait_timeout_s=1000)
async def long_timeout(self, requests):
if "raise" in requests:
raise ZeroDivisionError
_ = 1 / 0
return requests

cls = LongTimeout()
Expand Down
4 changes: 2 additions & 2 deletions python/ray/tests/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def task():

@ray.remote
def task_throws():
raise ZeroDivisionError
_ = 1 / 0

with pytest.raises(ray.exceptions.RayTaskError):
await task_throws.remote().as_future()
Expand All @@ -148,7 +148,7 @@ def big_object(self):
return "a" * (str_len)

def throw_error(self):
raise ZeroDivisionError
_ = 1 / 0

actor = Actor.remote()

Expand Down
2 changes: 1 addition & 1 deletion python/ray/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def __init__(self):
self.val = ray.put(0)

def method(self):
f # noqa : B018
_ = f

f = Foo()
ray.put(f)
Expand Down
4 changes: 2 additions & 2 deletions python/ray/tests/test_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def test_export_large_objects(ray_start_regular, error_pubsub):

@ray.remote
def f():
large_object # noqa : B018
_ = large_object

# Invoke the function so that the definition is exported.
f.remote()
Expand All @@ -531,7 +531,7 @@ def f():
@ray.remote
class Foo:
def __init__(self):
large_object # noqa: B018
_ = large_object

Foo.remote()

Expand Down
6 changes: 3 additions & 3 deletions python/ray/tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def test_numpy_ufunc(ray_start_shared_local_modes):
@ray.remote
def f():
# add reference to the numpy ufunc
log # noqa: B018
_ = log

ray.get(f.remote())

Expand Down Expand Up @@ -747,7 +747,7 @@ def test():

@ray.remote
def f():
ref # noqa: B018
_ = ref

with pytest.raises(ray.exceptions.OufOfBandObjectRefSerializationException):
ray.get(f.remote())
Expand All @@ -774,7 +774,7 @@ def test():

@ray.remote
def f():
ref # noqa: B018
_ = ref

ray.get(f.remote())

Expand Down
2 changes: 1 addition & 1 deletion python/ray/train/tests/test_base_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_large_params(ray_start_4_cpus):
huge_array = np.zeros(shape=int(1e8))

def training_loop(self):
huge_array # noqa: B018
_ = huge_array

trainer = DummyTrainer(training_loop)
trainer.fit()
Expand Down
4 changes: 2 additions & 2 deletions rllib/offline/offline_prelearner.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def convert(sample, space):

if is_multi_agent:
# TODO (simon): Add support for multi-agent episodes.
raise NotImplementedError
pass
else:
# Build a single-agent episode with a single row of the batch.
episode = SingleAgentEpisode(
Expand Down Expand Up @@ -521,7 +521,7 @@ def _map_sample_batch_to_episode(

if is_multi_agent:
# TODO (simon): Add support for multi-agent episodes.
raise NotImplementedError
pass
else:
# Unpack observations, if needed. Note, observations could
# be either compressed by their entirety (the complete batch
Expand Down

0 comments on commit 0d22a3a

Please sign in to comment.