MCPcopy Create free account
hub / github.com/pytorch/executorch / check_and_update_submodules

Function check_and_update_submodules

install_executorch.py:132–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130
131
132def check_and_update_submodules():
133 def check_folder(folder: str, file: str) -> bool:
134 return os.path.isdir(folder) and os.path.isfile(os.path.join(folder, file))
135
136 # Check if the directories exist for each required submodule
137 missing_submodules = {}
138 for path, file in get_required_submodule_paths().items():
139 if not check_folder(path, file):
140 missing_submodules[path] = file
141
142 # If any required submodule directories are missing, update them
143 if missing_submodules:
144 logger.warning("Some required submodules are missing. Updating submodules...")
145 try:
146 subprocess.check_call(["git", "submodule", "sync", "--recursive"])
147 subprocess.check_call(
148 ["git", "submodule", "update", "--init", "--recursive"]
149 )
150 except subprocess.CalledProcessError as e:
151 logger.error(f"Error updating submodules: {e}")
152 exit(1)
153
154 # After updating submodules, check again
155 for path, file in missing_submodules.items():
156 if not check_folder(path, file):
157 logger.error(f"{file} not found in {path}.")
158 logger.error(
159 "Submodule update failed. Please run `git submodule update --init --recursive` manually."
160 )
161 exit(1)
162 logger.info("All required submodules are present.")
163
164
165def _parse_args() -> argparse.Namespace:

Callers 1

mainFunction · 0.85

Calls 4

check_folderFunction · 0.85
itemsMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected