Giter Club home page Giter Club logo

udacity-howtodownloadworkspaces's Introduction

How to Download Udacity Workspace

Download Jupyter workspace

To download all files in a Jupyter workspace:

  • Go to File > New Notebook > Python 3 - this will create a new Jupyter Notebook.
  • Paste the code snippet below into the code cell in the new Jupyter Notebook
  • Click on Jupyter logo (top left of the screen) to open the directory browser. This will show all files and directories in the workspace.
  • Find workspace_archive.tar. download it.

Download extra data located outside of current workspace

Occassionally, you'll see in the code of a Notebook where it gets data from a different directory than the current workspace. In other words, the data is located outside of current ./ working directory.

For example, the code below is trying to get data from ../../data:

def example():
    data = os.path.join(os.getcwd(), '..', '..','data')
    return np.load(data)

To download the data, simply run make_tar_file function from the code snippet below with dir_name being the path to the data:

    dir_name = os.path.join(os.getcwd(), '..', '..','data')
    make_tar_file(dir_name)

Download Python workspace

For Python workspaces, use the code snippet below but put it in a Python file instead.

Download Snippet

The snippet below compresses all files in a workspace and put them in workspace_archive.tar file.

""" Source:
      - https://stackoverflow.com/questions/48122744/how-to-download-all-files-and-folder-hierarchy-from-jupyter-notebook
"""
import os
import tarfile

def recursive_files(dir_name='.', ignore=None):
    for dir_name,subdirs,files in os.walk(dir_name):
        if ignore and os.path.basename(dir_name) in ignore:
            continue

        for file_name in files:
            if ignore and file_name in ignore:
                continue

            yield os.path.join(dir_name, file_name)

def make_tar_file(dir_name='.', target_file_name='workspace_archive.tar', ignore=None):
    tar = tarfile.open(target_file_name, 'w')

    for file_name in recursive_files(dir_name, ignore):
        tar.add(file_name)

    tar.close()


dir_name = '.'
target_file_name = 'workspace_archive.tar'
# List of files/directories to ignore
ignore = {'.ipynb_checkpoints', '__pycache__', target_file_name}

make_tar_file(dir_name, target_file_name, ignore)

udacity-howtodownloadworkspaces's People

Contributors

udacimak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.