Skip to content

Commit c66bdf2

Browse files
authored
[pydoclint] dashboard docstring minimal format errors (#52875)
## Why are these changes needed? This changes are part a batch effort to rewrite Ray's docstrings to be minimally pydoclint compliant. This PR focuses on making them at least pass basic formatting checks ## Related issue number <!-- For example: "Closes #1234" --> ## Checks - [x] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Thomas Desrosiers <[email protected]>
1 parent 05ba146 commit c66bdf2

File tree

2 files changed

+58
-69
lines changed

2 files changed

+58
-69
lines changed

python/ray/dashboard/modules/log/log_manager.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,19 @@ async def _resolve_actor_filename(
201201
suffix: str,
202202
timeout: int,
203203
):
204-
"""
205-
Resolve actor log file
206-
Args:
207-
actor_id: The actor id.
208-
get_actor_fn: The function to get actor information.
209-
suffix: The suffix of the log file.
210-
timeout: Timeout in seconds.
211-
Returns:
212-
The log file name and node id.
213-
214-
Raises:
215-
ValueError if actor data is not found or get_actor_fn is not provided.
204+
"""Resolve actor log file.
205+
206+
Args:
207+
actor_id: The actor id.
208+
get_actor_fn: The function to get actor information.
209+
suffix: The suffix of the log file.
210+
timeout: Timeout in seconds.
211+
212+
Returns:
213+
The log file name and node id.
214+
215+
Raises:
216+
ValueError: If actor data is not found or get_actor_fn is not provided.
216217
"""
217218
if get_actor_fn is None:
218219
raise ValueError("get_actor_fn needs to be specified for actor_id")
@@ -249,23 +250,21 @@ async def _resolve_actor_filename(
249250
async def _resolve_task_filename(
250251
self, task_id: str, attempt_number: int, suffix: str, timeout: int
251252
):
252-
"""
253-
Resolve log file for a task.
253+
"""Resolve log file for a task.
254254
255255
Args:
256256
task_id: The task id.
257257
attempt_number: The attempt number.
258-
suffix: The suffix of the log file, e.g. out or err
258+
suffix: The suffix of the log file, e.g. out or err.
259259
timeout: Timeout in seconds.
260260
261261
Returns:
262262
The log file name, node id, the start and end offsets of the
263263
corresponding task log in the file.
264264
265265
Raises:
266-
FileNotFoundError if the log file is not found.
267-
ValueError if the suffix is not out or err.
268-
266+
FileNotFoundError: If the log file is not found.
267+
ValueError: If the suffix is not out or err.
269268
"""
270269
log_filename = None
271270
node_id = None

python/ray/dashboard/modules/reporter/reporter_head.py

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,18 @@ async def get_task_ids_running_in_a_worker(self, worker_id: str) -> List[str]:
173173
async def get_worker_details_for_running_task(
174174
self, task_id: str, attempt_number: int
175175
) -> Tuple[Optional[int], Optional[str]]:
176-
"""
177-
Retrieves worker details for a specific task and attempt number.
176+
"""Retrieves worker details for a specific task and attempt number.
178177
179178
Args:
180179
task_id: The ID of the task.
181180
attempt_number: The attempt number of the task.
182181
183182
Returns:
184-
Tuple[Optional[int], Optional[str]]: A tuple
185-
containing the worker's PID (process ID),
186-
and worker's ID.
183+
Tuple[Optional[int], Optional[str]]: A tuple containing the worker's PID
184+
(process ID), and worker's ID.
187185
188186
Raises:
189-
ValueError: If the task attempt is not running or
190-
the state APi is not initialized.
187+
ValueError: If the task attempt is not running or the state API is not initialized.
191188
"""
192189
if self._state_api is None:
193190
raise ValueError("The state API is not initialized yet. Please retry.")
@@ -217,35 +214,27 @@ async def get_worker_details_for_running_task(
217214
return pid, worker_id
218215

219216
@routes.get("/task/traceback")
220-
async def get_task_traceback(self, req) -> aiohttp.web.Response:
221-
"""
222-
Retrieves the traceback information for a specific task.
217+
async def get_task_traceback(
218+
self, req: aiohttp.web.Request
219+
) -> aiohttp.web.Response:
220+
"""Retrieves the traceback information for a specific task.
223221
Note that one worker process works on one task at a time
224222
or one worker works on multiple async tasks.
225223
226-
Args:
227-
req (aiohttp.web.Request): The HTTP request object.
228-
229224
Params:
230225
task_id: The ID of the task.
231226
attempt_number: The attempt number of the task.
232227
node_id: The ID of the node.
233228
234229
Returns:
235-
aiohttp.web.Response: The HTTP response containing
236-
the traceback information.
230+
aiohttp.web.Response: The HTTP response containing the traceback information.
237231
238232
Raises:
239-
ValueError: If the "task_id" parameter
240-
is missing in the request query.
241-
ValueError: If the "attempt_number" parameter
242-
is missing in the request query.
243-
ValueError: If the worker begins working on
244-
another task during the traceback retrieval.
245-
aiohttp.web.HTTPInternalServerError: If there is
246-
an internal server error during the traceback retrieval.
233+
ValueError: If the "task_id" parameter is missing in the request query.
234+
ValueError: If the "attempt_number" parameter is missing in the request query.
235+
ValueError: If the worker begins working on another task during the traceback retrieval.
236+
aiohttp.web.HTTPInternalServerError: If there is an internal server error during the traceback retrieval.
247237
"""
248-
249238
if "task_id" not in req.query:
250239
raise ValueError("task_id is required")
251240
if "attempt_number" not in req.query:
@@ -317,30 +306,23 @@ async def get_task_traceback(self, req) -> aiohttp.web.Response:
317306
)
318307

