Skip to content

Drive quickstart

Make a Drive, write to it from one sandbox, and read it from the next, with the glac command line, the Python SDK or the console.

Обновлено

Эта страница ещё не переведена на язык «русский»: вот она на английском.

You need a project’s API key in GLAC_API_KEY, and glac or the Python SDK installed: get started says how.

With the command line

Make a Drive of at most 1 GiB (one may be up to 10 GiB on Free, 1 TiB on Paid), and a sandbox that mounts it at /data. --region na|eu|ap would say where it is; without it, it is in the region of the API you call:

glac drives create --name data --size-bytes 1GiB
glac sandboxes create --name first --drive data:/data
glac sandboxes exec first -- sh -c 'echo kept > /data/note'

Take it from that sandbox and give it to another one that runs:

glac drives detach data first
glac sandboxes create --name second
glac drives attach data second:/data
glac sandboxes exec second -- cat /data/note      # kept

Look at it, and clean up:

glac drives ls                                    # each Drive: its size, what is written, its region, who has it
glac drives get data                              # and the machine that writes it now
glac sandboxes rm first second                    # the Drive stays
glac drives rm data

A Drive is one sandbox’s at a time: attaching one that another sandbox has is refused (409 drive_attached). Deleting a sandbox detaches its Drives, which keep what they hold. A Drive that is mounted is not deleted.

With the Python SDK

from glac import DriveMount, Glac

glac = Glac()  # GLAC_API_KEY and GLAC_API_URL
drive = glac.drives.create(name="data", size_bytes=1 << 30)   # region="eu" to choose where

first = glac.sandboxes.create(drives=[DriveMount("/data", drive)])
first.run("echo kept > /data/note")
glac.drives.detach(first, drive)

second = glac.sandboxes.create()
glac.drives.attach(second, drive, "/data")
print(second.run("cat /data/note").stdout)      # kept
print(glac.drives.get("data").used_bytes)       # what it is billed by

first.delete()
second.delete()                                 # detaches it
drive.delete()

A Drive that another machine held last is brought to the sandbox’s machine first. While that cannot be done yet, the call answers 503 copy_behind or drive_not_brought, which are retryable: the SDK tries again as its retries say, and then raises, for you to ask again a moment later.

In the console

Open the [console](https://console.glac.ai/console/), pick the project, and choose Drives under Storage. The page lists the project’s Drives: name, kind (a Drive, or a key’s Drive), size, what is written, the sandbox that has it, region, status and when it was made. Make, mount and delete Drives with the command line or the API.

Next

Навигация

Начните вводить запрос…

↑↓ навигация↵ выборEsc закрыть