prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Calling syft.grid.register() twice should throw an informative error
  **Is your feature request related to a problem? Please describe.**
  If you call syft.grid.register() twice in the same python runtime it should raise an error describing that you can't do this - that they shoudl restart the python runtime and try again.
  
  </issue>
  <code>
  [start of syft/grid/__init__.py]
  1 from .network import Network
  2 import sys
  3 import uuid
  4 
  5 DEFAULT_NETWORK_URL = "ws://ec2-13-59-45-128.us-east-2.compute.amazonaws.com"
  6 
  7 
  8 def register(**kwargs):
  9     """ Add this process as a new peer registering it in the grid network.
  10         
  11         Returns:
  12             peer: Peer Network instance.
  13     """
  14     try:
  15         if not kwargs:
  16             args = {"max_size": None, "timeout": 444, "url": DEFAULT_NETWORK_URL}
  17         else:
  18             args = kwargs
  19 
  20         peer_id = str(uuid.uuid4())
  21         sys.stdout.write(
  22             "Connecting to OpenGrid (" + "\033[94m" + args["url"] + "\033[0m" + ") ... "
  23         )
  24 
  25         peer = Network(peer_id, **args)
  26 
  27         sys.stdout.write("\033[92m" + "OK" + "\033[0m" + "\n")
  28         sys.stdout.write("Peer ID: " + peer_id + "\n")
  29 
  30         sys.stdout.write(
  31             "\033[93m" + "DISCLAIMER" + "\033[0m"
  32             ":"
  33             + "\033[1m"
  34             + " OpenGrid is an experimental feature currently in alpha. Do not use this to protect real-world data.\n"
  35             + "\033[0m"
  36         )
  37 
  38         sys.stdout.write("Where to get help: \n")
  39         sys.stdout.write(
  40             " - Join our slack  (https://slack.openmined.org) and ask for help in the #lib_syft channel.\n"
  41         )
  42         sys.stdout.write(
  43             " - File a Github Issue: https://github.com/OpenMined/PySyft and add the string '#opengrid' in the issue title.\n"
  44         )
  45         sys.stdout.write(
  46             " - Want to join in our development team? Apply here: https://forms.gle/wcH1vxzvPyDSbSVW6\n"
  47         )
  48         peer.start()
  49         return peer
  50     except Exception as e:
  51         sys.stdout.write("\033[91m" + "FAIL" + "\033[0m" + "\n")
  52         sys.stdout.write("You were not able to register your node.\n")
  53
  [end of syft/grid/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/syft/grid/__init__.py b/syft/grid/__init__.py
  --- a/syft/grid/__init__.py
  +++ b/syft/grid/__init__.py
  @@ -4,13 +4,25 @@
   
   DEFAULT_NETWORK_URL = "ws://ec2-13-59-45-128.us-east-2.compute.amazonaws.com"
   
  +_registered_peer = None
  +
   
   def register(**kwargs):
       """ Add this process as a new peer registering it in the grid network.
  -        
  +
           Returns:
               peer: Peer Network instance.
       """
  +    global _registered_peer
  +
  +    if isinstance(_registered_peer, Network):
  +        sys.stdout.write(
  +            "\033[93m" + "WARNING" + "\033[0m"
  +            ":" + f" You are already a registered peer!\n{_registered_peer}\n"
  +        )
  +
  +        return _registered_peer
  +
       try:
           if not kwargs:
               args = {"max_size": None, "timeout": 444, "url": DEFAULT_NETWORK_URL}
  @@ -22,7 +34,7 @@
               "Connecting to OpenGrid (" + "\033[94m" + args["url"] + "\033[0m" + ") ... "
           )
   
  -        peer = Network(peer_id, **args)
  +        _registered_peer = Network(peer_id, **args)
   
           sys.stdout.write("\033[92m" + "OK" + "\033[0m" + "\n")
           sys.stdout.write("Peer ID: " + peer_id + "\n")
  @@ -45,8 +57,11 @@
           sys.stdout.write(
               " - Want to join in our development team? Apply here: https://forms.gle/wcH1vxzvPyDSbSVW6\n"
           )
  -        peer.start()
  -        return peer
  +
  +        _registered_peer.start()
  +
  +        return _registered_peer
  +
       except Exception as e:
           sys.stdout.write("\033[91m" + "FAIL" + "\033[0m" + "\n")
           sys.stdout.write("You were not able to register your node.\n")
  