319308
@routes.get("/task/cpu_profile")
320-
async def get_task_cpu_profile(self, req) -> aiohttp.web.Response:
321-
"""
322-
Retrieves the CPU profile for a specific task.
309+
async def get_task_cpu_profile(
310+
self, req: aiohttp.web.Request
311+
) -> aiohttp.web.Response:
312+
"""Retrieves the CPU profile for a specific task.
323313
Note that one worker process works on one task at a time
324314
or one worker works on multiple async tasks.
325315
326-
Args:
327-
req (aiohttp.web.Request): The HTTP request object.
328-
329316
Returns:
330317
aiohttp.web.Response: The HTTP response containing the CPU profile data.
331318
332319
Raises:
333-
ValueError: If the "task_id" parameter is
334-
missing in the request query.
335-
ValueError: If the "attempt_number" parameter is
336-
missing in the request query.
320+
ValueError: If the "task_id" parameter is missing in the request query.
321+
ValueError: If the "attempt_number" parameter is missing in the request query.
337322
ValueError: If the maximum duration allowed is exceeded.
338-
ValueError: If the worker begins working on
339-
another task during the profile retrieval.
340-
aiohttp.web.HTTPInternalServerError: If there is
341-
an internal server error during the profile retrieval.
342-
aiohttp.web.HTTPInternalServerError: If the CPU Flame
343-
Graph information for the task is not found.
323+
ValueError: If the worker begins working on another task during the profile retrieval.
324+
aiohttp.web.HTTPInternalServerError: If there is an internal server error during the profile retrieval.
325+
aiohttp.web.HTTPInternalServerError: If the CPU Flame Graph information for the task is not found.
344326
"""
345327
if "task_id" not in req.query:
346328
raise ValueError("task_id is required")
@@ -420,8 +402,9 @@ async def get_task_cpu_profile(self, req) -> aiohttp.web.Response:
420402
)
421403

422404
@routes.get("/worker/traceback")
423-
async def get_traceback(self, req) -> aiohttp.web.Response:
424-
"""
405+
async def get_traceback(self, req: aiohttp.web.Request) -> aiohttp.web.Response:
406+
"""Retrieves the traceback information for a specific worker.
407+
425408
Params:
426409
pid: Required. The PID of the worker.
427410
ip: Required. The IP address of the node.
@@ -457,11 +440,21 @@ async def get_traceback(self, req) -> aiohttp.web.Response:
457440
return aiohttp.web.HTTPInternalServerError(text=reply.output)
458441

459442
@routes.get("/worker/cpu_profile")
460-
async def cpu_profile(self, req) -> aiohttp.web.Response:
461-
"""
443+
async def cpu_profile(self, req: aiohttp.web.Request) -> aiohttp.web.Response:
444+
"""Retrieves the CPU profile for a specific worker.
445+
462446
Params:
463447
pid: Required. The PID of the worker.
464448
ip: Required. The IP address of the node.
449+
duration: Optional. Duration in seconds for profiling (default: 5, max: 60).
450+
format: Optional. Output format (default: "flamegraph").
451+
native: Optional. Whether to use native profiling (default: false).
452+
453+
Raises:
454+
ValueError: If pid is not provided.
455+
ValueError: If ip is not provided.
456+
ValueError: If duration exceeds 60 seconds.
457+
aiohttp.web.HTTPInternalServerError: If there is an internal server error during the profile retrieval.
465458
"""
466459
pid = req.query.get("pid")
467460
ip = req.query.get("ip")
@@ -510,21 +503,18 @@ async def cpu_profile(self, req) -> aiohttp.web.Response:
510503
return aiohttp.web.HTTPInternalServerError(text=reply.output)
511504

512505
@routes.get("/memory_profile")
513-
async def memory_profile(self, req) -> aiohttp.web.Response:
514-
"""
515-
Retrieves the memory profile for a specific worker or task.
506+
async def memory_profile(self, req: aiohttp.web.Request) -> aiohttp.web.Response:
507+
"""Retrieves the memory profile for a specific worker or task.
516508
Note that for tasks, one worker process works on one task at a time
517509
or one worker works on multiple async tasks.
518510
519-
Args:
520-
req (aiohttp.web.Request): The HTTP request object.
521-
522511
Returns:
523512
aiohttp.web.Response: The HTTP response containing the memory profile data.
524513
525514
Params (1):
526515
pid: The PID of the worker.
527516
ip: The IP address of the node.
517+
528518
Params (2):
529519
task_id: The ID of the task.
530520
attempt_number: The attempt number of the task.
@@ -538,7 +528,7 @@ async def memory_profile(self, req) -> aiohttp.web.Response:
538528
or "node id" is missing in the request query.
539529
aiohttp.web.HTTPInternalServerError: If the maximum
540530
duration allowed is exceeded.
541-
aiohttp.web.HTTPInternalServerError If requesting task
531+
aiohttp.web.HTTPInternalServerError: If requesting task
542532
profiling for the worker begins working on another task
543533
during the profile retrieval.
544534
aiohttp.web.HTTPInternalServerError: If there is

0 commit comments

Comments
 (0)