-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathsetup_colab.py
42 lines (25 loc) · 1.1 KB
/
setup_colab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import sys
import subprocess
drivepath='/content/drive/'
if 'google.colab' in sys.modules:
from google.colab import drive
# 'Hmmm, seems you\'re not in colab :) Try again later.'
drive.mount(drivepath, force_remount=True)
mydrive = drivepath + '/MyDrive/'
os.chdir(mydrive)
try:
import desihigh
except:
print('Failed to import desihigh; Cloning.')
print('git clone https://github.com/michaelJwilson/desihigh.git --depth=1')
subprocess.run('git clone https://github.com/michaelJwilson/desihigh.git --depth=1', shell=True, check=True)
try:
sys.path.append(mydrive)
import desihigh
print('Successfully cloned DESI High to Google Drive.')
except Exception as EE:
emessage = 'Failed to setup DESI High @ colab. Please create a ticket at https://github.com/michaelJwilson/desihigh.git and include:\n\n{}\n\n{}'.format(EE, sys.path)
raise RuntimeError(emessage)
else:
print('It appears you are not on Google Colab (!)')