verification_info: {"golden_diff": "diff --git a/syft/grid/__init__.py b/syft/grid/__init__.py\n--- a/syft/grid/__init__.py\n+++ b/syft/grid/__init__.py\n@@ -4,13 +4,25 @@\n \n DEFAULT_NETWORK_URL = \"ws://ec2-13-59-45-128.us-east-2.compute.amazonaws.com\"\n \n+_registered_peer = None\n+\n \n def register(**kwargs):\n     \"\"\" Add this process as a new peer registering it in the grid network.\n-        \n+\n         Returns:\n             peer: Peer Network instance.\n     \"\"\"\n+    global _registered_peer\n+\n+    if isinstance(_registered_peer, Network):\n+        sys.stdout.write(\n+            \"\\033[93m\" + \"WARNING\" + \"\\033[0m\"\n+            \":\" + f\" You are already a registered peer!\\n{_registered_peer}\\n\"\n+        )\n+\n+        return _registered_peer\n+\n     try:\n         if not kwargs:\n             args = {\"max_size\": None, \"timeout\": 444, \"url\": DEFAULT_NETWORK_URL}\n@@ -22,7 +34,7 @@\n             \"Connecting to OpenGrid (\" + \"\\033[94m\" + args[\"url\"] + \"\\033[0m\" + \") ... \"\n         )\n \n-        peer = Network(peer_id, **args)\n+        _registered_peer = Network(peer_id, **args)\n \n         sys.stdout.write(\"\\033[92m\" + \"OK\" + \"\\033[0m\" + \"\\n\")\n         sys.stdout.write(\"Peer ID: \" + peer_id + \"\\n\")\n@@ -45,8 +57,11 @@\n         sys.stdout.write(\n             \" - Want to join in our development team? Apply here: https://forms.gle/wcH1vxzvPyDSbSVW6\\n\"\n         )\n-        peer.start()\n-        return peer\n+\n+        _registered_peer.start()\n+\n+        return _registered_peer\n+\n     except Exception as e:\n         sys.stdout.write(\"\\033[91m\" + \"FAIL\" + \"\\033[0m\" + \"\\n\")\n         sys.stdout.write(\"You were not able to register your node.\\n\")\n", "issue": "Calling syft.grid.register() twice should throw an informative error\n**Is your feature request related to a problem? Please describe.**\r\nIf you call syft.grid.register() twice in the same python runtime it should raise an error describing that you can't do this - that they shoudl restart the python runtime and try again.\n", "before_files": [{"content": "from .network import Network\nimport sys\nimport uuid\n\nDEFAULT_NETWORK_URL = \"ws://ec2-13-59-45-128.us-east-2.compute.amazonaws.com\"\n\n\ndef register(**kwargs):\n    \"\"\" Add this process as a new peer registering it in the grid network.\n        \n        Returns:\n            peer: Peer Network instance.\n    \"\"\"\n    try:\n        if not kwargs:\n            args = {\"max_size\": None, \"timeout\": 444, \"url\": DEFAULT_NETWORK_URL}\n        else:\n            args = kwargs\n\n        peer_id = str(uuid.uuid4())\n        sys.stdout.write(\n            \"Connecting to OpenGrid (\" + \"\\033[94m\" + args[\"url\"] + \"\\033[0m\" + \") ... \"\n        )\n\n        peer = Network(peer_id, **args)\n\n        sys.stdout.write(\"\\033[92m\" + \"OK\" + \"\\033[0m\" + \"\\n\")\n        sys.stdout.write(\"Peer ID: \" + peer_id + \"\\n\")\n\n        sys.stdout.write(\n            \"\\033[93m\" + \"DISCLAIMER\" + \"\\033[0m\"\n            \":\"\n            + \"\\033[1m\"\n            + \" OpenGrid is an experimental feature currently in alpha. Do not use this to protect real-world data.\\n\"\n            + \"\\033[0m\"\n        )\n\n        sys.stdout.write(\"Where to get help: \\n\")\n        sys.stdout.write(\n            \" - Join our slack  (https://slack.openmined.org) and ask for help in the #lib_syft channel.\\n\"\n        )\n        sys.stdout.write(\n            \" - File a Github Issue: https://github.com/OpenMined/PySyft and add the string '#opengrid' in the issue title.\\n\"\n        )\n        sys.stdout.write(\n            \" - Want to join in our development team? Apply here: https://forms.gle/wcH1vxzvPyDSbSVW6\\n\"\n        )\n        peer.start()\n        return peer\n    except Exception as e:\n        sys.stdout.write(\"\\033[91m\" + \"FAIL\" + \"\\033[0m\" + \"\\n\")\n        sys.stdout.write(\"You were not able to register your node.\\n\")\n", "path": "syft/grid/__init__.py"}]}