-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper method for determining environment
- Loading branch information
Showing
2 changed files
with
31 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pathlib import Path | ||
import os | ||
|
||
def determine_environment(): | ||
|
||
#determine if we're running on Google Colab | ||
try: | ||
import google.colab | ||
exec_env = "colab" #we seem to be on colab | ||
print("Assuming this notebook is running on Google Colab") | ||
except: | ||
exec_env = "binder" #assume it's binder | ||
|
||
if exec_env == "colab": | ||
working_dir = f"{Path.cwd()}/combine-notebooks/notebooks/results" | ||
os.system('git clone https://github.com/combine-org/combine-notebooks') | ||
os.chdir('combine-notebooks') | ||
os.system('pip install .') | ||
|
||
else: | ||
#binder starts off in the notebook's folder | ||
working_dir = f"{Path.cwd()}/results" | ||
|
||
os.chdir(working_dir) | ||
|
||
print("Current directory is: %s"%working_dir) | ||
return working_dir |