glenn-jocher commited on
Commit
b1cf25d
·
unverified ·
1 Parent(s): e9941d5

check_git_status() asserts (#1977)

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -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 pip install gsutil
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
- if Path('.git').exists() and not Path('/workspace').exists() and check_online(): # not exist '/.dockerenv'
64
- url = subprocess.check_output(
65
- 'git fetch && git config --get remote.origin.url', shell=True).decode('utf-8')[:-1]
66
- n = int(subprocess.check_output(
67
- 'git rev-list $(git rev-parse --abbrev-ref HEAD)..origin/master --count', shell=True)) # commits behind
68
- if n > 0:
69
- print(f"⚠️ WARNING: code is out of date by {n} {'commits' if n > 1 else 'commmit'}. "
70
- f"Use 'git pull' to update or 'git clone {url}' to download latest.")
71
- else:
72
- print(f'up to date with {url} ')
 
 
 
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