Download all files in a path on Jupyter notebook server

前端 未结 7 668
日久生厌
日久生厌 2021-01-29 18:46

As a user in a class that runs Jupyter notebooks for assignments, I have access to the assignments via the web interface. I assume the assignments are stored somewhere in my per

相关标签:
7条回答
  • 2021-01-29 18:54

    The easiest way is to archive all content using tar, but there is also an API for files downloading.

    GET /files/_FILE_PATH_
    

    To get all files in folder you can use:

    GET /api/contents/work
    

    Example:

    curl https://server/api/contents?token=your_token
    curl https://server/files/path/to/file.txt?token=your_token --output some.file
    

    Source: Jupyter Docs

    0 讨论(0)
  • 2021-01-29 18:55

    I don't think this is possible with wget, even with the wget -r option. You may have to download them individually (using the Download option in the dashboard view (which is only available on single, non-directory, non-running notebook items) if that is available to you.

    However, it is likely that you are not able to download them since if your teacher is using grading software like nbgrader then the students having access to the notebooks themselves is undesirable - since the notebooks can contain information about the answers as well.

    0 讨论(0)
  • 2021-01-29 18:56

    Try running this as separate cell in one of your notebooks:

    !tar chvfz notebook.tar.gz *
    

    If you want to cover more folders up the tree, write ../ before the * for every step up the directory. The file notebook.tar.gz will be saved in the same folder as your notebook.

    0 讨论(0)
  • 2021-01-29 19:03

    You can create a new terminal from the "New" menu and call the command described on https://stackoverflow.com/a/47355754/8554972:

    tar cvfz notebook.tar.gz *
    

    The file notebook.tar.gz will be saved in the same folder as your notebook.

    0 讨论(0)
  • from google.colab import files
    
    files.download("/content/data.txt")
    

    These lines might work if you are working in a google colab or Jupyter notebook.

    The first line imports the library files The second one, downloads your created file, example:"data.txt" (your file name) located in the content.

    0 讨论(0)
  • 2021-01-29 19:16

    Try first to get the directory by:

    import os
    os.getcwd()
    

    And then use snipped from How to create a zip archive of a directory. You can download complete directory by zipping it. Good luck!

    0 讨论(0)
提交回复
热议问题