Skip to content

Commit 37ed591

Browse files
Extend build_developer.sh and git_sync_main.py with a -a flag. (#9319)
Co-authored-by: Zhanyong Wan <wan@google.com>
1 parent d82e15c commit 37ed591

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

scripts/build_developer.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ _SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
1717
_BUILD_BASE=torch_xla
1818

1919
# Parse commandline flags.
20-
while getopts 'b:ht' OPTION; do
20+
while getopts 'ab:ht' OPTION; do
2121
case $OPTION in
22+
a)
23+
_BUILD_BASE="pytorch"
24+
;;
2225
b)
2326
_BUILD_BASE=$OPTARG
2427
# Validate _BUILD_BASE.
@@ -31,9 +34,10 @@ while getopts 'b:ht' OPTION; do
3134
esac
3235
;;
3336
h)
34-
echo "Usage: $0 [-b <base_project>] [-t]"
37+
echo "Usage: $0 [-b <base_project>] [-a] [-t]"
3538
echo "where"
3639
echo " -b <base_project> selects which project to start the build from. <base_project> be pytorch, vision, or torch_xla (the default)."
40+
echo " -a (short for -b pytorch) builds all projects."
3741
echo " -t checks that the torch_xla and torchax libraries are built and installed successfully."
3842
exit 0
3943
;;

scripts/git_sync_main.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,35 @@ def main() -> None:
146146
help=('sync the given repo and all repos that depend on it; '
147147
'the default is torch_xla'),
148148
)
149+
arg_parser.add_argument(
150+
'--all',
151+
'-a',
152+
action='store_true',
153+
help=('sync all repos (pytorch, vision, and torch_xla); shorthand for '
154+
'--base_repo pytorch'),
155+
)
149156

150157
args = arg_parser.parse_args()
151158

152-
success = True
153-
if args.base_repo == _PYTORCH_REPO:
154-
if not sync_repo(_PYTORCH_REPO):
155-
success = False
159+
sync_pytorch = args.all or args.base_repo == _PYTORCH_REPO
160+
sync_vision = sync_pytorch or args.base_repo == _VISION_REPO
156161

157-
if args.base_repo in (_PYTORCH_REPO, _VISION_REPO):
158-
# The torchvision repo is optional, so skip it if it doesn't exist.
159-
if os.path.isdir(_VISION_DIR) and not sync_repo(_VISION_REPO):
160-
success = False
162+
failed_repos: list[str] = []
163+
if sync_pytorch and not sync_repo(_PYTORCH_REPO):
164+
failed_repos.append(_PYTORCH_REPO)
165+
166+
if (sync_vision and
167+
# The torchvision repo is optional, so skip it if it doesn't exist.
168+
os.path.isdir(_VISION_DIR) and not sync_repo(_VISION_REPO)):
169+
failed_repos.append(_VISION_REPO)
161170

162171
if not sync_repo(_TORCH_XLA_REPO):
163-
success = False
172+
failed_repos.append(_TORCH_XLA_REPO)
164173

165-
if not success:
166-
logger.error('Failed to sync some repos.')
174+
# Print the failed repos last, so that the error is not buried in
175+
# the middle of the messages.
176+
if failed_repos:
177+
logger.error(f'Failed to sync repos: {", ".join(failed_repos)}.')
167178
sys.exit(1)
168179

169180
logger.info('All repos synced successfully.')

0 commit comments

Comments
 (0)