prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  modules install to also print/write `include` statements
  ### Description of feature
  
  print `include` statements to terminal for easy copy to destination files
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nf_core/modules/install.py`
  Content:
  ```
  1 import os
  2 import questionary
  3 import logging
  4 
  5 import nf_core.utils
  6 import nf_core.modules.module_utils
  7 
  8 from .modules_command import ModuleCommand
  9 from .module_utils import get_module_git_log, module_exist_in_repo
  10 
  11 log = logging.getLogger(__name__)
  12 
  13 
  14 class ModuleInstall(ModuleCommand):
  15     def __init__(self, pipeline_dir, force=False, prompt=False, sha=None, update_all=False):
  16         super().__init__(pipeline_dir)
  17         self.force = force
  18         self.prompt = prompt
  19         self.sha = sha
  20         self.update_all = update_all
  21 
  22     def install(self, module):
  23         if self.repo_type == "modules":
  24             log.error("You cannot install a module in a clone of nf-core/modules")
  25             return False
  26         # Check whether pipelines is valid
  27         if not self.has_valid_directory():
  28             return False
  29 
  30         # Verify that 'modules.json' is consistent with the installed modules
  31         self.modules_json_up_to_date()
  32 
  33         # Get the available modules
  34         try:
  35             self.modules_repo.get_modules_file_tree()
  36         except LookupError as e:
  37             log.error(e)
  38             return False
  39 
  40         if self.prompt and self.sha is not None:
  41             log.error("Cannot use '--sha' and '--prompt' at the same time!")
  42             return False
  43 
  44         # Verify that the provided SHA exists in the repo
  45         if self.sha:
  46             try:
  47                 nf_core.modules.module_utils.sha_exists(self.sha, self.modules_repo)
  48             except UserWarning:
  49                 log.error(f"Commit SHA '{self.sha}' doesn't exist in '{self.modules_repo.name}'")
  50                 return False
  51             except LookupError as e:
  52                 log.error(e)
  53                 return False
  54 
  55         if module is None:
  56             module = questionary.autocomplete(
  57                 "Tool name:",
  58                 choices=self.modules_repo.modules_avail_module_names,
  59                 style=nf_core.utils.nfcore_question_style,
  60             ).unsafe_ask()
  61 
  62         # Check that the supplied name is an available module
  63         if module and module not in self.modules_repo.modules_avail_module_names:
  64             log.error("Module '{}' not found in list of available modules.".format(module))
  65             log.info("Use the command 'nf-core modules list' to view available software")
  66             return False
  67 
  68         # Load 'modules.json'
  69         modules_json = self.load_modules_json()
  70         if not modules_json:
  71             return False
  72 
  73         if not module_exist_in_repo(module, self.modules_repo):
  74             warn_msg = f"Module '{module}' not found in remote '{self.modules_repo.name}' ({self.modules_repo.branch})"
  75             log.warning(warn_msg)
  76             return False
  77 
  78         if self.modules_repo.name in modules_json["repos"]:
  79             current_entry = modules_json["repos"][self.modules_repo.name].get(module)
  80         else:
  81             current_entry = None
  82 
  83         # Set the install folder based on the repository name
  84         install_folder = [self.dir, "modules", self.modules_repo.owner, self.modules_repo.repo]
  85 
  86         # Compute the module directory
  87         module_dir = os.path.join(*install_folder, module)
  88 
  89         # Check that the module is not already installed
  90         if (current_entry is not None and os.path.exists(module_dir)) and not self.force:
  91 
  92             log.error(f"Module is already installed.")
  93             repo_flag = "" if self.modules_repo.name == "nf-core/modules" else f"-g {self.modules_repo.name} "
  94             branch_flag = "" if self.modules_repo.branch == "master" else f"-b {self.modules_repo.branch} "
  95 
  96             log.info(
  97                 f"To update '{module}' run 'nf-core modules {repo_flag}{branch_flag}update {module}'. To force reinstallation use '--force'"
  98             )
  99             return False
  100 
  101         if self.sha:
  102             version = self.sha
  103         elif self.prompt:
  104             try:
  105                 version = nf_core.modules.module_utils.prompt_module_version_sha(
  106                     module,
  107                     installed_sha=current_entry["git_sha"] if not current_entry is None else None,
  108                     modules_repo=self.modules_repo,
  109                 )
  110             except SystemError as e:
  111                 log.error(e)
  112                 return False
  113         else:
  114             # Fetch the latest commit for the module
  115             try:
  116                 git_log = get_module_git_log(module, modules_repo=self.modules_repo, per_page=1, page_nbr=1)
  117             except UserWarning:
  118                 log.error(f"Was unable to fetch version of module '{module}'")
  119                 return False
  120             version = git_log[0]["git_sha"]
  121 
  122         if self.force:
  123             log.info(f"Removing installed version of '{self.modules_repo.name}/{module}'")
  124             self.clear_module_dir(module, module_dir)
  125 
  126         log.info(f"{'Rei' if self.force else 'I'}nstalling '{module}'")
  127         log.debug(f"Installing module '{module}' at modules hash {version} from {self.modules_repo.name}")
  128 
  129         # Download module files
  130         if not self.download_module_file(module, version, self.modules_repo, install_folder):
  131             return False
  132 
  133         # Update module.json with newly installed module
  134         self.update_modules_json(modules_json, self.modules_repo.name, module, version)
  135         return True
  136
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/nf_core/modules/install.py b/nf_core/modules/install.py
  --- a/nf_core/modules/install.py
  +++ b/nf_core/modules/install.py
  @@ -130,6 +130,10 @@
           if not self.download_module_file(module, version, self.modules_repo, install_folder):
               return False
   
  +        # Print include statement
  +        module_name = "_".join(module.upper().split("/"))
  +        log.info(f"Include statement: include {{ {module_name} }} from '.{os.path.join(*install_folder, module)}/main’")
  +
           # Update module.json with newly installed module
           self.update_modules_json(modules_json, self.modules_repo.name, module, version)
           return True
  
