prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Unable to run poc command if nvflare is installed by pip install -e .
  
  
  </issue>
  <code>
  [start of nvflare/lighter/poc.py]
  1 # Copyright (c) 2021-2022, NVIDIA CORPORATION.  All rights reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import argparse
  16 import os
  17 import pathlib
  18 import shutil
  19 
  20 
  21 def clone_client(num_clients: int):
  22     current_path = os.getcwd()
  23     poc_folder = os.path.join(current_path, "poc")
  24     src_folder = os.path.join(poc_folder, "client")
  25     for index in range(1, num_clients + 1):
  26         dst_folder = os.path.join(poc_folder, f"site-{index}")
  27         shutil.copytree(src_folder, dst_folder)
  28         start_sh = open(os.path.join(dst_folder, "startup", "start.sh"), "rt")
  29         content = start_sh.read()
  30         start_sh.close()
  31         content = content.replace("NNN", f"{index}")
  32         with open(os.path.join(dst_folder, "startup", "start.sh"), "wt") as f:
  33             f.write(content)
  34     shutil.rmtree(src_folder)
  35 
  36 
  37 def main():
  38     parser = argparse.ArgumentParser()
  39     parser.add_argument("-n", "--num_clients", type=int, default=1, help="number of client folders to create")
  40 
  41     args = parser.parse_args()
  42 
  43     file_dir_path = pathlib.Path(__file__).parent.absolute()
  44     poc_zip_path = file_dir_path.parent / "poc.zip"
  45     answer = input("This will delete poc folder in current directory and create a new one. Is it OK to proceed? (y/N) ")
  46     if answer.strip().upper() == "Y":
  47         dest_poc_folder = os.path.join(os.getcwd(), "poc")
  48         shutil.rmtree(dest_poc_folder, ignore_errors=True)
  49         shutil.unpack_archive(poc_zip_path)
  50         for root, dirs, files in os.walk(dest_poc_folder):
  51             for file in files:
  52                 if file.endswith(".sh"):
  53                     os.chmod(os.path.join(root, file), 0o755)
  54         clone_client(args.num_clients)
  55         print("Successfully creating poc folder.  Please read poc/Readme.rst for user guide.")
  56 
  57 
  58 if __name__ == "__main__":
  59     main()
  60
  [end of nvflare/lighter/poc.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/nvflare/lighter/poc.py b/nvflare/lighter/poc.py
  --- a/nvflare/lighter/poc.py
  +++ b/nvflare/lighter/poc.py
  @@ -42,11 +42,20 @@
   
       file_dir_path = pathlib.Path(__file__).parent.absolute()
       poc_zip_path = file_dir_path.parent / "poc.zip"
  +    poc_folder_path = file_dir_path.parent / "poc"
       answer = input("This will delete poc folder in current directory and create a new one. Is it OK to proceed? (y/N) ")
       if answer.strip().upper() == "Y":
           dest_poc_folder = os.path.join(os.getcwd(), "poc")
           shutil.rmtree(dest_poc_folder, ignore_errors=True)
  -        shutil.unpack_archive(poc_zip_path)
  +        try:
  +            shutil.unpack_archive(poc_zip_path)
  +        except shutil.ReadError:
  +            print(f"poc.zip not found at {poc_zip_path}, try to use template poc folder")
  +            try:
  +                shutil.copytree(poc_folder_path, dest_poc_folder)
  +            except BaseException:
  +                print(f"Unable to copy poc folder from {poc_folder_path}.  Exit")
  +                exit(1)
           for root, dirs, files in os.walk(dest_poc_folder):
               for file in files:
                   if file.endswith(".sh"):
  
verification_info: {"golden_diff": "diff --git a/nvflare/lighter/poc.py b/nvflare/lighter/poc.py\n--- a/nvflare/lighter/poc.py\n+++ b/nvflare/lighter/poc.py\n@@ -42,11 +42,20 @@\n \n     file_dir_path = pathlib.Path(__file__).parent.absolute()\n     poc_zip_path = file_dir_path.parent / \"poc.zip\"\n+    poc_folder_path = file_dir_path.parent / \"poc\"\n     answer = input(\"This will delete poc folder in current directory and create a new one. Is it OK to proceed? (y/N) \")\n     if answer.strip().upper() == \"Y\":\n         dest_poc_folder = os.path.join(os.getcwd(), \"poc\")\n         shutil.rmtree(dest_poc_folder, ignore_errors=True)\n-        shutil.unpack_archive(poc_zip_path)\n+        try:\n+            shutil.unpack_archive(poc_zip_path)\n+        except shutil.ReadError:\n+            print(f\"poc.zip not found at {poc_zip_path}, try to use template poc folder\")\n+            try:\n+                shutil.copytree(poc_folder_path, dest_poc_folder)\n+            except BaseException:\n+                print(f\"Unable to copy poc folder from {poc_folder_path}.  Exit\")\n+                exit(1)\n         for root, dirs, files in os.walk(dest_poc_folder):\n             for file in files:\n                 if file.endswith(\".sh\"):\n", "issue": "Unable to run poc command if nvflare is installed by pip install -e .\n\n", "before_files": [{"content": "# Copyright (c) 2021-2022, NVIDIA CORPORATION.  All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport argparse\nimport os\nimport pathlib\nimport shutil\n\n\ndef clone_client(num_clients: int):\n    current_path = os.getcwd()\n    poc_folder = os.path.join(current_path, \"poc\")\n    src_folder = os.path.join(poc_folder, \"client\")\n    for index in range(1, num_clients + 1):\n        dst_folder = os.path.join(poc_folder, f\"site-{index}\")\n        shutil.copytree(src_folder, dst_folder)\n        start_sh = open(os.path.join(dst_folder, \"startup\", \"start.sh\"), \"rt\")\n        content = start_sh.read()\n        start_sh.close()\n        content = content.replace(\"NNN\", f\"{index}\")\n        with open(os.path.join(dst_folder, \"startup\", \"start.sh\"), \"wt\") as f:\n            f.write(content)\n    shutil.rmtree(src_folder)\n\n\ndef main():\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"-n\", \"--num_clients\", type=int, default=1, help=\"number of client folders to create\")\n\n    args = parser.parse_args()\n\n    file_dir_path = pathlib.Path(__file__).parent.absolute()\n    poc_zip_path = file_dir_path.parent / \"poc.zip\"\n    answer = input(\"This will delete poc folder in current directory and create a new one. Is it OK to proceed? (y/N) \")\n    if answer.strip().upper() == \"Y\":\n        dest_poc_folder = os.path.join(os.getcwd(), \"poc\")\n        shutil.rmtree(dest_poc_folder, ignore_errors=True)\n        shutil.unpack_archive(poc_zip_path)\n        for root, dirs, files in os.walk(dest_poc_folder):\n            for file in files:\n                if file.endswith(\".sh\"):\n                    os.chmod(os.path.join(root, file), 0o755)\n        clone_client(args.num_clients)\n        print(\"Successfully creating poc folder.  Please read poc/Readme.rst for user guide.\")\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "nvflare/lighter/poc.py"}]}