Spaces:
Paused
Paused
File size: 11,039 Bytes
715606b a2c34a6 715606b a2c34a6 715606b a2c34a6 715606b a2c34a6 715606b a2c34a6 715606b a2c34a6 715606b a2c34a6 715606b a2c34a6 715606b |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "SavtaDepth Colab.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "QKUz-9qCbHRH"
},
"source": [
"<center> <a href=\"https://dagshub.com\"><img alt=\\\"DAGsHub\\\" width=500px src=https://raw.githubusercontent.com/DAGsHub/client/master/dagshub_github.png></a> </center>\n",
"\n",
"# SavtaDepth Colab Environment\n",
"\n",
"### ***This notebook is meant to be run on Google Colab***\n",
"\n",
"This notebook is a tool to setup and run experiments for [SavtaDepth](https://dagshub.com/OperationSavta/SavtaDepth) on Google Colab, while maintaining a relatively clean environment and using version control to promote reproducibility. Following (and modifying where necessary) the cells below should let you git clone a project into colab, download the data, run it, and push it to https://DAGsHub.com which is a free platform for open source data science. \n",
"\n",
"SavtaDepth is an [Open Source Data Science](https://dagshub.com/blog/a-case-for-open-source-data-science/) project. We'd love to get help from the community, so if you'd like to contribute head over to the [project page](https://dagshub.com/OperationSavta/SavtaDepth) to get started."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wJNCkwSIa7To"
},
"source": [
"# General Setup\n",
"**Before you start, make a copy of this notebook to your Google Drive**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "2Tq2Dl33XDqw"
},
"source": [
"%reload_ext autoreload\n",
"%autoreload 2"
],
"execution_count": 1,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "UiFeCt5xXEK1"
},
"source": [
"from google.colab import auth\n",
"auth.authenticate_user()"
],
"execution_count": 2,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "xn8URgDmWBKm"
},
"source": [
"Clone Git Repo from DAGsHub. **Make sure to put in your username so that you clone your version of the project**."
]
},
{
"cell_type": "code",
"metadata": {
"id": "jxOO9c2hU_zM"
},
"source": [
"!git clone https://dagshub.com/{your_dagshub_user}/SavtaDepth.git\n",
"%cd SavtaDepth/"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "4bndN7kVagXj"
},
"source": [
"*Note: Currently you can't see the intermediate output so it's completely opaque and long process + you can't set up credentials for google within the shell instance*\n",
"\n",
"This installs conda, creates a virtual environment and installs all relevant requirements."
]
},
{
"cell_type": "code",
"metadata": {
"id": "JAsG5scFYjqd"
},
"source": [
"%%bash\n",
"MINICONDA_INSTALLER_SCRIPT=Miniconda3-py37_4.8.3-Linux-x86_64.sh\n",
"MINICONDA_PREFIX=/usr/local\n",
"wget https://repo.continuum.io/miniconda/$MINICONDA_INSTALLER_SCRIPT\n",
"chmod +x $MINICONDA_INSTALLER_SCRIPT\n",
"./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX\n",
"rm $MINICONDA_INSTALLER_SCRIPT\n",
"make env"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "TR0asdFLaeAV"
},
"source": [
"Since locally we might not be working with a GPU, here we install the pytorch version that should use the GPU provided by Google Colab. After that we install the rest of the requirements from the requirements.txt file."
]
},
{
"cell_type": "code",
"metadata": {
"id": "n3U6qqVFWYRm"
},
"source": [
"!bash -c \"source activate savta_depth && conda install -y pytorch torchvision cudatoolkit=10.1 -c pytorch && make load_requirements\""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "WOzZu9GQaaeI"
},
"source": [
"### Pull DVC files from our remote"
]
},
{
"cell_type": "code",
"metadata": {
"id": "sNmiqub0WbqT"
},
"source": [
"!bash -c \"source activate savta_depth && dvc pull -r dvc-remote\""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "qNNIfodJc_0g"
},
"source": [
"\n",
"\n",
"---\n",
"\n",
"\n",
"# Setup is done!\n",
"If you've made it here, everything is set up. You have the code and data in the file viewer to the left. You can edit the files located in SavtaDepth/src/code/ as you like. You can see the YAML defining the project pipeline in dvc.yaml. If you change dependencies or outputs (for example, add an additional code file for the training stage), make sure you edit the pipeline to reflect this.\n",
"\n",
"### Once you are done with your changes run the cell below to run the pipeline end-to-end\n",
"* You can run this multiple times if you've made a change and want to test it\n",
"* If you want to run only a specific stage you can change the `dvc repro` command to any other command you like.\n",
"\n",
"▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽▽"
]
},
{
"cell_type": "code",
"metadata": {
"id": "fwOfOwnrZWMe"
},
"source": [
"!bash -c \"source activate savta_depth && dvc repro\""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "PAxz-29WhN12"
},
"source": [
"---\n",
"# Commiting Your Work and Pushing Back to DAGsHub\n",
"\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "kyse-hAuZY9X"
},
"source": [
"!git status"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Ib12i6aOhbgI"
},
"source": [
"# Add the files you want to commit\n",
"!git add {your files here}"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "duM9An0Khr_F"
},
"source": [
"Run the following 2 cells without modifications. They will prompt you for a commit message, and for credentials to push back to DAGsHub"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "V9SYYA9Zh3f9"
},
"source": [
"**Commiting**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "_fjym_38hhgl"
},
"source": [
"os.environ['COMMIT_MESSAGE'] = input('Enter the commit message for you commit: ')\n",
"!git commit -m \"${COMMIT_MESSAGE}\"\n",
"os.environ['COMMIT_MESSAGE'] = \"\""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "mWtgXU0ph6Dv"
},
"source": [
"**Pushing to DAGsHub**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "z7LoVk9Zh9GC"
},
"source": [
"# If this stage fails, make sure to remove outputs as it will show your password to whoever it is shared with.\n",
"from getpass import getpass\n",
"import os\n",
"\n",
"os.environ['USER'] = input('Enter the username of your DAGsHub account: ')\n",
"os.environ['PASSWORD'] = getpass('Enter the password of your DAGsHub account: ')\n",
"os.environ['REPO_URL'] = input('Enter the url of your DAGsHub project: ').split('https://')[-1]\n",
"os.environ['DAGSHUB_AUTH'] = os.environ['USER'] + ':' + os.environ['PASSWORD']\n",
"\n",
"!git push https://$DAGSHUB_AUTH@$REPO_URL.git"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "MXlzJbuLiFWb"
},
"source": [
"***NOTE: ALWAYS RUN THIS CELL AFTER THE PREVIOUS***, it will delete your DAGsHub password in case you share this notebook with someone"
]
},
{
"cell_type": "code",
"metadata": {
"id": "6-yZzyeAiGPI"
},
"source": [
"os.environ['PASSWORD'] = os.environ['DAGSHUB_AUTH'] = \"\""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "FImsqcvYie77"
},
"source": [
"## Push data back to your DVC Remote\n",
"For this step you must first create a DVC remote on some cloud provider. We recommend Google Cloud Storage. If you're not sure how to set up a DVC remote, [follow these instructions](https://dagshub.com/docs/getting-started/set-up-remote-storage-for-data-and-models/#create-a-storage-bucket) (you only need to go through creating a storage bucket and adding permissions)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "L4XWSvPQjfLb"
},
"source": [
"Add your storage bucket to DVC (replace {bucket-name} with the bucket name you chose)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "kGx03PpijiAW"
},
"source": [
"!bash -c \"source activate savta_depth && dvc remote add my-dvc-remote gs://{bucket-name}\""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "i8uYEa64imDl"
},
"source": [
"from google.colab import auth\n",
"auth.authenticate_user()"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ZsM5epDbiotM"
},
"source": [
"!bash -c \"source activate savta_depth && dvc push -r my-dvc-remote\""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "ne7pU7bMj18m"
},
"source": [
"# That's it, you can now create a PR on DAGsHub."
]
}
]
} |