verification_info: {"golden_diff": "diff --git a/nf_core/modules/install.py b/nf_core/modules/install.py\n--- a/nf_core/modules/install.py\n+++ b/nf_core/modules/install.py\n@@ -130,6 +130,10 @@\n         if not self.download_module_file(module, version, self.modules_repo, install_folder):\n             return False\n \n+        # Print include statement\n+        module_name = \"_\".join(module.upper().split(\"/\"))\n+        log.info(f\"Include statement: include {{ {module_name} }} from '.{os.path.join(*install_folder, module)}/main\u2019\")\n+\n         # Update module.json with newly installed module\n         self.update_modules_json(modules_json, self.modules_repo.name, module, version)\n         return True\n", "issue": "modules install to also print/write `include` statements\n### Description of feature\n\nprint `include` statements to terminal for easy copy to destination files\n", "before_files": [{"content": "import os\nimport questionary\nimport logging\n\nimport nf_core.utils\nimport nf_core.modules.module_utils\n\nfrom .modules_command import ModuleCommand\nfrom .module_utils import get_module_git_log, module_exist_in_repo\n\nlog = logging.getLogger(__name__)\n\n\nclass ModuleInstall(ModuleCommand):\n    def __init__(self, pipeline_dir, force=False, prompt=False, sha=None, update_all=False):\n        super().__init__(pipeline_dir)\n        self.force = force\n        self.prompt = prompt\n        self.sha = sha\n        self.update_all = update_all\n\n    def install(self, module):\n        if self.repo_type == \"modules\":\n            log.error(\"You cannot install a module in a clone of nf-core/modules\")\n            return False\n        # Check whether pipelines is valid\n        if not self.has_valid_directory():\n            return False\n\n        # Verify that 'modules.json' is consistent with the installed modules\n        self.modules_json_up_to_date()\n\n        # Get the available modules\n        try:\n            self.modules_repo.get_modules_file_tree()\n        except LookupError as e:\n            log.error(e)\n            return False\n\n        if self.prompt and self.sha is not None:\n            log.error(\"Cannot use '--sha' and '--prompt' at the same time!\")\n            return False\n\n        # Verify that the provided SHA exists in the repo\n        if self.sha:\n            try:\n                nf_core.modules.module_utils.sha_exists(self.sha, self.modules_repo)\n            except UserWarning:\n                log.error(f\"Commit SHA '{self.sha}' doesn't exist in '{self.modules_repo.name}'\")\n                return False\n            except LookupError as e:\n                log.error(e)\n                return False\n\n        if module is None:\n            module = questionary.autocomplete(\n                \"Tool name:\",\n                choices=self.modules_repo.modules_avail_module_names,\n                style=nf_core.utils.nfcore_question_style,\n            ).unsafe_ask()\n\n        # Check that the supplied name is an available module\n        if module and module not in self.modules_repo.modules_avail_module_names:\n            log.error(\"Module '{}' not found in list of available modules.\".format(module))\n            log.info(\"Use the command 'nf-core modules list' to view available software\")\n            return False\n\n        # Load 'modules.json'\n        modules_json = self.load_modules_json()\n        if not modules_json:\n            return False\n\n        if not module_exist_in_repo(module, self.modules_repo):\n            warn_msg = f\"Module '{module}' not found in remote '{self.modules_repo.name}' ({self.modules_repo.branch})\"\n            log.warning(warn_msg)\n            return False\n\n        if self.modules_repo.name in modules_json[\"repos\"]:\n            current_entry = modules_json[\"repos\"][self.modules_repo.name].get(module)\n        else:\n            current_entry = None\n\n        # Set the install folder based on the repository name\n        install_folder = [self.dir, \"modules\", self.modules_repo.owner, self.modules_repo.repo]\n\n        # Compute the module directory\n        module_dir = os.path.join(*install_folder, module)\n\n        # Check that the module is not already installed\n        if (current_entry is not None and os.path.exists(module_dir)) and not self.force:\n\n            log.error(f\"Module is already installed.\")\n            repo_flag = \"\" if self.modules_repo.name == \"nf-core/modules\" else f\"-g {self.modules_repo.name} \"\n            branch_flag = \"\" if self.modules_repo.branch == \"master\" else f\"-b {self.modules_repo.branch} \"\n\n            log.info(\n                f\"To update '{module}' run 'nf-core modules {repo_flag}{branch_flag}update {module}'. To force reinstallation use '--force'\"\n            )\n            return False\n\n        if self.sha:\n            version = self.sha\n        elif self.prompt:\n            try:\n                version = nf_core.modules.module_utils.prompt_module_version_sha(\n                    module,\n                    installed_sha=current_entry[\"git_sha\"] if not current_entry is None else None,\n                    modules_repo=self.modules_repo,\n                )\n            except SystemError as e:\n                log.error(e)\n                return False\n        else:\n            # Fetch the latest commit for the module\n            try:\n                git_log = get_module_git_log(module, modules_repo=self.modules_repo, per_page=1, page_nbr=1)\n            except UserWarning:\n                log.error(f\"Was unable to fetch version of module '{module}'\")\n                return False\n            version = git_log[0][\"git_sha\"]\n\n        if self.force:\n            log.info(f\"Removing installed version of '{self.modules_repo.name}/{module}'\")\n            self.clear_module_dir(module, module_dir)\n\n        log.info(f\"{'Rei' if self.force else 'I'}nstalling '{module}'\")\n        log.debug(f\"Installing module '{module}' at modules hash {version} from {self.modules_repo.name}\")\n\n        # Download module files\n        if not self.download_module_file(module, version, self.modules_repo, install_folder):\n            return False\n\n        # Update module.json with newly installed module\n        self.update_modules_json(modules_json, self.modules_repo.name, module, version)\n        return True\n", "path": "nf_core/modules/install.py"}], "after_files": [{"content": "import os\nimport questionary\nimport logging\n\nimport nf_core.utils\nimport nf_core.modules.module_utils\n\nfrom .modules_command import ModuleCommand\nfrom .module_utils import get_module_git_log, module_exist_in_repo\n\nlog = logging.getLogger(__name__)\n\n\nclass ModuleInstall(ModuleCommand):\n    def __init__(self, pipeline_dir, force=False, prompt=False, sha=None, update_all=False):\n        super().__init__(pipeline_dir)\n        self.force = force\n        self.prompt = prompt\n        self.sha = sha\n        self.update_all = update_all\n\n    def install(self, module):\n        if self.repo_type == \"modules\":\n            log.error(\"You cannot install a module in a clone of nf-core/modules\")\n            return False\n        # Check whether pipelines is valid\n        if not self.has_valid_directory():\n            return False\n\n        # Verify that 'modules.json' is consistent with the installed modules\n        self.modules_json_up_to_date()\n\n        # Get the available modules\n        try:\n            self.modules_repo.get_modules_file_tree()\n        except LookupError as e:\n            log.error(e)\n            return False\n\n        if self.prompt and self.sha is not None:\n            log.error(\"Cannot use '--sha' and '--prompt' at the same time!\")\n            return False\n\n        # Verify that the provided SHA exists in the repo\n        if self.sha:\n            try:\n                nf_core.modules.module_utils.sha_exists(self.sha, self.modules_repo)\n            except UserWarning:\n                log.error(f\"Commit SHA '{self.sha}' doesn't exist in '{self.modules_repo.name}'\")\n                return False\n            except LookupError as e:\n                log.error(e)\n                return False\n\n        if module is None:\n            module = questionary.autocomplete(\n                \"Tool name:\",\n                choices=self.modules_repo.modules_avail_module_names,\n                style=nf_core.utils.nfcore_question_style,\n            ).unsafe_ask()\n\n        # Check that the supplied name is an available module\n        if module and module not in self.modules_repo.modules_avail_module_names:\n            log.error(\"Module '{}' not found in list of available modules.\".format(module))\n            log.info(\"Use the command 'nf-core modules list' to view available software\")\n            return False\n\n        # Load 'modules.json'\n        modules_json = self.load_modules_json()\n        if not modules_json:\n            return False\n\n        if not module_exist_in_repo(module, self.modules_repo):\n            warn_msg = f\"Module '{module}' not found in remote '{self.modules_repo.name}' ({self.modules_repo.branch})\"\n            log.warning(warn_msg)\n            return False\n\n        if self.modules_repo.name in modules_json[\"repos\"]:\n            current_entry = modules_json[\"repos\"][self.modules_repo.name].get(module)\n        else:\n            current_entry = None\n\n        # Set the install folder based on the repository name\n        install_folder = [self.dir, \"modules\", self.modules_repo.owner, self.modules_repo.repo]\n\n        # Compute the module directory\n        module_dir = os.path.join(*install_folder, module)\n\n        # Check that the module is not already installed\n        if (current_entry is not None and os.path.exists(module_dir)) and not self.force:\n\n            log.error(f\"Module is already installed.\")\n            repo_flag = \"\" if self.modules_repo.name == \"nf-core/modules\" else f\"-g {self.modules_repo.name} \"\n            branch_flag = \"\" if self.modules_repo.branch == \"master\" else f\"-b {self.modules_repo.branch} \"\n\n            log.info(\n                f\"To update '{module}' run 'nf-core modules {repo_flag}{branch_flag}update {module}'. To force reinstallation use '--force'\"\n            )\n            return False\n\n        if self.sha:\n            version = self.sha\n        elif self.prompt:\n            try:\n                version = nf_core.modules.module_utils.prompt_module_version_sha(\n                    module,\n                    installed_sha=current_entry[\"git_sha\"] if not current_entry is None else None,\n                    modules_repo=self.modules_repo,\n                )\n            except SystemError as e:\n                log.error(e)\n                return False\n        else:\n            # Fetch the latest commit for the module\n            try:\n                git_log = get_module_git_log(module, modules_repo=self.modules_repo, per_page=1, page_nbr=1)\n            except UserWarning:\n                log.error(f\"Was unable to fetch version of module '{module}'\")\n                return False\n            version = git_log[0][\"git_sha\"]\n\n        if self.force:\n            log.info(f\"Removing installed version of '{self.modules_repo.name}/{module}'\")\n            self.clear_module_dir(module, module_dir)\n\n        log.info(f\"{'Rei' if self.force else 'I'}nstalling '{module}'\")\n        log.debug(f\"Installing module '{module}' at modules hash {version} from {self.modules_repo.name}\")\n\n        # Download module files\n        if not self.download_module_file(module, version, self.modules_repo, install_folder):\n            return False\n\n        # Print include statement\n        module_name = \"_\".join(module.upper().split(\"/\"))\n        log.info(f\"Include statement: include {{ {module_name} }} from '.{os.path.join(*install_folder, module)}/main\u2019\")\n\n        # Update module.json with newly installed module\n        self.update_modules_json(modules_json, self.modules_repo.name, module, version)\n        return True\n", "path": "nf_core/modules/install.py"}]}