Skip to content

Commit 9531ed2

Browse files
committed
add flag to enable detailed timestamped logging
1 parent 3c41e56 commit 9531ed2

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

build/build.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ def add_global_arguments(parser: argparse.ArgumentParser):
123123
help="Produce verbose output for debugging.",
124124
)
125125

126+
parser.add_argument(
127+
"--detailed_timestamped_log",
128+
action="store_true",
129+
help="""
130+
Enable detailed logging of the Bazel command with timestamps. The logs
131+
will be stored and can be accessed as artifacts.
132+
""",
133+
)
134+
126135

127136
def add_artifact_subcommand_arguments(parser: argparse.ArgumentParser):
128137
"""Adds all the arguments that applies to the artifact subcommands."""
@@ -399,7 +408,7 @@ async def main():
399408
else:
400409
requirements_command.append("//build:requirements.update")
401410

402-
result = await executor.run(requirements_command.get_command_as_string(), args.dry_run)
411+
result = await executor.run(requirements_command.get_command_as_string(), args.dry_run, args.detailed_timestamped_log)
403412
if result.return_code != 0:
404413
raise RuntimeError(f"Command failed with return code {result.return_code}")
405414
else:
@@ -597,7 +606,7 @@ async def main():
597606

598607
wheel_build_command.append(f"--jaxlib_git_hash={git_hash}")
599608

600-
result = await executor.run(wheel_build_command.get_command_as_string(), args.dry_run)
609+
result = await executor.run(wheel_build_command.get_command_as_string(), args.dry_run, args.detailed_timestamped_log)
601610
# Exit with error if any wheel build fails.
602611
if result.return_code != 0:
603612
raise RuntimeError(f"Command failed with return code {result.return_code}")
@@ -607,4 +616,4 @@ async def main():
607616

608617

609618
if __name__ == "__main__":
610-
asyncio.run(main())
619+
asyncio.run(main())

build/tools/command.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, environment: Dict[str, str] = None):
7575
"""
7676
self.environment = environment or dict(os.environ)
7777

78-
async def run(self, cmd: str, dry_run: bool = False) -> CommandResult:
78+
async def run(self, cmd: str, dry_run: bool = False, detailed_timestamped_log: bool = False) -> CommandResult:
7979
"""
8080
Executes a subprocess command.
8181
@@ -96,14 +96,15 @@ async def run(self, cmd: str, dry_run: bool = False) -> CommandResult:
9696

9797
process = await asyncio.create_subprocess_shell(
9898
cmd,
99-
stdout=asyncio.subprocess.PIPE,
100-
stderr=asyncio.subprocess.PIPE,
99+
stdout=asyncio.subprocess.PIPE if detailed_timestamped_log else None,
100+
stderr=asyncio.subprocess.PIPE if detailed_timestamped_log else None,
101101
env=self.environment,
102102
)
103103

104-
await asyncio.gather(
105-
_process_log_stream(process.stdout, result), _process_log_stream(process.stderr, result)
106-
)
104+
if detailed_timestamped_log:
105+
await asyncio.gather(
106+
_process_log_stream(process.stdout, result), _process_log_stream(process.stderr, result)
107+
)
107108

108109
result.return_code = await process.wait()
109110
result.end_time = datetime.datetime.now()

ci/build_artifacts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if [[ "${allowed_artifacts[@]}" =~ "${artifact}" ]]; then
6969
fi
7070

7171
# Build the artifact.
72-
python build/build.py build --wheels="$artifact" --bazel_options=--config="$bazelrc_config" --python_version=$JAXCI_HERMETIC_PYTHON_VERSION --verbose
72+
python build/build.py build --wheels="$artifact" --bazel_options=--config="$bazelrc_config" --python_version=$JAXCI_HERMETIC_PYTHON_VERSION --verbose --detailed_timestamped_log
7373

7474
# If building `jaxlib` or `jax-cuda-plugin` or `jax-cuda-pjrt` for Linux, we
7575
# run `auditwheel show` to verify manylinux compliance.

0 commit comments

Comments
 (0)