Skip to content

Commit e21ce19

Browse files
committed
rename checkpoint_upload_function -> checkpoint_upload_fn
Signed-off-by: Timothy Seah <tseah@anyscale.com>
1 parent b277643 commit e21ce19

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

python/ray/train/v2/_internal/execution/context.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def _upload_checkpoint(
228228
metrics: Dict[str, Any],
229229
checkpoint: Optional["Checkpoint"] = None,
230230
delete_local_checkpoint_after_upload: bool = False,
231-
checkpoint_upload_function: Optional[
231+
checkpoint_upload_fn: Optional[
232232
Callable[["Checkpoint", str], "Checkpoint"]
233233
] = None,
234234
validation_spec: Optional[_ValidationSpec] = None,
@@ -240,7 +240,7 @@ def _upload_checkpoint(
240240
metrics: The metrics to report.
241241
checkpoint: The checkpoint to report.
242242
delete_local_checkpoint_after_upload: Whether to delete the checkpoint after it is uploaded.
243-
checkpoint_upload_function: A user defined function that will be called with the
243+
checkpoint_upload_fn: A user defined function that will be called with the
244244
checkpoint to upload it. If not provided, defaults to using the `pyarrow.fs.copy_files`
245245
utility for copying to the destination `storage_path`.
246246
validation_spec: The validation specification.
@@ -256,8 +256,8 @@ def _upload_checkpoint(
256256

257257
# Persist the checkpoint to the remote storage path.
258258
try:
259-
if checkpoint_upload_function:
260-
persisted_checkpoint = checkpoint_upload_function(
259+
if checkpoint_upload_fn:
260+
persisted_checkpoint = checkpoint_upload_fn(
261261
checkpoint, checkpoint_dir_name
262262
)
263263
else:
@@ -321,7 +321,7 @@ def report(
321321
checkpoint_dir_name: Optional[str] = None,
322322
checkpoint_upload_mode: CheckpointUploadMode = CheckpointUploadMode.SYNC,
323323
delete_local_checkpoint_after_upload: Optional[bool] = None,
324-
checkpoint_upload_function: Optional[
324+
checkpoint_upload_fn: Optional[
325325
Callable[["Checkpoint", str], "Checkpoint"]
326326
] = None,
327327
validate_fn: Optional[Callable[["Checkpoint", Optional[Dict]], Dict]] = None,
@@ -376,7 +376,7 @@ def report(
376376
metrics,
377377
checkpoint,
378378
delete_local_checkpoint_after_upload,
379-
checkpoint_upload_function,
379+
checkpoint_upload_fn,
380380
validation_spec,
381381
)
382382
self._wait_then_report(training_report, report_call_index)
@@ -403,7 +403,7 @@ def _upload_checkpoint_and_report(
403403
metrics,
404404
checkpoint,
405405
delete_local_checkpoint_after_upload,
406-
checkpoint_upload_function,
406+
checkpoint_upload_fn,
407407
validation_spec,
408408
)
409409
self._wait_then_report(training_report, report_call_index)

python/ray/train/v2/_internal/execution/train_fn_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def report(
3939
checkpoint_dir_name: Optional[str] = None,
4040
checkpoint_upload_mode: CheckpointUploadMode = CheckpointUploadMode.SYNC,
4141
delete_local_checkpoint_after_upload: Optional[bool] = None,
42-
checkpoint_upload_function: Optional[
42+
checkpoint_upload_fn: Optional[
4343
Callable[["Checkpoint", str], "Checkpoint"]
4444
] = None,
4545
validate_fn: Optional[Callable[["Checkpoint", Optional[Dict]], Dict]] = None,
@@ -58,7 +58,7 @@ def report(
5858
Defaults to uploading the checkpoint synchronously.
5959
This works when no checkpoint is provided but is not useful in that case.
6060
delete_local_checkpoint_after_upload: Whether to delete the checkpoint after it is uploaded.
61-
checkpoint_upload_function: A user defined function that will be called with the
61+
checkpoint_upload_fn: A user defined function that will be called with the
6262
checkpoint to upload it. If not provided, defaults to using the `pyarrow.fs.copy_files`
6363
utility for copying to the destination `storage_path`.
6464
validate_fn: If provided, Ray Train will validate the checkpoint using
@@ -142,7 +142,7 @@ def report(
142142
checkpoint_dir_name: Optional[str] = None,
143143
checkpoint_upload_mode: CheckpointUploadMode = CheckpointUploadMode.SYNC,
144144
delete_local_checkpoint_after_upload: Optional[bool] = None,
145-
checkpoint_upload_function: Optional[
145+
checkpoint_upload_fn: Optional[
146146
Callable[["Checkpoint", str], "Checkpoint"]
147147
] = None,
148148
validate_fn: Optional[Callable[["Checkpoint", Optional[Dict]], Dict]] = None,
@@ -154,7 +154,7 @@ def report(
154154
checkpoint_dir_name,
155155
checkpoint_upload_mode,
156156
delete_local_checkpoint_after_upload,
157-
checkpoint_upload_function,
157+
checkpoint_upload_fn,
158158
validate_fn,
159159
validate_config,
160160
)
@@ -211,7 +211,7 @@ def report(
211211
checkpoint_dir_name: Optional[str] = None,
212212
checkpoint_upload_mode: CheckpointUploadMode = CheckpointUploadMode.SYNC,
213213
delete_local_checkpoint_after_upload: Optional[bool] = None,
214-
checkpoint_upload_function: Optional[
214+
checkpoint_upload_fn: Optional[
215215
Callable[["Checkpoint", str], "Checkpoint"]
216216
] = None,
217217
validate_fn: Optional[Callable[["Checkpoint", Optional[Dict]], Dict]] = None,

python/ray/train/v2/api/train_fn_utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ def report(
1919
checkpoint_dir_name: Optional[str] = None,
2020
checkpoint_upload_mode: CheckpointUploadMode = CheckpointUploadMode.SYNC,
2121
delete_local_checkpoint_after_upload: Optional[bool] = None,
22-
checkpoint_upload_function: Optional[
23-
Callable[["Checkpoint", str], "Checkpoint"]
24-
] = None,
22+
checkpoint_upload_fn: Optional[Callable[["Checkpoint", str], "Checkpoint"]] = None,
2523
validate_fn: Optional[Callable[["Checkpoint", Optional[Dict]], Dict]] = None,
2624
validate_config: Optional[Dict] = None,
2725
):
@@ -100,7 +98,7 @@ def train_func(config):
10098
Defaults to uploading the checkpoint synchronously.
10199
This works when no checkpoint is provided but is not useful in that case.
102100
delete_local_checkpoint_after_upload: Whether to delete the checkpoint after it is uploaded.
103-
checkpoint_upload_function: A user defined function that will be called with the
101+
checkpoint_upload_fn: A user defined function that will be called with the
104102
checkpoint to upload it. If not provided, defaults to using the `pyarrow.fs.copy_files`
105103
utility for copying to the destination `storage_path`.
106104
validate_fn: If provided, Ray Train will validate the checkpoint using
@@ -123,7 +121,7 @@ def train_func(config):
123121
checkpoint_dir_name=checkpoint_dir_name,
124122
checkpoint_upload_mode=checkpoint_upload_mode,
125123
delete_local_checkpoint_after_upload=delete_local_checkpoint_after_upload,
126-
checkpoint_upload_function=checkpoint_upload_function,
124+
checkpoint_upload_fn=checkpoint_upload_fn,
127125
validate_fn=validate_fn,
128126
validate_config=validate_config or {},
129127
)

python/ray/train/v2/tests/test_async_checkpointing_validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ def train_fn():
331331
assert len(result.best_checkpoints) == 2
332332

333333

334-
def test_report_checkpoint_upload_function(tmp_path):
335-
def checkpoint_upload_function(checkpoint, checkpoint_dir_name):
334+
def test_report_checkpoint_upload_fn(tmp_path):
335+
def checkpoint_upload_fn(checkpoint, checkpoint_dir_name):
336336
full_checkpoint_path = (
337337
ray.train.get_context()
338338
.get_storage()
@@ -350,7 +350,7 @@ def train_fn():
350350
metrics={},
351351
checkpoint=checkpoint,
352352
checkpoint_dir_name="my_checkpoint_dir_name",
353-
checkpoint_upload_function=checkpoint_upload_function,
353+
checkpoint_upload_fn=checkpoint_upload_fn,
354354
)
355355
else:
356356
ray.train.report(metrics={}, checkpoint=None)

0 commit comments

Comments
 (0)