<jupyter_start><jupyter_text>Getting started with Colab + GitHub + Google Drive<jupyter_code>import xarray
# although we started this notebook from a binder badge here https://github.com/scottyhq/colab-experiments
# we don't have the full repository contents in the default directory
!ls
# but edits can be committed back to github via `File --> Save a Copy in GitHub`
# Connecting data from google drive
# Folder sidebar --> Drive icon --> auto-creates code cell below:
# Seems like this can be unreliable for shared drives...
# https://github.com/googlecolab/colabtools/issues/1494
# This also is going to be challenging to run anywhere other than colab 
# https://stackoverflow.com/questions/60008929/how-to-use-google-colab-local-runtime-and-connect-to-google-drive
# Running the code sends you to an authorization URL to get a token
# <-- after a few seconds you get a 'drive' folder over on the left
from google.colab import drive
drive.mount('/content/drive')
ls /content/drive
ls /content/drive/Shareddrives/Incubator2021/data/dataset/
# Ok there is our data! Now how to open with xarray? is xarray installed in the default environment?
import xarray as xr
# It is! but it's an older version compared to the one we want (0.15.1) 
xr.__version__
# Conda is not installed. pip is though, so you can upgrade a package with the -U flag
#! pip install -U xarray netcdf4
# might have to restart runtime?
datadir = '/content/drive/Shareddrives/Incubator2021/data/dataset/'
ds = xr.open_dataset(f'{datadir}/dataset.nc')
ds
# Now lets try to connect to a GPU?
# Runtime --> Change runtime type --> GPU
# WARNING: you have to re-execute everything if doing this (doesn't simply attach GPU)
# (so best to install libraries in first cell and ensure correct runtime before starting execution)
import xarray as xr
xr.__version__<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08423326133909287, 'fraction_numerical': 0.013498920086393088, 'mean_word_length': 4.418128654970761, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '610651', 'license': 'MIT', 'n_tokens_mistral': 567, 'n_tokens_neox': 534, 'n_words': 233, 'path': 'configure.ipynb', 'repo_name': 'scottyhq/colab-experiments', 'size': '1852'}