Skip to main content

Datalayer on CLI

Datalayer provides a Command Line Interface (CLI) that supports the platform features.

Installation

Check you have python>=3.9 and pip and install Datalayer with the following command in your terminal.

# Use --upgrade if you want to update an existing installation to the latest version.
pip install datalayer
Environment setup with conda

If you are using conda, you can create a new environment and install the required packages as follows. Note that conda and miniconda are interchangeable.

ENV_NAME=datalayer
miniconda create -y -n $ENV_NAME
miniconda activate $ENV_NAME
miniconda install -c conda-forge -y python=3.11 pip
pip install datalayer

Once installed you can invoke the datalayer command.

datalayer

Datalayer - Version 1.0.0 - Connected as None on https://prod1.datalayer.run

[DatalayerCLI] One of `about` `benchmarks` `envs` `runtimes` `login` `logout` `web` `who` `whoami` must be specified.

Ask details adding --help to any of the commands.

datalayer --help
The Datalayer CLI application.

Subcommands
===========
Subcommands are launched as `datalayer_core cmd [args]`. For information on
using subcommand 'cmd', do: `datalayer_core cmd -h`.

about
benchmarks
envs
runtimes
login
logout
...
tip

You can use dla or even d as shortcut, instead of datalayer if you prefer.

The about command is available to explain you the features

datalayer about

Datalayer - Version 1.0.0 - Connected as None on https://prod1.datalayer.run

About

Datalayer provides a command line tool allowing to list,
create, terminate and open a console against with Runtimes.

Read more on https://datalayer.io

All command lines support an option --run-url to set the URL of the Datalayer RUN cluster providing the Datalayer services.

datalayer runtimes list --run-url https://prod1.datalayer.run

Alternatively, you can set environment variables to avoid adding parameters to every command.

export DATALAYER_RUN_URL="https://prod1.datalayer.run"
export DATALAYER_TOKEN="MY_TOKEN"
export DATALAYER_EXTERNAL_TOKEN="MY_EXTERNAL_TOKEN"
datalayer whoami
datalayer envs list
datalayer runtimes list

We also made it easy for you to get the values via a User Interface (on SaaS, JupyterLab...). Go to the action menu of the Kernel list and select the Copy terminal command line action. This will copy in your clipboard the command to run from CLI with the needed environment variables.

Account

Before login, you should have a valid account created during the Join process from the SaaS.

Using the Web Browser

To login, you can use the following command.

datalayer login

This command will open a new tab in your web browser to authenticate you.

Once authenticated, you can close your browser.

info

If your cached credentials are obsolete, you will be prompted to log in when you run any of the command lines.

Using the CLI

If you prefer not to use your web browser, you can add the --no-browser option to any command. When using the --no-browser option, you will be prompted to either:

  • Provide a Username and Password.
  • Provide a Token.
datalayer login --no-browser --run-url=...
? How do you want to log in? (Use arrow keys)
» Username/Password
Token

Ask help to get all the login options.

datalayer login --help
An application to log into a Runtime provider.

datalayer login

Options
=======
The options below are convenience aliases to configurable class-options,
as listed in the "Equivalent to" description-line of the aliases.
To see all configurable class-options for some <cmd>, use:
<cmd> --help-all

--debug
set log level to logging.DEBUG (maximize logging output)
Equivalent to: [--Application.log_level=10]
...

Using a Token

If you have a Token, you can use it to authenticate. The Token can be a Datalayer Token or an External Token in case of integration with an External IAM Provider.

Just use the --token option to provide the Token directly in any command.

datalayer envs list --token TOKEN --run-url RUN_URL

Environments

Refer to the Environments feature documentation for more information.

You can list the available environments using the following CLI command:

datalayer envs list
                                               Environments                                           
┏━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Cost p… ┃ Name ┃ Description ┃ ┃ Resources ┃
┡━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ python-s… │ 0.01 │ Python Simple En… │ A Python environment for simp… │ │ {"cpu": "250m", "memory… │
└───────────┴─────────┴───────────────────┴────────────────────────────────┴──┴──────────────────────────┘

Runtimes

Refer to the Runtimes feature documentation for more information.

Refer to the Launch a Runtime feature documentation for more information on the different options available.

Use datalayer runtimes create ENV_ID --given-name GIVEN_NAME --credits-limit CREDITS_LIMIT.

datalayer runtimes create python-simple-env --given-name k1 --credits-limit 3
                                            Jupyter Runtimes                                              
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Runtime ID ┃ Runtime Name┃ Environment ┃ Expired At ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ jupyter-01j2m0zt2kaheyy3yzn021g032 │ k1 │ python-simple-env │ 2024-08-10T17:29:19.355000+02:… │
└────────────────────────────────────┴─────────────┴───────────────────┴─────────────────────────────────┘