check_git_status() asserts (#1977)
Browse files- Dockerfile +2 -2
- utils/general.py +13 -10
Dockerfile
CHANGED
@@ -7,8 +7,8 @@ RUN apt update && apt install -y screen libgl1-mesa-glx
|
|
7 |
# Install python dependencies
|
8 |
RUN pip install --upgrade pip
|
9 |
COPY requirements.txt .
|
10 |
-
RUN pip install -r requirements.txt
|
11 |
-
RUN
|
12 |
|
13 |
# Create working directory
|
14 |
RUN mkdir -p /usr/src/app
|
|
|
7 |
# Install python dependencies
|
8 |
RUN pip install --upgrade pip
|
9 |
COPY requirements.txt .
|
10 |
+
RUN pip install -r requirements.txt gsutil wandb
|
11 |
+
RUN wandb disabled
|
12 |
|
13 |
# Create working directory
|
14 |
RUN mkdir -p /usr/src/app
|
utils/general.py
CHANGED
@@ -60,16 +60,19 @@ def check_git_status():
|
|
60 |
# Recommend 'git pull' if code is out of date
|
61 |
print(colorstr('github: '), end='')
|
62 |
try:
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
except Exception as e:
|
74 |
print(e)
|
75 |
|
|
|
60 |
# Recommend 'git pull' if code is out of date
|
61 |
print(colorstr('github: '), end='')
|
62 |
try:
|
63 |
+
assert Path('.git').exists(), 'skipping check (not a git repository)'
|
64 |
+
assert not Path('/workspace').exists(), 'skipping check (Docker image)' # not Path('/.dockerenv').exists()
|
65 |
+
assert check_online(), 'skipping check (offline)'
|
66 |
+
|
67 |
+
cmd = 'git fetch && git config --get remote.origin.url' # github repo url
|
68 |
+
url = subprocess.check_output(cmd, shell=True).decode()[:-1]
|
69 |
+
cmd = 'git rev-list $(git rev-parse --abbrev-ref HEAD)..origin/master --count' # commits behind
|
70 |
+
n = int(subprocess.check_output(cmd, shell=True))
|
71 |
+
if n > 0:
|
72 |
+
print(f"⚠️ WARNING: code is out of date by {n} {'commits' if n > 1 else 'commmit'}. "
|
73 |
+
f"Use 'git pull' to update or 'git clone {url}' to download latest.")
|
74 |
+
else:
|
75 |
+
print(f'up to date with {url} ✅')
|
76 |
except Exception as e:
|
77 |
print(e)
|
78 |
|