mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 21:12:15 +08:00
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import ray
|
|
|
|
|
|
def force_spill_objects(object_refs):
|
|
"""Force spilling objects to external storage.
|
|
|
|
Args:
|
|
object_refs: Object refs of the objects to be
|
|
spilled.
|
|
"""
|
|
core_worker = ray.worker.global_worker.core_worker
|
|
# Make sure that the values are object refs.
|
|
for object_ref in object_refs:
|
|
if not isinstance(object_ref, ray.ObjectRef):
|
|
raise TypeError(
|
|
f"Attempting to call `force_spill_objects` on the "
|
|
f"value {object_ref}, which is not an ray.ObjectRef.")
|
|
return core_worker.force_spill_objects(object_refs)
|
|
|
|
|
|
def force_restore_spilled_objects(object_refs):
|
|
"""Force restoring objects from external storage.
|
|
|
|
Args:
|
|
object_refs: Object refs of the objects to be
|
|
restored.
|
|
"""
|
|
core_worker = ray.worker.global_worker.core_worker
|
|
# Make sure that the values are object refs.
|
|
for object_ref in object_refs:
|
|
if not isinstance(object_ref, ray.ObjectRef):
|
|
raise TypeError(
|
|
f"Attempting to call `force_restore_spilled_objects` on the "
|
|
f"value {object_ref}, which is not an ray.ObjectRef.")
|
|
return core_worker.force_restore_spilled_objects(object_refs)
|