OpenMined / KotlinSyft

The official Syft worker for secure on-device machine learning
https://www.openmined.org
Apache License 2.0
85 stars 28 forks source link

Unable to execute PySyft/examples/tutorials/model-centric-fl/Part 01 - Create Plan.ipynb #269

Closed chlw2123 closed 4 years ago

chlw2123 commented 4 years ago

Description

Hi KotlinSyft team,

I was trying to run the mentioned notebook but I encountered these errors instead when running it.

The error below happens with syft==0.2.7.

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-22da4773ebd0> in <module>
      6 from syft_proto.execution.v1.plan_pb2 import Plan as PlanPB
      7 from syft_proto.execution.v1.state_pb2 import State as StatePB
----> 8 from syft.grid.clients.model_centric_fl_client import ModelCentricFLClient
      9 from syft.execution.state import State
     10 from syft.execution.placeholder import PlaceHolder

ModuleNotFoundError: No module named 'syft.grid.clients.model_centric_fl_client'

While another error below happens with syft==0.2.8.

KeyError                                  Traceback (most recent call last)
<ipython-input-17-8a945e035458> in <module>
     12     server_averaging_plan=avg_plan,
     13     client_config=client_config,
---> 14     server_config=server_config
     15 )
     16 

~/anaconda3/envs/pysyft/lib/python3.7/site-packages/syft/grid/clients/model_centric_fl_client.py in host_federated_training(self, model, client_plans, client_protocols, client_config, server_averaging_plan, server_config)
    119         }
    120 
--> 121         return self._send_msg(message)
    122 
    123     def get_model(self, name, version, checkpoint="latest"):

~/anaconda3/envs/pysyft/lib/python3.7/site-packages/syft/grid/clients/model_centric_fl_client.py in _send_msg(self, message)
     49         json_response = json.loads(self.ws.recv())
     50 
---> 51         error = json_response["data"].get("error", None)
     52         if error is not None:
     53             raise GridError(error, None)

KeyError: 'data'

And the demo shows the error org.openmined.syft.execution.JobErrorThrowable$ExternalException: HTTP 401 UNAUTHORIZED

which I assumed is by caused the previous errors because I received an acknowledgement on PyGrid of a POST request INFO:geventwebsocket.handler:192.168.0.102 - - [2020-08-29 18:02:45] "POST /model-centric/authenticate HTTP/1.1" 401 223 0.005669

Please share the list of dependencies that work with the examples. Thank you so much.

vkkhare commented 4 years ago

Hi @chihan461 can you try using pysyft 0.2.8.

chlw2123 commented 4 years ago

Hi @vkkhare thanks for the follow up. However, I still encounter another error with syft 0.2.8

model_params_state = State(
    state_placeholders=[
        PlaceHolder().instantiate(param)
        for param in model_params
    ]
)

response = grid.host_federated_training(
    model=model_params_state,
    client_plans={'training_plan': training_plan},
    client_protocols={},
    server_averaging_plan=avg_plan,
    client_config=client_config,
    server_config=server_config
)

print("Host response:", response)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-17-8a945e035458> in <module>
     12     server_averaging_plan=avg_plan,
     13     client_config=client_config,
---> 14     server_config=server_config
     15 )
     16 

~/anaconda3/envs/pysyft/lib/python3.7/site-packages/syft/grid/clients/model_centric_fl_client.py in host_federated_training(self, model, client_plans, client_protocols, client_config, server_averaging_plan, server_config)
    119         }
    120 
--> 121         return self._send_msg(message)
    122 
    123     def get_model(self, name, version, checkpoint="latest"):

~/anaconda3/envs/pysyft/lib/python3.7/site-packages/syft/grid/clients/model_centric_fl_client.py in _send_msg(self, message)
     49         json_response = json.loads(self.ws.recv())
     50 
---> 51         error = json_response["data"].get("error", None)
     52         if error is not None:
     53             raise GridError(error, None)

KeyError: 'data'
chlw2123 commented 4 years ago

After testing again with a step-by-step manual from one of the forum member @jkimbf https://github.com/jkimbf/KotlinSyft-Manual, it worked.

vkkhare commented 4 years ago

Thanks for the reference. Yes we are fixing the compatibility changes occuring again and again. We will update the readme to use the latest pysyft when it's stable

stevejaehyeok commented 4 years ago

@vkkhare I would appreciate it if you could give an announcement in the Openmined Slack!