Download File
- The filesystem of the Notebook Lab is persistent. However, the filesystem of the Kernel is ephemeral and is not linked to the filesystem of the Notebook Lab.
- Any files that are created in the Kernel filesystem are deleted when the Kernel is restarted or shut down.
- You can download a file from the Kernel filesystem to your local filesystem using the
download_file
method.
import h2o_notebook
await h2o_notebook.Session().download_file("world.txt")
- Otherwise, you can use H2O Drive Python client to move files between the Kernel and H2O Drive.
Manage files with H2O Drive
- In the H2O AI Cloud environment, the running Notebook and JupyterLab environments operate on separate machines. This separation helps with cost control and improves operationalization when you’re ready to productionalize your notebooks.
- H2O Drive allows you to upload files from your local machine or other locations directly into your cloud environment. You can access H2O Drive from the H2O AI Cloud homepage.
- After you’ve uploaded your data, you can manage files in your H2O Drive storage directly from your Python environment. The following sections describe how to list files in your storage and download them to your local environment.
List files in your Storage
Use the following code to connect to H2O Drive and list all files in your storage:
import h2o_drive
# Connect to your storage
drive_client = await h2o_drive.Drive()
my_bucket = drive_client.my_bucket()
# View all files in your storage
all_objects = await my_bucket.list_objects()
print([o.key for o in all_objects])
This code connects to your H2O Drive instance and prints a list of file names in your storage.
Download a file from H2O Drive
To download a file from your H2O Drive storage to your local environment, use the following code:
# Download the file first to the notebook
await my_bucket.download_file(all_objects[0].key, "./downloaded-file.csv")
Feedback
- Submit and view feedback for this page
- Send feedback about H2O Notebook Labs to cloud-feedback@h2o.ai