Repository: ray-project/ray
File: python/ray/_private/worker.py (Python)

Code before:
        # Make sure that the value is not an object ref.
        if isinstance(value, ObjectRef):
            raise TypeError(
                "Calling 'put' on an ray.ObjectRef is not allowed. "
                "If you really want to do this, you can wrap the "
                "ray.ObjectRef in a list and call 'put' on it."
            )
        tensors = None
        from ray.experimental.gpu_object_manager.util import (
            normalize_and_validate_tensor_transport,
            validate_one_sided,
        )

        tensor_transport = None
        if _tensor_transport is not None:
            tensor_transport = normalize_and_validate_tensor_transport(
                _tensor_transport
            )
            validate_one_sided(tensor_transport, "ray.put")
        try:
            if tensor_transport is not None:
                (
                    serialized_value,
                    tensors,
                ) = self.get_serialization_context().serialize_gpu_objects(value)
            else:
                serialized_value = self.get_serialization_context().serialize(value)
        except TypeError as e:
            sio = io.StringIO()
            ray.util.inspect_serializability(value, print_file=sio)
            msg = (
                "Could not serialize the put value "
                f"{repr(value)}:\n"
                f"{sio.getvalue()}"
            )
            raise TypeError(msg) from e

        # If the object is mutable, then the raylet should never read the
        # object. Instead, clients will keep the object pinned.
        pin_object = not _is_experimental_channel

        # This *must* be the first place that we construct this python
        # ObjectRef because an entry with 0 local references is created when
        # the object is Put() in the core worker, expecting that this python
        # reference will be created. If another reference is created and
        # removed before this one, it will corrupt the state in the
        # reference counter.
        ret = self.core_worker.put_object(
            serialized_value,
            pin_object=pin_object,
            owner_address=owner_address,

Review comment (suggestion):
I am getting an error of "Traceback (most recent call last):
  File "python/ray/_raylet.pyx", line 2306, in ray._raylet.task_execution_handler
  File "python/ray/_raylet.pyx", line 2155, in ray._raylet.execute_task_with_cancellation_handler
  File "python/ray/_raylet.pyx", line 1800, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 1801, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 2048, in ray._raylet.execute_task
  File "python/ray/_raylet.pyx", line 1021, in ray._raylet.store_task_errors
  File "python/ray/_raylet.pyx", line 4298, in ray._raylet.CoreWorker.store_task_outputs
TypeError: SerializationContext.serialize_gpu_objects() missing 1 required positional argument: 'tensor_transport'"

Code after:
        # Make sure that the value is not an object ref.
        if isinstance(value, ObjectRef):
            raise TypeError(
                "Calling 'put' on an ray.ObjectRef is not allowed. "
                "If you really want to do this, you can wrap the "
                "ray.ObjectRef in a list and call 'put' on it."
            )
        tensors = None
        from ray.experimental.gpu_object_manager.util import (
            normalize_and_validate_tensor_transport,
            validate_one_sided,
        )

        tensor_transport = None
        if _tensor_transport is not None:
            tensor_transport = normalize_and_validate_tensor_transport(
                _tensor_transport
            )
            validate_one_sided(tensor_transport, "ray.put")
        try:
            if tensor_transport is not None:
                (
                    serialized_value,
                    tensors,
                ) = self.get_serialization_context().serialize_gpu_objects(
                    value, tensor_transport
                )
            else:
                serialized_value = self.get_serialization_context().serialize(value)
        except TypeError as e:
            sio = io.StringIO()
            ray.util.inspect_serializability(value, print_file=sio)
            msg = (
                "Could not serialize the put value "
                f"{repr(value)}:\n"
                f"{sio.getvalue()}"
            )
            raise TypeError(msg) from e

        # If the object is mutable, then the raylet should never read the
        # object. Instead, clients will keep the object pinned.
        pin_object = not _is_experimental_channel

        # This *must* be the first place that we construct this python
        # ObjectRef because an entry with 0 local references is created when
        # the object is Put() in the core worker, expecting that this python
        # reference will be created. If another reference is created and
        # removed before this one, it will corrupt the state in the
        # reference counter.
        ret = self.core_worker.put_object(
            serialized_value,