Skip to content

Commit 0d378b7

Browse files
raytomatoliboyue
andcommitted
Fix CI pre-commit check failure. (#1195)
* Fix CI and add memory monitoring * minor scripts improvements * Update .github/workflows/pre-commit.yml resolve boyue's comment. Co-authored-by: Boyue Li <[email protected]> * make monitor process non-critical upon failure --------- Co-authored-by: Boyue Li <[email protected]>
1 parent 2146b74 commit 0d378b7

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

.github/scripts/monitor_memory.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Simple memory monitor that prints to console periodically.
3+
# Designed for GitHub Actions monitoring.
4+
5+
INFO="\033[90m"
6+
RESET="\033[0m"
7+
8+
echo -e "${INFO}====== Starting memory monitor at $(date) ======${RESET}"
9+
10+
while true; do
11+
# Get current timestamp
12+
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
13+
14+
echo ""
15+
echo -e "${INFO}=== Memory Check: $timestamp ===${RESET}"
16+
17+
# Print simplified memory stats.
18+
free -h | grep "Mem:" | awk "{printf \"${INFO}Memory: %s used, %s free, %s total\n${RESET}\", \$3, \$4, \$2}"
19+
20+
# Print memory usage percentage.
21+
mem_total=$(free | grep Mem | awk '{print $2}')
22+
mem_used=$(free | grep Mem | awk '{print $3}')
23+
mem_percent=$(awk "BEGIN {printf \"%.1f\", $mem_used/$mem_total*100}")
24+
echo -e "${INFO}Memory usage: $mem_percent%${RESET}"
25+
26+
# Sleep for 30 seconds
27+
sleep 30
28+
done

.github/workflows/pre-commit.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,21 @@ jobs:
1616
# TODO(markblee): Remove gcp,vertexai_tensorboard from CI. (needed by pytype)
1717
- run: pip install '.[core,dev,grain,gcp,vertexai_tensorboard,open_api]'
1818
# pylint uses approx 12GB of memory during this run, look into split to decrease?
19-
- run: pre-commit run --all-files
19+
- run: |
20+
# Start memory monitor as a background process.
21+
{ .github/scripts/monitor_memory.sh & } || true
22+
MONITOR_PID=$!
23+
# A short sleep to wait for monitor process to start.
24+
sleep 1
25+
26+
# Start pre-commit check.
27+
echo "====== Starting pre-commit... ======"
28+
pre-commit run --all-files
29+
echo "====== pre-commit completed. ======"
30+
31+
# Clean up memory monitor process.
32+
if kill -0 $MONITOR_PID 2>/dev/null; then
33+
echo "Manually stopping monitor process..."
34+
kill $MONITOR_PID || true
35+
fi
2036
- run: pytype -j auto .

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ persistent=no
2828
# load-plugins=pylint.extensions.docparams
2929

3030
# Use multiple processes to speed up Pylint.
31-
jobs=4
31+
jobs=1
3232

3333
# Allow loading of arbitrary C extensions. Extensions are imported into the
3434
# active Python interpreter and may run arbitrary code.

0 commit comments

Comments
 (0)