Package: backend.ai-client
The official client SDK forBackend.AIUsage (KeyPair mode)You should set the access key and secret key as environment variables to use the API.
Grab your keypair fromcloud.backend.aior your cluster
admin.On Linux/macOS, create a shell script asmy-backend-ai.shand run it before using
thebackend.aicommand:exportBACKEND_ACCESS_KEY=...exportBACKEND_SECRET_KEY=...exportBACKEND_ENDPOINT=https://my-precious-clusterexportBACKEND_ENDPOINT_TYPE=apiOn Windows, create a batch file asmy-backend-ai.batand run it before using
thebackend.aicommand:chcp 65001setPYTHONIOENCODING=UTF-8setBACKEND_ACCESS_KEY=...setBACKEND_SECRET_KEY=...setBACKEND_ENDPOINT=https://my-precious-clustersetBACKEND_ENDPOINT_TYPE=apiNote that you need to switch to the UTF-8 codepage for correct display of
special characters used in the console logs.Usage (Session mode)ChangeBACKEND_ENDPOINT_TYPEto “session” and set the endpoint to the URL of your console server.exportBACKEND_ENDPOINT=https://my-precious-clusterexportBACKEND_ENDPOINT_TYPE=session$backend.ailoginUser ID: myid@mydomain.com
Password:
✔ Login succeeded!$backend.ai...# run any command$backend.ailogout✔ Logout done.The session expiration timeout is set by the console server.Command-line Interfacebackend.aicommand is the entry point of all sub commands.
(Alternatively you can use a verbosely long version:python-mai.backend.client.cli)Highlight:runcommandTheruncommand execute a code snippet or code source files on a Backend.AI compute session
created on-the-fly.To run the code specified in the command line directly,
use-coption to pass the code string (like a shell).$backend.airunpython:3.6-ubuntu18.04-c"print('hello world')"∙ Client session token: d3694dda6e5a9f1e5c718e07bba291a9
✔ Kernel (ID: zuF1OzMIhFknyjUl7Apbvg) is ready.
hello worldBy default, you need to specify language with full version tag likepython:3.6-ubuntu18.04. Depending on the Backend.AI admin’s language
alias settings, this can be shortened just aspython. If you want to
know defined language aliases, contact the admin of Backend.AI server.For more complicated programs, you may upload multiple files and then build &
execute them.  The below is a simple example to runa sample C program.$gitclonehttps://gist.github.com/achimnol/df464c6a3fe05b21e9b06d5b80e986c5c-exampleCloning into 'c-example'...
Unpacking objects: 100% (5/5), done.$cdc-example$backend.airungcc:gcc6.4-alpine3.8main.cmylib.cmylib.h∙ Client session token: 1c352a572bc751a81d1f812186093c47
✔ Kernel (ID: kJ6CgWR7Tz3_v2WsDHOwLQ) is ready.
✔ Uploading done.
✔ Build finished.
myvalue is 42
your name? LABLUP
hello, LABLUP!Please refer the--helpmanual provided by theruncommand.Highlight:startandappcommandbackend.ai startis simliar to theruncommand in that it creates a new compute session,
but it does not execute anything there.
You can subsequently callbackend.ai run-t<sessionId> ...to execute codes snippets
or usebackend.ai appcommand to start a local proxy to a container service such as Jupyter which
runs inside the compute session.$backend.aistart-tmysess-rcpu=1-rmem=2glablup/python:3.6-ubuntu18.04∙ Session ID mysess is created and ready.
∙ This session provides the following app services: ipython, jupyter, jupyterlab$backend.aiappmysessjupyter∙ A local proxy to the application "jupyter" provided by the session "mysess" is available at: http://127.0.0.1:8080Highlight:psandrmcommandYou can see the list of currently running sessions using your API keypair.$backend.aipsSession ID    Lang/runtime              Tag    Created At                        Terminated At    Status      CPU Cores    CPU Used (ms)    Total Memory (MiB)    Used Memory (MiB)    GPU Cores
------------  ------------------------  -----  --------------------------------  ---------------  --------  -----------  ---------------  --------------------  -------------------  -----------
88ee10a027    lablup/python:3.6-ubuntu         2018-12-11T03:53:14.802206+00:00                   RUNNING             1            16314                  1024                 39.2            0
fce7830826    lablup/python:3.6-ubuntu         2018-12-11T03:50:10.150740+00:00                   RUNNING             1            15391                  1024                 39.2            0If you set-toption in theruncommand, it will be used as the session ID—you may use it to assign a human-readable, easy-to-type alias for your sessions.
These session IDs can be reused after the current session using the same ID terminates.To terminate a session, you can useterminateorrmcommand.$backend.airm5baafb2136029228ca9d873e1f2b4f6a✔ Done.Highlight:proxycommandTo use API development tools such as GraphiQL for the admin API, run an insecure
local API proxy.  This will attach all the necessary authorization headers to your
vanilla HTTP API requests.$backend.aiproxy∙ Starting an insecure API proxy at http://localhost:8084More commands?Please runbackend.ai--helpto see more commands.Troubleshooting (FAQ)There are error reports related tosimplejsonwith Anaconda on Windows.
This package no longer depends on simplejson since v1.0.5, so you may uninstall it
safely since Python 3.5+ offers almost identicaljsonmodule in the standard
library.If you really need to keep thesimplejsonpackage, uninstall the existing
simplejson package manually and try reinstallation of it by downloadinga
pre-built binary wheel from here.