Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex DataSphere
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Creating a project
    • Installing dependencies
    • Running sample code in a notebook
    • Version control. Working with checkpoints
    • Managing computing resources
    • Clearing the interpreter state
    • Sharing a notebook
      • Publishing a notebook
      • Exporting a project
    • Changing a name or description
    • Deleting a project
    • Working with Git
    • Setting up integration with Data Proc
  • Concepts
    • Overview
    • Project
    • List of pre-installed software
    • Available commands
    • Computing resource configurations
    • Integration with version and data control systems
    • Integration with Data Proc
    • Quotas and limits
  • Access management
  • Pricing policy
  • Questions and answers
  1. Step-by-step instructions
  2. Running sample code in a notebook

Running sample code in a notebook

  • Before you start
  • Run the sample code
    • Code examples for loading data from different sources

The notebook provides small code examples for loading data from different sources.

Before you start

If a project is already open, open the tab with a notebook.

If not, open the project:

  1. In the management console, open the DataSphere section in the folder where you work with DataSphere projects.

  2. Go to the Projects tab.
  3. Select the project you want to open and click .
  4. Choose Open and wait for the project to open.

Run the sample code

To run the sample code:

  1. In the top panel in the project window, click Kernel.
  2. In the menu that opens, click Yandex Disk.
  3. In the menu that opens, click the example you want to run.
  4. The example code will be inserted into the notebook cell.
    1. Follow the steps in the example.
    2. Run the cell. To do this, click .

Code examples for loading data from different sources

To run the code examples, you will need the app ID and secret.
To get them:

  1. Follow the link: https://oauth.yandex.ru/client/new.
  2. Fill in the field Application name.
  3. In Platforms, choose Web service.
  4. In the Callback URI #1 field, enter https://oauth.yandex.ru/verification_code.
  5. In Accesses, mark access for Yandex.Disk.

Uploading the contents of a remote file to a local file

from cloud_ml.storage.api import Storage

disk = Storage.ya_disk(application_id='ID', application_secret='secret')

disk.get('path/to/file/within/ya/disk/file.txt', 'path/to/file.txt')

Uploading the contents of a remote directory to a local file

from cloud_ml.storage.api import Storage

disk = Storage.ya_disk(application_id='ID', application_secret='secret')

disk.get_dir('path/to/dir/within/ya/disk', 'path/to/dir')

Uploading the contents of a local file to a remote file

from cloud_ml.storage.api import Storage

disk = Storage.ya_disk(application_id='ID', application_secret='secret')

disk.put('path/to/file.txt', 'path/to/file/within/ya/disk/file.txt')

Uploading the contents of a local directory to a remote directory

from cloud_ml.storage.api import Storage

disk = Storage.ya_disk(application_id='ID', application_secret='secret')

disk.put_dir('path/to/dir', 'path/to/dir/within/ya/disk')
In this article:
  • Before you start
  • Run the sample code
  • Code examples for loading data from different sources
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC