PySyft icon indicating copy to clipboard operation
PySyft copied to clipboard

Small correction in Sample Code Block of sy.core.pointer.pointer

Open rajatrc1705 opened this issue 5 years ago • 2 comments

Where?

Where are you looking to add documentation? Which file? Which feature?

In directory PySyft/src/syft/core/pointer directory, there is a python file, pointer.py. The example code in the python file can be viewed by the user by executing the following command:

import syft as sy sy.core.pointer.pointer?

The example code in the output of above command is as follows:

Example:

.. code-block::

# creating the data holder domain
domain_1 = Domain(name="Data holder domain")

# creating dummy data
tensor = th.tensor([1, 2, 3])

# creating the data holder client
domain_1_client = domain_1.get_root_client()

# sending the data to the client and receiving a pointer of that data.
data_ptr_domain_1 = tensor.send(domain_1_client) # or tensor.send_to(domain_1_client)

# creating the data user domain
domain_2 = Domain(name="Data user domain")

# creating a request to access the data
data_ptr_domain_1.request(
    name="My Request", reason="I'd lke to see this pointer"
)

# getting the remote id of the object
requested_object = data_ptr_domain_1.id_at_location

message_request_id = domain_1_client.request_queue.get_request_id_from_object_id(
    object_id=requested_object
)

# the data holder accepts the request
domain_1.requests[0].owner_client_if_available = domain_1_client
domain_1.requests[0].accept()

# the data user checks if the data holder approved his request
response = data_ptr_domain_1.check_access(node=domain_2, request_id=message_request_id)

The following line is where the issue is:

getting the request id

message_request_id = domain_1_client.request_queue.get_request_id_from_object_id(
    object_id=requested_object
)

Error Generated by the line is:

AttributeError: 'DomainClient' object has no attribute 'request_queue'

Solution :

Replacing "request_queue" to "requests" solves the issue.

rajatrc1705 avatar Dec 15 '20 08:12 rajatrc1705

Can I do the corrections in the documentation for this issue?

rajatrc1705 avatar Dec 15 '20 08:12 rajatrc1705

@rajatrc1705 good spot, thank you! 👍🏼

madhavajay avatar Dec 16 '20 03:12 madhavajay